Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Aug 2011 23:19:20 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r225093 - in user/gabor/tre-integration: contrib/tre/lib include
Message-ID:  <201108222319.p7MNJKZ4072487@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Mon Aug 22 23:19:20 2011
New Revision: 225093
URL: http://svn.freebsd.org/changeset/base/225093

Log:
  - Add an internal flag for heuristics: it understands ^$. but handles
    everything else as literal. This allows using the fast algorithm while
    treating {}, \, *, etc. as literal.

Modified:
  user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c
  user/gabor/tre-integration/include/regex.h

Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c	Mon Aug 22 23:15:15 2011	(r225092)
+++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c	Mon Aug 22 23:19:20 2011	(r225093)
@@ -428,10 +428,11 @@ tre_compile_fast(fastmatch_t *fg, const 
   for (unsigned int i = 0; i < n; i++)
     {
       /* Can still cheat? */
-      if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) ||
+      if (!(cflags & _REG_HEUR) &&
+	  ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) ||
 	  (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) ||
 	  (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) ||
-	  (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/')))
+	  (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))))
 	continue;
       else if (pat[i] == TRE_CHAR('.'))
 	fg->hasdot = i;

Modified: user/gabor/tre-integration/include/regex.h
==============================================================================
--- user/gabor/tre-integration/include/regex.h	Mon Aug 22 23:15:15 2011	(r225092)
+++ user/gabor/tre-integration/include/regex.h	Mon Aug 22 23:19:20 2011	(r225093)
@@ -110,6 +110,7 @@ typedef enum {
 #define REG_PEND	(REG_UNGREEDY << 1)
 #define REG_GNU         (REG_PEND << 1)
 #define REG_WORD	(REG_GNU << 1)
+#define _REG_HEUR	(REG_WORD << 1)
 
 /* POSIX tre_regexec() flags. */
 #define REG_NOTBOL 1



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