svn commit: r225300 - user/gabor/tre-integration/contrib/tre/lib
Gabor Kovesdan
gabor at FreeBSD.org
Wed Aug 31 23:19:20 UTC 2011
Author: gabor
Date: Wed Aug 31 23:19:19 2011
New Revision: 225300
URL: http://svn.freebsd.org/changeset/base/225300
Log:
- Add support for 0-length pattern (matches everyting)
Modified:
user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c
Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 31 23:14:37 2011 (r225299)
+++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 31 23:19:19 2011 (r225300)
@@ -385,12 +385,15 @@ static int fastcmp(const void *, const v
fg->word = (cflags & REG_WORD); \
fg->newline = (cflags & REG_NEWLINE); \
\
+ if (n == 0) \
+ { \
+ fg->matchall = true; \
+ return REG_OK; \
+ }
+ \
/* Cannot handle REG_ICASE with MB string */ \
if (fg->icase && (TRE_MB_CUR_MAX > 1)) \
return REG_BADPAT; \
- \
- /* Calculate length if unspecified */ \
- n = (n == 0) ? tre_strlen(pat) : n;
/*
* Returns: REG_OK on success, error code otherwise
@@ -597,6 +600,13 @@ tre_match_fast(const fastmatch_t *fg, co
break;
}
+ if (fg->matchall)
+ {
+ pmatch[0].rm_so = 0;
+ pmatch[0].rm_eo = len;
+ return REG_OK;
+ }
+
/* No point in going farther if we do not have enough data. */
switch (type)
{
More information about the svn-src-user
mailing list