From owner-svn-src-user@FreeBSD.ORG Fri Jul 8 01:32:04 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 8D3D6106564A; Fri, 8 Jul 2011 01:32:04 +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 7CA978FC13; Fri, 8 Jul 2011 01:32:04 +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 p681W46b086969; Fri, 8 Jul 2011 01:32:04 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p681W4nc086966; Fri, 8 Jul 2011 01:32:04 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107080132.p681W4nc086966@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 8 Jul 2011 01:32:04 +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: r223853 - 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: Fri, 08 Jul 2011 01:32:04 -0000 Author: gabor Date: Fri Jul 8 01:32:04 2011 New Revision: 223853 URL: http://svn.freebsd.org/changeset/base/223853 Log: - Partly fix fixed string matching by dropping weird code that is not necessary at all Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Jul 8 00:49:50 2011 (r223852) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Jul 8 01:32:04 2011 (r223853) @@ -79,8 +79,7 @@ static void revstr(tre_char_t *, int); * Returns: -1 on failure, 0 on success */ int -tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, - int cflags) +tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n) { /* Initialize. */ @@ -88,7 +87,6 @@ tre_fastcomp_literal(fastmatch_t *fg, co fg->bol = false; fg->eol = false; fg->reversed = false; - fg->cflags = cflags; fg->pattern = xmalloc((fg->len + 1) * sizeof(tre_char_t)); if (fg->pattern == NULL) return -1; @@ -120,7 +118,7 @@ tre_fastcomp_literal(fastmatch_t *fg, co * Returns: -1 on failure, 0 on success */ int -tre_fastcomp(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) +tre_fastcomp(fastmatch_t *fg, const tre_char_t *pat, size_t n) { int firstHalfDot = -1; int firstLastHalfDot = -1; @@ -133,7 +131,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ fg->eol = false; fg->reversed = false; fg->word = false; - fg->cflags = cflags; /* Remove end-of-line character ('$'). */ if ((fg->len > 0) && (pat[fg->len - 1] == TRE_CHAR('$'))) @@ -166,6 +163,8 @@ tre_fastcomp(fastmatch_t *fg, const tre_ * of the string respectively. */ fg->pattern = xmalloc((fg->len + 1) * sizeof(tre_char_t)); + if (fg->pattern == NULL) + return -1; memcpy(fg->pattern, pat, fg->len * sizeof(tre_char_t)); fg->pattern[fg->len] = TRE_CHAR('\0'); @@ -269,7 +268,6 @@ tre_fastexec(const fastmatch_t *fg, cons { unsigned int j; size_t siz, skip; - int cnt = 0; int ret = REG_NOMATCH; const char *str_byte = data; const void *startptr = NULL; @@ -306,10 +304,8 @@ tre_fastexec(const fastmatch_t *fg, cons j = fg->eol ? len - fg->len : 0; SKIP_CHARS(j); if (fastcmp(fg->pattern, startptr, fg->len, type) == -1) { - if (!(fg->cflags & REG_NOSUB) || (nmatch < 1)) - return REG_OK; - pmatch[cnt].rm_so = j; - pmatch[cnt].rm_eo = j + fg->len; + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + fg->len; return REG_OK; } } @@ -319,18 +315,9 @@ tre_fastexec(const fastmatch_t *fg, cons do { SKIP_CHARS(j - fg->len); if (fastcmp(fg->pattern, startptr, fg->len, type) == -1) { - if (!(fg->cflags & REG_NOSUB) || (nmatch < 1)) - return REG_OK; - pmatch[cnt++].rm_so = j - fg->len; - pmatch[cnt++].rm_eo = j; - nmatch--; - ret = REG_OK; - if (nmatch < 1) - return ret; - else { - j -= 2 * fg->len; - continue; - } + pmatch[0].rm_so = j - fg->len; + pmatch[0].rm_eo = j; + return REG_OK; } /* Shift if within bounds, otherwise, we are done. */ if (((long)j - (long)fg->len - 1) < 0) @@ -373,18 +360,9 @@ tre_fastexec(const fastmatch_t *fg, cons do { SKIP_CHARS(j); if (fastcmp(fg->pattern, startptr, fg->len, type) == -1) { - if (!(fg->cflags & REG_NOSUB) || (nmatch < 1)) - return REG_OK; - pmatch[cnt++].rm_so = j; - pmatch[cnt++].rm_eo = j + fg->len; - nmatch--; - ret = REG_OK; - if (nmatch < 1) - return ret; - else { - j += fg->len; - continue; - } + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + fg->len; + return REG_OK; } /* Shift if within bounds, otherwise, we are done. */ Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Fri Jul 8 00:49:50 2011 (r223852) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Fri Jul 8 01:32:04 2011 (r223853) @@ -44,7 +44,6 @@ typedef struct { int qsBc[UCHAR_MAX + 1]; #endif /* flags */ - int cflags; bool bol; bool eol; bool reversed; @@ -52,9 +51,8 @@ typedef struct { } fastmatch_t; int tre_fastcomp_literal(fastmatch_t *preg, const tre_char_t *regex, - size_t, int cflags); -int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t, - int cflags); + size_t); +int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t); int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[]); void tre_fastfree(fastmatch_t *preg);