From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 13:24:32 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 862FD106566C; Wed, 10 Aug 2011 13:24:32 +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 6B3398FC14; Wed, 10 Aug 2011 13:24:32 +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 p7ADOW0t047207; Wed, 10 Aug 2011 13:24:32 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ADOWOe047204; Wed, 10 Aug 2011 13:24:32 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108101324.p7ADOWOe047204@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 13:24:32 +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: r224757 - 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: Wed, 10 Aug 2011 13:24:32 -0000 Author: gabor Date: Wed Aug 10 13:24:32 2011 New Revision: 224757 URL: http://svn.freebsd.org/changeset/base/224757 Log: - Drop reverse matching code. We always need the first match so it cannot be applied here. 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 Wed Aug 10 08:55:46 2011 (r224756) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 13:24:32 2011 (r224757) @@ -202,9 +202,7 @@ static void revs(char *str, int len); * next character after the comparison is within the pattern. With * wildcards, the position of the last dot effects the maximum shift * distance. - * The closer to the end the wild card is the slower the search. A - * reverse version of this algorithm would be useful for wildcards near - * the end of the string. + * The closer to the end the wild card is the slower the search. * * Examples: * Pattern Max shift @@ -383,10 +381,6 @@ int tre_fastcomp(fastmatch_t *fg, const tre_char_t *wpat, size_t n, int cflags) { - int firstHalfDot = -1; - int firstLastHalfDot = -1; - int lastHalfDot = 0; - /* Initialize. */ memset(fg, 0, sizeof(*fg)); fg->icase = (cflags & REG_ICASE); @@ -440,19 +434,9 @@ tre_fastcomp(fastmatch_t *fg, const tre_ (fg->wpattern[i] == TRE_CHAR('=')) || (fg->wpattern[i] == TRE_CHAR('-')) || (fg->wpattern[i] == TRE_CHAR(':')) || (fg->wpattern[i] == TRE_CHAR('/'))) { continue; - } else if (fg->wpattern[i] == TRE_CHAR('.')) { + } else if (fg->wpattern[i] == TRE_CHAR('.')) fg->hasdot = i; - if (i < fg->wlen / 2) { - if (firstHalfDot < 0) - /* Closest dot to the beginning */ - firstHalfDot = i; - } else { - /* Closest dot to the end of the pattern. */ - lastHalfDot = i; - if (firstLastHalfDot < 0) - firstLastHalfDot = i; - } - } else { + else { /* Free memory and let others know this is empty. */ free(fg->wpattern); fg->wpattern = NULL; @@ -464,22 +448,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ STORE_MBS_PAT; #endif - /* - * Determine if a reverse search would be faster based on the placement - * of the dots. - */ -// if ((!(fg->bol || fg->eol)) && -// (lastHalfDot && ((firstHalfDot < 0) || -// ((fg->wlen - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) { -// fg->reversed = true; -// fg->hasdot = fg->wlen - (firstHalfDot < 0 ? -// firstLastHalfDot : firstHalfDot) - 1; -// revstr(fg->wpattern, fg->wlen); -//#ifdef TRE_WCHAR -// revs(fg->pattern, fg->len); -//#endif -// } - FILL_QSBC; if (!fg->hasdot) FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); @@ -488,18 +456,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); #endif - /* - * Put pattern back to normal after pre-processing to allow for easy - * comparisons later. - */ - if (fg->reversed) - { - revstr(fg->wpattern, fg->wlen); -#ifdef TRE_WCHAR - revs(fg->pattern, fg->len); -#endif - } - return REG_OK; } @@ -561,21 +517,6 @@ tre_fastexec(const fastmatch_t *fg, cons return REG_OK; } } - } else if (fg->reversed) { - /* Quick Search algorithm. */ - j = len - fg->len; - do { - SKIP_CHARS(j); - COMPARE; - if (mismatch == REG_OK) { - pmatch[0].rm_so = j - fg->len; - pmatch[0].rm_eo = j; - return REG_OK; - } else if (mismatch > 0) - return mismatch; - mismatch = -mismatch - 1; - SHIFT; - } while (!IS_OUT_OF_BOUNDS); } else { /* Quick Search algorithm. */ j = 0; Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Wed Aug 10 08:55:46 2011 (r224756) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Wed Aug 10 13:24:32 2011 (r224757) @@ -53,7 +53,6 @@ typedef struct { /* flags */ bool bol; bool eol; - bool reversed; bool word; bool icase; } fastmatch_t;