svn commit: r225930 - user/gabor/tre-integration/contrib/tre/lib

Gabor Kovesdan gabor at FreeBSD.org
Sun Oct 2 20:52:28 UTC 2011


Author: gabor
Date: Sun Oct  2 20:52:28 2011
New Revision: 225930
URL: http://svn.freebsd.org/changeset/base/225930

Log:
  - Collating elements and equivalence classes are not necessarily fixed-length,
    so fall back to the full NFA on embedded brackets

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

Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c	Sun Oct  2 19:24:13 2011	(r225929)
+++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c	Sun Oct  2 20:52:28 2011	(r225930)
@@ -39,13 +39,6 @@
 #include "tre-internal.h"
 #include "xmalloc.h"
 
-#ifdef TRE_WCHAR
-#define tre_strnstr(big, s1, little, s2)				\
-  memmem(big, s1 * sizeof(tre_char_t), little, s2 * sizeof(tre_char_t))
-#else
-#define tre_strnstr(big, s1, little, s2) strnstr(big, little, s1)
-#endif
-
 /*
  * A full regex implementation requires a finite state automaton
  * and using an automaton is always about a trade-off. A DFA is
@@ -84,38 +77,21 @@
 
 #define PARSE_BRACKETS							\
   {									\
-    tre_char_t *tmp;							\
-									\
     i++;								\
     if (regex[i] == TRE_CHAR('^'))					\
       i++;								\
     if (regex[i] == TRE_CHAR(']'))					\
       i++;								\
 									\
-    do									\
-      {									\
-	tmp = tre_strnstr(&regex[i], len - i, TRE_CHAR("[.].]"), 5);	\
-	if (tmp)							\
-	  {								\
-	    i += (tmp - regex);						\
-	    regex = tmp;						\
-	  }								\
-      } while (tmp != NULL);						\
-									\
-    do									\
+    for (; i < len; i++)						\
       {									\
-	tmp = tre_strnstr(&regex[i], len - i, TRE_CHAR("[=]=]"), 5);	\
-	if (tmp)							\
-	  {								\
-	    i += (tmp - regex);						\
-	    regex = tmp;						\
-	  }								\
-      } while (tmp != NULL);						\
-									\
-    for (; (i != TRE_CHAR(']')) && (i < len); i++);			\
+	if (regex[i] == TRE_CHAR('['))					\
+	  return REG_BADPAT;						\
+	if (regex[i] == TRE_CHAR(']'))					\
+	  break;							\
+      }									\
   }
 
-
 /*
  * Finishes a segment (fixed-length text fragment).
  */


More information about the svn-src-user mailing list