Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Sep 2011 15:54:37 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r225592 - user/gabor/tre-integration/contrib/tre/lib
Message-ID:  <201109151554.p8FFsb5V080102@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Thu Sep 15 15:54:37 2011
New Revision: 225592
URL: http://svn.freebsd.org/changeset/base/225592

Log:
  - Refactor code to only call fast matcher and heuristic code if input is not
    STR_USER. This makes reguexec() work again like before.

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

Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/regexec.c	Thu Sep 15 15:28:41 2011	(r225591)
+++ user/gabor/tre-integration/contrib/tre/lib/regexec.c	Thu Sep 15 15:54:37 2011	(r225592)
@@ -158,7 +158,7 @@ tre_match(const tre_tnfa_t *tnfa, const 
   int *tags = NULL, eo;
 
   /* Check if we can cheat with a faster algorithm. */
-  if (shortcut != NULL)
+  if ((shortcut != NULL) && (type != STR_USER))
     {
       DPRINT("tre_match: using tre_match_fast() instead of the full NFA\n");
       return tre_match_fast(shortcut, string, len, type, nmatch,
@@ -184,7 +184,7 @@ tre_match(const tre_tnfa_t *tnfa, const 
     (void *)&data_byte[off];
 
   /* Check if we have a heuristic to speed up the search. */
-  if (heur != NULL)
+  if ((heur != NULL) && (type != STR_USER))
     {
       int ret;
       size_t st = 0, n;

Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c	Thu Sep 15 15:28:41 2011	(r225591)
+++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c	Thu Sep 15 15:54:37 2011	(r225592)
@@ -1890,7 +1890,6 @@ tre_compile(regex_t *preg, const tre_cha
 	  preg->shortcut = shortcut;
 	  preg->re_nsub = 0;
 	  DPRINT("tre_compile: pattern compiled for fast matcher\n");
-	  return REG_OK;
 	}
       else
 	{
@@ -1904,14 +1903,11 @@ tre_compile(regex_t *preg, const tre_cha
      purposes. */
   stack = tre_stack_new(512, 10240, 128);
   if (!stack)
-    return REG_ESPACE;
+    ERROR_EXIT(REG_ESPACE);
   /* Allocate a fast memory allocator. */
   mem = tre_mem_new();
   if (!mem)
-    {
-      tre_stack_destroy(stack);
-      return REG_ESPACE;
-    }
+    ERROR_EXIT(REG_ESPACE);
 
   /* Parse the regexp. */
   memset(&parse_ctx, 0, sizeof(parse_ctx));
@@ -2196,10 +2192,7 @@ tre_compile(regex_t *preg, const tre_cha
    */
   heur = xmalloc(sizeof(heur_t));
   if (!heur)
-    {
-      errcode = REG_ESPACE;
-      goto error_exit;
-    }
+    ERROR_EXIT(REG_ESPACE);
 
   ret = tre_compile_heur(heur, regex, n, cflags);
   if (ret != REG_OK)
@@ -2219,7 +2212,12 @@ tre_compile(regex_t *preg, const tre_cha
 
  error_exit:
   /* Free everything that was allocated and return the error code. */
-  tre_mem_destroy(mem);
+  if (shortcut != NULL)
+    xfree(shortcut);
+  if (heur != NULL)
+    xfree(heur);
+  if (mem != NULL)
+    tre_mem_destroy(mem);
   if (stack != NULL)
     tre_stack_destroy(stack);
   if (counts != NULL)



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