From owner-svn-src-user@FreeBSD.ORG Thu Sep 15 15:54:37 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7C88106566B; Thu, 15 Sep 2011 15:54:37 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7DFCE8FC16; Thu, 15 Sep 2011 15:54:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8FFsb03080105; Thu, 15 Sep 2011 15:54:37 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8FFsb5V080102; Thu, 15 Sep 2011 15:54:37 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109151554.p8FFsb5V080102@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 15 Sep 2011 15:54:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225592 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2011 15:54:37 -0000 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)