svn commit: r224871 - user/gabor/tre-integration/contrib/tre/lib
Gabor Kovesdan
gabor at FreeBSD.org
Sun Aug 14 22:53:03 UTC 2011
Author: gabor
Date: Sun Aug 14 22:53:02 2011
New Revision: 224871
URL: http://svn.freebsd.org/changeset/base/224871
Log:
- Implement TRE-specific REG_NOTBOL and REG_NOTEOL
- Adjust an older comment
Modified:
user/gabor/tre-integration/contrib/tre/lib/fastmatch.c
user/gabor/tre-integration/contrib/tre/lib/fastmatch.h
user/gabor/tre-integration/contrib/tre/lib/regexec.c
Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 20:55:32 2011 (r224870)
+++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 22:53:02 2011 (r224871)
@@ -503,9 +503,9 @@ tre_fastcomp(fastmatch_t *fg, const tre_
*/
int
tre_fastexec(const fastmatch_t *fg, const void *data, size_t len,
- tre_str_type_t type, int nmatch, regmatch_t pmatch[])
+ tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags)
{
- unsigned int j;
+ unsigned int j = 0;
int ret = REG_NOMATCH;
int mismatch, shift, u = 0, v;
const char *str_byte = data;
@@ -537,8 +537,23 @@ tre_fastexec(const fastmatch_t *fg, cons
shift = fg->len;
}
+ /*
+ * REG_NOTBOL means not anchoring ^ to the beginning of the line, so we
+ * can shift one because there can't be a match at the beginning.
+ */
+ if (fg->bol && (eflags & REG_NOTBOL))
+ j = 1;
+
+ /*
+ * Like above, we cannot have a match at the very end when anchoring to
+ * the end and REG_NOTEOL is specified.
+ */
+ if (fg->eol && (eflags & REG_NOTEOL))
+ len--;
+
/* Only try once at the beginning or ending of the line. */
- if (!fg->newline && (fg->bol || fg->eol))
+ if ((fg->bol || fg->eol) && !fg->newline && !(eflags & REG_NOTBOL) &&
+ !(eflags & REG_NOTEOL))
{
/* Simple text comparison. */
if (!((fg->bol && fg->eol) &&
@@ -561,7 +576,6 @@ tre_fastexec(const fastmatch_t *fg, cons
else
{
/* Quick Search / Turbo Boyer-Moore algorithm. */
- j = 0;
do
{
SKIP_CHARS(j);
Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 20:55:32 2011 (r224870)
+++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 22:53:02 2011 (r224871)
@@ -62,7 +62,7 @@ int tre_fastcomp_literal(fastmatch_t *pr
size_t, int);
int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t, int);
int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len,
- tre_str_type_t type, int nmatch, regmatch_t pmatch[]);
+ tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags);
void tre_fastfree(fastmatch_t *preg);
#endif /* FASTMATCH_H */
Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 14 20:55:32 2011 (r224870)
+++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 14 22:53:02 2011 (r224871)
@@ -156,9 +156,9 @@ tre_match(const tre_tnfa_t *tnfa, const
reg_errcode_t status;
int *tags = NULL, eo;
- /* Check if we can cheat with a fixed string */
+ /* Check if we can cheat with a faster algorithm */
if (shortcut != NULL)
- return tre_fastexec(shortcut, string, len, type, nmatch, pmatch);
+ return tre_fastexec(shortcut, string, len, type, nmatch, pmatch, eflags);
if (tnfa->num_tags > 0 && nmatch > 0)
{
More information about the svn-src-user
mailing list