Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2011 15:31:32 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r224971 - user/gabor/tre-integration/contrib/tre/lib
Message-ID:  <201108181531.p7IFVWud062952@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Thu Aug 18 15:31:31 2011
New Revision: 224971
URL: http://svn.freebsd.org/changeset/base/224971

Log:
  - Support REG_PEND in the fast matching functions
  - Fall back to strlen() when the end pointer is invalid

Modified:
  user/gabor/tre-integration/contrib/tre/lib/fastmatch.c
  user/gabor/tre-integration/contrib/tre/lib/regcomp.c

Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c	Thu Aug 18 15:13:08 2011	(r224970)
+++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c	Thu Aug 18 15:31:31 2011	(r224971)
@@ -121,13 +121,29 @@ tre_fastncomp(fastmatch_t *preg, const c
 int
 tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags)
 {
-  return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
+  if (cflags & REG_PEND)
+    {
+      len = (preg->re_endp >= regex)
+        ? preg->re_endp - regex
+        : 0;
+     return tre_fixncomp(preg, regex, len ? strlen(regex) : 0, cflags);
+   }
+  else
+    return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
 }
 
 int
 tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags)
 {
-  return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
+  if (cflags & REG_PEND)
+    {
+      len = (preg->re_endp >= regex)
+        ? preg->re_endp - regex
+        : 0;
+     return tre_fastncomp(preg, regex, len ? strlen(regex) : 0, cflags);
+   }
+  else
+    return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
 }
 
 int

Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/regcomp.c	Thu Aug 18 15:13:08 2011	(r224970)
+++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c	Thu Aug 18 15:31:31 2011	(r224971)
@@ -118,7 +118,7 @@ tre_regcomp(regex_t *preg, const char *r
       len = (preg->re_endp >= regex)
 	? preg->re_endp - regex
 	: 0;
-     return tre_regncomp(preg, regex, len, cflags);
+     return tre_regncomp(preg, regex, len ? strlen(regex) : 0, cflags);
    }
   else
     return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108181531.p7IFVWud062952>