Date: Wed, 31 Aug 2011 23:19:19 +0000 (UTC) From: Gabor Kovesdan <gabor@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r225300 - user/gabor/tre-integration/contrib/tre/lib Message-ID: <201108312319.p7VNJJDk021474@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108312319.p7VNJJDk021474>