From owner-svn-src-user@FreeBSD.ORG Thu Oct 20 09:57:28 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 42029106568A; Thu, 20 Oct 2011 09:57:28 +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 318958FC12; Thu, 20 Oct 2011 09:57:28 +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 p9K9vSsS067337; Thu, 20 Oct 2011 09:57:28 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9K9vScU067335; Thu, 20 Oct 2011 09:57:28 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201110200957.p9K9vScU067335@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 20 Oct 2011 09:57:28 +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: r226563 - 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, 20 Oct 2011 09:57:28 -0000 Author: gabor Date: Thu Oct 20 09:57:27 2011 New Revision: 226563 URL: http://svn.freebsd.org/changeset/base/226563 Log: - Minor fixes 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 Thu Oct 20 09:55:21 2011 (r226562) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Thu Oct 20 09:57:27 2011 (r226563) @@ -140,6 +140,7 @@ tre_compile_heur(heur_t *h, const tre_ch * Process the pattern char-by-char. * * i: position in regex + * j: number of fragment * st: start offset of current segment (fixed-length fragment) * to be processed * pos: current position (and length) in the temporary space where @@ -331,8 +332,8 @@ end_segment: errcode = REG_ESPACE; goto err; } - memcpy(&arr[j], &heur, pos); - arr[j][pos] = TRE_CHAR('\0'); + heur[pos] = TRE_CHAR('\0'); + memcpy(arr[j], heur, (pos + 1) * sizeof(tre_char_t)); length[j] = pos; j++; pos = 0; @@ -344,7 +345,7 @@ ok: size_t m = 1; int ret; - for(int i = 1; i < j; i++) + for (int i = 1; i < j; i++) m = (length[i] > length[m]) ? i : m; if (!h->heurs) @@ -363,11 +364,11 @@ ok: } } -#define CHECK_ERR - if (ret != REG_OK) - { - errcode = REG_BADPAT; - goto err2; +#define CHECK_ERR \ + if (ret != REG_OK) \ + { \ + errcode = REG_BADPAT; \ + goto err2; \ } ret = tre_compile_fast(h->heurs[0], arr[0], length[0], 0); @@ -381,7 +382,7 @@ ok: else ret = tre_compile_fast(h->heurs[1], arr[m], length[m], 0); CHECK_ERR - if (h->prefix) + if (h->prefix || (m == j - 1)) { xfree(h->heurs[2]); h->heurs[2] = NULL;