From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 14:11:03 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9980B106566B; Thu, 18 Aug 2011 14:11:03 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7045A8FC12; Thu, 18 Aug 2011 14:11:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7IEB3sA060265; Thu, 18 Aug 2011 14:11:03 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IEB3Zg060263; Thu, 18 Aug 2011 14:11:03 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181411.p7IEB3Zg060263@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 14:11:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224968 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2011 14:11:03 -0000 Author: gabor Date: Thu Aug 18 14:11:03 2011 New Revision: 224968 URL: http://svn.freebsd.org/changeset/base/224968 Log: - Properly pass pattern length to underlying functions Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 13:33:34 2011 (r224967) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 14:11:03 2011 (r224968) @@ -34,7 +34,7 @@ #include "tre-internal.h" #include "xmalloc.h" -/* XXX: clean up */ +/* XXX: avoid duplication */ #define CONV_PAT \ int ret; \ tre_char_t *wregex; \ @@ -43,6 +43,17 @@ wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ if (wregex == NULL) \ return REG_ESPACE; \ + \ + if (TRE_MB_CUR_MAX == 1) \ + { \ + unsigned int i; \ + const unsigned char *str = (const unsigned char *)regex; \ + tre_char_t *wstr = wregex; \ + \ + for (i = 0; i < n; i++) \ + *(wstr++) = *(str++); \ + wlen = n; \ + } \ else \ { \ int consumed; \ @@ -87,7 +98,7 @@ tre_fixncomp(fastmatch_t *preg, const ch { CONV_PAT; - ret = tre_compile_literal(preg, wregex, n, cflags); + ret = tre_compile_literal(preg, wregex, wlen, cflags); xfree(wregex); return ret; @@ -99,8 +110,8 @@ tre_fastncomp(fastmatch_t *preg, const c CONV_PAT; ret = (cflags & REG_LITERAL) ? - tre_compile_literal(preg, wregex, n, cflags) : - tre_compile_fast(preg, wregex, n, cflags); + tre_compile_literal(preg, wregex, wlen, cflags) : + tre_compile_fast(preg, wregex, wlen, cflags); xfree(wregex); return ret; @@ -110,13 +121,13 @@ tre_fastncomp(fastmatch_t *preg, const c int tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) { - return tre_fixncomp(preg, regex, 0, cflags); + return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) { - return tre_fastncomp(preg, regex, 0, cflags); + return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int @@ -136,13 +147,13 @@ tre_fastwncomp(fastmatch_t *preg, const int tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) { - return tre_fixwncomp(preg, regex, 0, cflags); + return tre_fixwncomp(preg, regex, regex ? tre_strlen(regex) : 0, cflags); } int tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) { - return tre_fastwncomp(preg, regex, 0, cflags); + return tre_fastwncomp(preg, regex, regex ? tre_strlen(regex) : 0, cflags); } void