svn commit: r225592 - user/gabor/tre-integration/contrib/tre/lib
Gabor Kovesdan
gabor at FreeBSD.org
Thu Sep 15 15:54:37 UTC 2011
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)
More information about the svn-src-user
mailing list