svn commit: r232191 - user/gabor/tre-integration/contrib/tre/lib
Gabor Kovesdan
gabor at FreeBSD.org
Sun Feb 26 19:05:17 UTC 2012
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;
More information about the svn-src-user
mailing list