Date: Sun, 26 Feb 2012 19:05:17 +0000 (UTC) From: Gabor Kovesdan <gabor@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r232191 - user/gabor/tre-integration/contrib/tre/lib Message-ID: <201202261905.q1QJ5Hdg078855@svn.freebsd.org>
index | next in thread | raw e-mail
Author: gabor Date: Sun Feb 26 19:05:17 2012 New Revision: 232191 URL: http://svn.freebsd.org/changeset/base/232191 Log: - Add handling single pattern Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c user/gabor/tre-integration/contrib/tre/lib/mregexec.c user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Sun Feb 26 19:00:59 2012 (r232190) +++ user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Sun Feb 26 19:05:17 2012 (r232191) @@ -79,6 +79,12 @@ tre_mcompile(mregex_t *preg, size_t nr, } } + if (nr == 1) + { + preg->type = MHEUR_SINGLE; + goto finish; + } + /* If not literal, check if any of them have fixed-length prefix. */ if (!(cflags & REG_LITERAL)) for (int i = 0; i < nr; i++) Modified: user/gabor/tre-integration/contrib/tre/lib/mregexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sun Feb 26 19:00:59 2012 (r232190) +++ user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sun Feb 26 19:05:17 2012 (r232191) @@ -235,6 +235,15 @@ finish2: } /* + * Single pattern. Call single matcher. + */ + else if (preg->type == MHEUR_SINGLE) + { + return tre_match(&preg->patterns[0], str, len, type, nmatch, pmatch, + eflags); + } + + /* * General case. Look for the beginning of any of the patterns with the * Wu-Manber algorithm and try to match from there with the automaton. */ Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sun Feb 26 19:00:59 2012 (r232190) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sun Feb 26 19:05:17 2012 (r232191) @@ -15,6 +15,7 @@ #define MHEUR_PREFIX 1 #define MHEUR_LONGEST 2 #define MHEUR_LITERAL 3 +#define MHEUR_SINGLE 4 typedef struct { int cflags;help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202261905.q1QJ5Hdg078855>
