From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 11:16:13 2012 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 BAA02106566C; Tue, 14 Feb 2012 11:16:13 +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 A4A1E8FC0C; Tue, 14 Feb 2012 11:16:13 +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 q1EBGDrX095555; Tue, 14 Feb 2012 11:16:13 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1EBGDZ0095552; Tue, 14 Feb 2012 11:16:13 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202141116.q1EBGDZ0095552@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 14 Feb 2012 11:16:13 +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: r231668 - 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: Tue, 14 Feb 2012 11:16:13 -0000 Author: gabor Date: Tue Feb 14 11:16:13 2012 New Revision: 231668 URL: http://svn.freebsd.org/changeset/base/231668 Log: - Fix a bug that always resulted in a HEUR_PREFIX_ARRAY heuristic - Store the fragments for later processing (will be used for the Wu-Manber algorithm to match more patterns at a time) - Refactor the code for better readability Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Tue Feb 14 10:51:24 2012 (r231667) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Tue Feb 14 11:16:13 2012 (r231668) @@ -126,7 +126,10 @@ int tre_compile_heur(heur_t *h, const tre_char_t *regex, size_t len, int cflags) { - tre_char_t *arr[MAX_FRAGMENTS], *heur; + tre_char_t **arr, *heur; + tre_char_t **farr; + char **barr; + size_t *bsiz, *fsiz; size_t length[MAX_FRAGMENTS]; ssize_t tlen = 0; int errcode, j = 0, pos = 0, st = 0; @@ -136,6 +139,13 @@ tre_compile_heur(heur_t *h, const tre_ch if (!heur) return REG_ESPACE; + arr = xmalloc(MAX_FRAGMENTS * sizeof(tre_char_t *)); + if (!arr) + { + errcode = REG_ESPACE; + goto err; + } + h->type = HEUR_ARRAY; while (true) @@ -316,7 +326,7 @@ tre_compile_heur(heur_t *h, const tre_ch st = len; end_segment: - + /* Check if pattern is open-ended */ if (st == len && pos == 0) { if (j == 0) @@ -327,6 +337,7 @@ end_segment: h->type = HEUR_PREFIX_ARRAY; goto ok; } + /* Continue if we got some variable-length part */ else if (pos == 0) continue; @@ -349,95 +360,202 @@ end_segment: length[j] = pos; j++; pos = 0; + + /* Check whether there is more input */ + if (st == len) + goto ok; } ok: { - size_t m = 1; - int ret; + size_t m = 0; + int i, ret; h->tlen = tlen; /* Look up maximum length fragment */ - for (int i = 1; i < j; i++) + for (i = 1; i < j; i++) m = (length[i] > length[m]) ? i : m; + /* Will hold the final fragments that we actually use */ + farr = xmalloc(4 * sizeof(tre_char_t *)); + if (!farr) + { + errcode = REG_ESPACE; + goto err; + } + + /* Sizes for the final fragments */ + fsiz = xmalloc(4 * sizeof(size_t)); + if (!fsiz) + { + errcode = REG_ESPACE; + goto err; + } + /* - * If possible, store prefix, maximum internal fragment and suffix. - * If not possible, store prefix and either maximum internal fragment - * or suffix if it is the same. In the worst case, only prefix is - * stored. The closing element is always NULL. + * Only save the longest fragment if match is line-based. */ - for (int i = 0; i < MIN(3, j + 1); i++) + if (cflags & REG_NEWLINE) { - h->heurs[i] = xmalloc(sizeof(fastmatch_t)); - if (!h->heurs[i]) + farr[0] = arr[m]; + arr[m] = NULL; + fsiz[0] = length[0]; + farr[1] = NULL; + } + /* + * Otherwise try to save up to three fragments: beginning, longest + * intermediate pattern, ending. If either the beginning or the + * ending fragment is longer than any intermediate fragments, we will + * not save any intermediate one. The point here is to always maximize + * the possible shifting when searching in the input. Measurements + * have shown that the eager approach works best. + */ + else + { + size_t idx = 0; + + /* Always start by saving the beginning */ + farr[idx] = arr[0]; + arr[0] = NULL; + fsiz[idx++] = length[0]; + + /* + * If the longest pattern is not the beginning nor the ending, + * save it. + */ + if ((m != 1) && (m != j - 1)) + { + farr[idx] = arr[m]; + fsiz[idx++] = length[m]; + arr[m] = NULL; + } + + /* + * If we have an ending pattern (even if the pattern is + * "open-ended"), save it. + */ + if (j > 1) + { + farr[idx] = arr[j - 1]; + fsiz[idx++] = length[j - 1]; + arr[j - 1] = NULL; + } + + farr[idx] = NULL; + } + + /* Once necessary pattern saved, free original array */ + for (i = 0; i < j; i++) + if (arr[i]) + xfree(arr[i]); + xfree(arr); + +/* + * Store the array in single-byte and wide char forms in the + * heur_t struct for later reuse. When supporting whcar_t + * convert the fragments to single-byte string because + * conversion is probably faster than processing the patterns + * again in single-byte form. + */ +#ifdef TRE_WCHAR + barr = xmalloc(4 * sizeof(char *)); + if (!barr) + { + errcode = REG_ESPACE; + goto err; + } + + bsiz = xmalloc(4 * sizeof(size_t)); + if (!bsiz) + { + errcode = REG_ESPACE; + goto err; + } + + for (i = 0; farr[i] != NULL; i++) + { + bsiz[i] = mbstowcs(farr[i], NULL, 0); + barr[i] = xmalloc(bsiz[i] + 1); + if (!barr[i]) { errcode = REG_ESPACE; goto err; } + mbstowcs(farr[i], barr[i], bsiz[i]); + barr[i][bsiz[i]] = '\0'; } + barr[i] = NULL; -#define CHECK_ERR \ - if (ret != REG_OK) \ - { \ - errcode = REG_BADPAT; \ - goto err2; \ - } + h->warr = farr; + h->wsiz = fsiz; + h->arr = barr; + h->siz = bsiz; +#else + h->arr = farr; + h->siz = fsiz; +#endif - if (cflags & REG_NEWLINE) + /* + * Compile all the useful fragments for actual matching. + */ + h->heurs = xmalloc(4 * sizeof(fastmatch_t *)); + if (!h->heurs) { - /* For REG_NEWLINE, only store longest fragment. */ - ret = tre_compile_literal(h->heurs[0], arr[m], length[m], 0); - CHECK_ERR - h->type = HEUR_LONGEST; + errcode = REG_ESPACE; + goto err; } - else + for (i = 0; farr[i] != NULL; i++) { - /* - * If possible, store prefix, maximum internal fragment and suffix. - * If not possible, store prefix and either maximum internal fragment - * or suffix if it is the same. In the worst case, only prefix is - * stored. The closing element is always NULL. - */ - ret = tre_compile_literal(h->heurs[0], arr[0], length[0], 0); - CHECK_ERR - if (j == 1) + h->heurs[i] = xmalloc(sizeof(fastmatch_t)); + if (!h->heurs[i]) { - free(h->heurs[1]); - h->heurs[1] = NULL; - errcode = REG_OK; - goto finish; + errcode = REG_ESPACE; + goto err; } - else - ret = tre_compile_literal(h->heurs[1], arr[m], length[m], 0); - CHECK_ERR - if ((h->type == HEUR_PREFIX_ARRAY) || (m == j - 1)) + ret = tre_compile_literal(h->heurs[i], farr[i], fsiz[i], 0); + if (ret != REG_OK) { - xfree(h->heurs[2]); - h->heurs[2] = NULL; - errcode = REG_OK; - goto finish; + errcode = REG_BADPAT; + goto err; } - else - ret = tre_compile_literal(h->heurs[2], arr[j - 1], length[j - 1], 0); - CHECK_ERR - h->heurs[3] = NULL; } - errcode = REG_OK; - goto finish; + h->heurs[i] = NULL; + errcode = REG_OK; + goto finish; } -err2: - for (int i = 0; h->heurs[i] != NULL; i++) - tre_free_fast(h->heurs[i]); - xfree(h->heurs); err: +#ifdef TRE_WCHAR + if (barr) + { + for (int i = 0; i < 4; i++) + if (barr[i]) + xfree(barr[i]); + xfree(barr); + } + if (bsiz) + xfree(bsiz); +#endif + if (farr) + { + for (int i = 0; i < j; i++) + if (farr[i]) + xfree(farr[i]); + xfree(farr); + } + if (fsiz) + xfree(fsiz); + if (h->heurs) + { + for (int i = 0; h->heurs[i] != NULL; i++) + tre_free_fast(h->heurs[i]); + xfree(h->heurs); + } finish: - for (int i = 0; i < j; i++) - xfree(arr[i]); - xfree(heur); + if (heur) + xfree(heur); return errcode; } @@ -450,5 +568,24 @@ tre_free_heur(heur_t *h) for (int i = 0; h->heurs[i] != NULL; i++) tre_free_fast(h->heurs[i]); + if (h->arr) + { + for (int i = 0; h->arr[i] != NULL; i++) + if (h->arr[i]) + xfree(h->arr[i]); + xfree(h->arr); + } + +#ifdef TRE_WCHAR + if (h->warr) + { + for (int i = 0; h->warr[i] != NULL; i++) + if (h->warr[i]) + xfree(h->warr[i]); + xfree(h->warr); + } + +#endif + DPRINT("tre_free_heur: resources are freed\n"); } Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Tue Feb 14 10:51:24 2012 (r231667) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Tue Feb 14 11:16:13 2012 (r231668) @@ -12,7 +12,13 @@ #define HEUR_LONGEST 2 typedef struct { - fastmatch_t *heurs[4]; + char **arr; + size_t *siz; +#ifdef TRE_WCHAR + tre_char_t **warr; + size_t *wsiz; +#endif + fastmatch_t **heurs; ssize_t tlen; int type; } heur_t; From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 12:06:57 2012 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 5457C106566C; Tue, 14 Feb 2012 12:06:57 +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 28CDD8FC14; Tue, 14 Feb 2012 12:06:57 +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 q1EC6v3D097438; Tue, 14 Feb 2012 12:06:57 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1EC6uEW097436; Tue, 14 Feb 2012 12:06:56 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202141206.q1EC6uEW097436@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 14 Feb 2012 12:06:56 +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: r231674 - 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: Tue, 14 Feb 2012 12:06:57 -0000 Author: gabor Date: Tue Feb 14 12:06:56 2012 New Revision: 231674 URL: http://svn.freebsd.org/changeset/base/231674 Log: - Fix possible segfaults by reading before or after the bounds of the input string - Fix a bug in the relative end offset of the context that caused that some matches were missing Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 12:03:23 2012 (r231673) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 12:06:56 2012 (r231674) @@ -224,8 +224,8 @@ tre_match(const tre_tnfa_t *tnfa, const else { size_t rem = heur->tlen - (pmatch[0].rm_eo - pmatch[0].rm_so); - so = st + pmatch[0].rm_so - rem; - eo = st + pmatch[0].rm_eo + rem; + so = st + pmatch[0].rm_so <= rem ? 0 : st + pmatch[0].rm_so - rem; + eo = st + pmatch[0].rm_eo + rem >= len ? len : st + pmatch[0].rm_eo + rem; } SEEK_TO(so); @@ -247,7 +247,7 @@ tre_match(const tre_tnfa_t *tnfa, const if (ret != REG_OK) return ret; st += pmatch[0].rm_so; - n = pmatch[0].rm_eo; + n = pmatch[0].rm_eo - pmatch[0].rm_so; /* Intermediate heuristics */ while (!(heur->heurs[i] == NULL) && @@ -255,6 +255,8 @@ tre_match(const tre_tnfa_t *tnfa, const ((heur->heurs[i + 1] == NULL) && (heur->type == HEUR_PREFIX_ARRAY)))) { SEEK_TO(st + n); + if (len <= st + n) + return REG_NOMATCH; ret = tre_match_fast(heur->heurs[i], string, len - st - n, type, nmatch, pmatch, eflags); if (ret != REG_OK) @@ -267,6 +269,8 @@ tre_match(const tre_tnfa_t *tnfa, const if ((heur->type == HEUR_ARRAY) && heur->heurs[i] != NULL) { SEEK_TO(st + n); + if (len <= st + n) + return REG_NOMATCH; ret = tre_match_fast(heur->heurs[i], string, len - st - n, type, nmatch, pmatch, eflags); if (ret != REG_OK) From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 12:13:05 2012 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 5044A106564A; Tue, 14 Feb 2012 12:13:05 +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 249228FC14; Tue, 14 Feb 2012 12:13:05 +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 q1ECD504097685; Tue, 14 Feb 2012 12:13:05 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1ECD4Eh097683; Tue, 14 Feb 2012 12:13:04 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202141213.q1ECD4Eh097683@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 14 Feb 2012 12:13:04 +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: r231675 - 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: Tue, 14 Feb 2012 12:13:05 -0000 Author: gabor Date: Tue Feb 14 12:13:04 2012 New Revision: 231675 URL: http://svn.freebsd.org/changeset/base/231675 Log: - Add some more verbose comments about how this stuff works Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 12:06:56 2012 (r231674) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 12:13:04 2012 (r231675) @@ -191,6 +191,10 @@ tre_match(const tre_tnfa_t *tnfa, const const char *data_byte = string; const tre_char_t *data_wide = string; + /* + * REG_NEWLINE: looking for the longest fragment and then + * isolate the line and run the automaton. + */ if (heur->type == HEUR_LONGEST) { while (st < len) @@ -198,11 +202,17 @@ tre_match(const tre_tnfa_t *tnfa, const size_t eo, so; SEEK_TO(st); + + /* Match for heuristic */ ret = tre_match_fast(heur->heurs[0], string, len - st, type, nmatch, pmatch, eflags); if (ret != REG_OK) return ret; + /* + * If we do not know the length of the possibly matching part, + * look for newlines. + */ if (heur->tlen == -1) { for (so = st + pmatch[0].rm_so - 1; ; so--) @@ -221,6 +231,11 @@ tre_match(const tre_tnfa_t *tnfa, const break; } } + + /* + * If we know the possible match length, just check the narrowest + * context that we can, without looking for explicit newlines. + */ else { size_t rem = heur->tlen - (pmatch[0].rm_eo - pmatch[0].rm_so); @@ -235,6 +250,14 @@ tre_match(const tre_tnfa_t *tnfa, const } return REG_NOMATCH; } + + /* + * General case when REG_NEWLINE is not set. Look for prefix, + * intermediate and suffix heuristics is available, to determine + * the context where the automaton will be invoked. The start + * of the context is st and the relative end offset from st is + * stored in n. + */ else { while (st < len) @@ -249,7 +272,7 @@ tre_match(const tre_tnfa_t *tnfa, const st += pmatch[0].rm_so; n = pmatch[0].rm_eo - pmatch[0].rm_so; - /* Intermediate heuristics */ + /* Intermediate heuristics (if any) */ while (!(heur->heurs[i] == NULL) && ((heur->heurs[i + 1] != NULL) || ((heur->heurs[i + 1] == NULL) && (heur->type == HEUR_PREFIX_ARRAY)))) From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 14:55:28 2012 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 79AB51065670; Tue, 14 Feb 2012 14:55: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 679458FC16; Tue, 14 Feb 2012 14:55: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 q1EEtRF4003459; Tue, 14 Feb 2012 14:55:28 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1EEtR5K003457; Tue, 14 Feb 2012 14:55:27 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202141455.q1EEtR5K003457@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 14 Feb 2012 14:55:27 +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: r231683 - 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: Tue, 14 Feb 2012 14:55:28 -0000 Author: gabor Date: Tue Feb 14 14:55:27 2012 New Revision: 231683 URL: http://svn.freebsd.org/changeset/base/231683 Log: - Separate different matching logics for better later reuse and readability Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 14:24:37 2012 (r231682) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 14:55:27 2012 (r231683) @@ -62,6 +62,14 @@ __weak_reference(tre_regawexec, regawexe __weak_reference(tre_regawnexec, regawnexec); #endif +static int tre_match_heur(const tre_tnfa_t *tnfa, heur_t *heur, + const void *string, size_t len, + tre_str_type_t type, size_t nmatch, + regmatch_t pmatch[], int eflags); +static int tre_match_nfa(const tre_tnfa_t *tnfa, const void *string, + size_t len, tre_str_type_t type, size_t nmatch, + regmatch_t pmatch[], int eflags); + /* Fills the POSIX.2 regmatch_t array according to the TNFA tag and match endpoint values. */ void @@ -154,16 +162,27 @@ tre_match(const tre_tnfa_t *tnfa, const tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], int eflags, fastmatch_t *shortcut, heur_t *heur) { - reg_errcode_t status; - int *tags = NULL, eo; - /* Check if we can cheat with a faster algorithm. */ 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, - pmatch, eflags); - } + tre_match_fast(shortcut, string, len, type, nmatch, + pmatch, eflags); + else if ((heur != NULL) && (type != STR_USER)) + return tre_match_heur(tnfa, heur, string, len, type, nmatch, + pmatch, eflags); + + return tre_match_nfa(tnfa, string, len, type, nmatch, + pmatch, eflags); +} + +static int +tre_match_heur(const tre_tnfa_t *tnfa, heur_t *heur, const void *string, + size_t len, tre_str_type_t type, size_t nmatch, + regmatch_t pmatch[], int eflags) +{ + int ret; + size_t st = 0, i = 1, n; + const char *data_byte = string; + const tre_char_t *data_wide = string; #define FIX_OFFSETS(adj) \ if (ret == REG_NOMATCH) \ @@ -183,144 +202,145 @@ tre_match(const tre_tnfa_t *tnfa, const string = (type == STR_WIDE) ? (void *)&data_wide[off] : \ (void *)&data_byte[off]; - /* Check if we have a heuristic to speed up the search. */ - if ((heur != NULL) && (type != STR_USER)) + /* + * REG_NEWLINE: looking for the longest fragment and then + * isolate the line and run the automaton. + */ + if (heur->type == HEUR_LONGEST) { - int ret; - size_t st = 0, i = 1, n; - const char *data_byte = string; - const tre_char_t *data_wide = string; - - /* - * REG_NEWLINE: looking for the longest fragment and then - * isolate the line and run the automaton. - */ - if (heur->type == HEUR_LONGEST) + while (st < len) { - while (st < len) - { - size_t eo, so; + size_t eo, so; - SEEK_TO(st); + SEEK_TO(st); - /* Match for heuristic */ - ret = tre_match_fast(heur->heurs[0], string, len - st, type, nmatch, - pmatch, eflags); - if (ret != REG_OK) - return ret; - - /* - * If we do not know the length of the possibly matching part, - * look for newlines. - */ - if (heur->tlen == -1) - { - for (so = st + pmatch[0].rm_so - 1; ; so--) - { - if ((type == STR_WIDE) ? (data_wide[so] == TRE_CHAR('\n')) : - (data_byte[so] == '\n')) + /* Match for heuristic */ + ret = tre_match_fast(heur->heurs[0], string, len - st, type, nmatch, + pmatch, eflags); + if (ret != REG_OK) + return ret; + + /* + * If we do not know the length of the possibly matching part, + * look for newlines. + */ + if (heur->tlen == -1) + { + for (so = st + pmatch[0].rm_so - 1; ; so--) + { + if ((type == STR_WIDE) ? (data_wide[so] == TRE_CHAR('\n')) : + (data_byte[so] == '\n')) break; if (so == 0) break; - } + } - for (eo = st + pmatch[0].rm_eo; st + eo < len; eo++) - { - if ((type == STR_WIDE) ? (data_wide[eo] == TRE_CHAR('\n')) : - (data_byte[eo] == '\n')) + for (eo = st + pmatch[0].rm_eo; st + eo < len; eo++) + { + if ((type == STR_WIDE) ? (data_wide[eo] == TRE_CHAR('\n')) : + (data_byte[eo] == '\n')) break; - } - } + } + } - /* - * If we know the possible match length, just check the narrowest - * context that we can, without looking for explicit newlines. - */ - else - { - size_t rem = heur->tlen - (pmatch[0].rm_eo - pmatch[0].rm_so); - so = st + pmatch[0].rm_so <= rem ? 0 : st + pmatch[0].rm_so - rem; - eo = st + pmatch[0].rm_eo + rem >= len ? len : st + pmatch[0].rm_eo + rem; - } - - SEEK_TO(so); - ret = tre_match(tnfa, string, eo - so, type, nmatch, pmatch, eflags, NULL, NULL); - FIX_OFFSETS(st = eo); + /* + * If we know the possible match length, just check the narrowest + * context that we can, without looking for explicit newlines. + */ + else + { + size_t rem = heur->tlen - (pmatch[0].rm_eo - pmatch[0].rm_so); + + so = st + pmatch[0].rm_so <= rem ? 0 : st + pmatch[0].rm_so - rem; + eo = st + pmatch[0].rm_eo + rem >= len ? len : st + pmatch[0].rm_eo + rem; + } - } - return REG_NOMATCH; + SEEK_TO(so); + ret = tre_match_nfa(tnfa, string, eo - so, type, nmatch, pmatch, eflags); + FIX_OFFSETS(st = eo); } + return REG_NOMATCH; + } - /* - * General case when REG_NEWLINE is not set. Look for prefix, - * intermediate and suffix heuristics is available, to determine - * the context where the automaton will be invoked. The start - * of the context is st and the relative end offset from st is - * stored in n. - */ - else + /* + * General case when REG_NEWLINE is not set. Look for prefix, + * intermediate and suffix heuristics is available, to determine + * the context where the automaton will be invoked. The start + * of the context is st and the relative end offset from st is + * stored in n. + */ + else + { + while (st < len) { - while (st < len) - { - SEEK_TO(st); + SEEK_TO(st); - /* Prefix heuristic */ - ret = tre_match_fast(heur->heurs[0], string, len - st, - type, nmatch, pmatch, eflags); - if (ret != REG_OK) - return ret; - st += pmatch[0].rm_so; - n = pmatch[0].rm_eo - pmatch[0].rm_so; - - /* Intermediate heuristics (if any) */ - while (!(heur->heurs[i] == NULL) && - ((heur->heurs[i + 1] != NULL) || - ((heur->heurs[i + 1] == NULL) && (heur->type == HEUR_PREFIX_ARRAY)))) - { - SEEK_TO(st + n); - if (len <= st + n) - return REG_NOMATCH; - ret = tre_match_fast(heur->heurs[i], string, len - st - n, - type, nmatch, pmatch, eflags); - if (ret != REG_OK) - return ret; - n += pmatch[0].rm_eo; - i++; - } - - /* Suffix heuristic available */ - if ((heur->type == HEUR_ARRAY) && heur->heurs[i] != NULL) - { - SEEK_TO(st + n); - if (len <= st + n) - return REG_NOMATCH; - ret = tre_match_fast(heur->heurs[i], string, len - st - n, - type, nmatch, pmatch, eflags); - if (ret != REG_OK) - return ret; - n += pmatch[0].rm_eo; - - SEEK_TO(st); - ret = tre_match(tnfa, string, n, type, nmatch, pmatch, - eflags, NULL, NULL); - FIX_OFFSETS(st += n); - } - /* Suffix heuristic not available */ - else - { - size_t l = (heur->tlen == -1) ? len - st : heur->tlen; + /* Prefix heuristic */ + ret = tre_match_fast(heur->heurs[0], string, len - st, + type, nmatch, pmatch, eflags); + if (ret != REG_OK) + return ret; + st += pmatch[0].rm_so; + n = pmatch[0].rm_eo - pmatch[0].rm_so; + + /* Intermediate heuristics (if any) */ + while (!(heur->heurs[i] == NULL) && + ((heur->heurs[i + 1] != NULL) || + ((heur->heurs[i + 1] == NULL) && (heur->type == HEUR_PREFIX_ARRAY)))) + { + SEEK_TO(st + n); + if (len <= st + n) + return REG_NOMATCH; + ret = tre_match_fast(heur->heurs[i], string, len - st - n, + type, nmatch, pmatch, eflags); + if (ret != REG_OK) + return ret; + n += pmatch[0].rm_eo; + i++; + } + + /* Suffix heuristic available */ + if ((heur->type == HEUR_ARRAY) && heur->heurs[i] != NULL) + { + SEEK_TO(st + n); + if (len <= st + n) + return REG_NOMATCH; + ret = tre_match_fast(heur->heurs[i], string, len - st - n, + type, nmatch, pmatch, eflags); + if (ret != REG_OK) + return ret; + n += pmatch[0].rm_eo; + + SEEK_TO(st); + ret = tre_match_nfa(tnfa, string, n, type, nmatch, pmatch, + eflags); + FIX_OFFSETS(st += n); + } - if (l > len - st) - return REG_NOMATCH; - SEEK_TO(st); - ret = tre_match(tnfa, string, l, type, nmatch, - pmatch, eflags, NULL, NULL); - FIX_OFFSETS(st += n); - } + /* Suffix heuristic not available */ + else + { + size_t l = (heur->tlen == -1) ? len - st : heur->tlen; + + if (l > len - st) + return REG_NOMATCH; + SEEK_TO(st); + ret = tre_match_nfa(tnfa, string, l, type, nmatch, + pmatch, eflags); + FIX_OFFSETS(st += n); } - return REG_NOMATCH; - } + } + return REG_NOMATCH; } +} + +static int +tre_match_nfa(const tre_tnfa_t *tnfa, const void *string, size_t len, + tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], + int eflags) +{ + reg_errcode_t status; + int eo, *tags = NULL; if (tnfa->num_tags > 0 && nmatch > 0) { From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 19:58:03 2012 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 F25C81065740; Tue, 14 Feb 2012 19:58:02 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD4508FC13; Tue, 14 Feb 2012 19:58:02 +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 q1EJw2jH015695; Tue, 14 Feb 2012 19:58:02 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1EJw1Yo015651; Tue, 14 Feb 2012 19:58:01 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201202141958.q1EJw1Yo015651@svn.freebsd.org> From: Attilio Rao Date: Tue, 14 Feb 2012 19:58:01 +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: r231707 - in user/attilio/vmcontention: . bin/sh crypto/openssh etc etc/defaults etc/devd etc/mtree etc/rc.d gnu/usr.bin/cc/cc_tools include include/rpc include/xlocale lib/libc/arm/gen... 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: Tue, 14 Feb 2012 19:58:03 -0000 Author: attilio Date: Tue Feb 14 19:58:00 2012 New Revision: 231707 URL: http://svn.freebsd.org/changeset/base/231707 Log: MFC Added: user/attilio/vmcontention/etc/rc.d/utx - copied unchanged from r231706, head/etc/rc.d/utx user/attilio/vmcontention/include/xlocale/ - copied from r231706, head/include/xlocale/ user/attilio/vmcontention/lib/libc/arm/gen/__aeabi_read_tp.c - copied unchanged from r231706, head/lib/libc/arm/gen/__aeabi_read_tp.c user/attilio/vmcontention/sys/conf/WITHOUT_SOURCELESS - copied unchanged from r231706, head/sys/conf/WITHOUT_SOURCELESS user/attilio/vmcontention/sys/conf/WITHOUT_SOURCELESS_HOST - copied unchanged from r231706, head/sys/conf/WITHOUT_SOURCELESS_HOST user/attilio/vmcontention/sys/conf/WITHOUT_SOURCELESS_UCODE - copied unchanged from r231706, head/sys/conf/WITHOUT_SOURCELESS_UCODE user/attilio/vmcontention/sys/dev/oce/ - copied from r231706, head/sys/dev/oce/ user/attilio/vmcontention/sys/modules/oce/ - copied from r231706, head/sys/modules/oce/ user/attilio/vmcontention/tools/regression/bin/sh/builtins/hash4.0 - copied unchanged from r231706, head/tools/regression/bin/sh/builtins/hash4.0 user/attilio/vmcontention/tools/test/hwpmc/ - copied from r231706, head/tools/test/hwpmc/ user/attilio/vmcontention/tools/test/ptrace/ - copied from r231706, head/tools/test/ptrace/ user/attilio/vmcontention/usr.sbin/utx/ - copied from r231706, head/usr.sbin/utx/ Deleted: user/attilio/vmcontention/include/_xlocale_ctype.h user/attilio/vmcontention/sys/amd64/conf/WITHOUT_SOURCELESS user/attilio/vmcontention/sys/amd64/conf/WITHOUT_SOURCELESS_HOST user/attilio/vmcontention/sys/amd64/conf/WITHOUT_SOURCELESS_UCODE user/attilio/vmcontention/sys/i386/conf/WITHOUT_SOURCELESS user/attilio/vmcontention/sys/i386/conf/WITHOUT_SOURCELESS_HOST user/attilio/vmcontention/sys/i386/conf/WITHOUT_SOURCELESS_UCODE user/attilio/vmcontention/usr.sbin/utxrm/ Modified: user/attilio/vmcontention/UPDATING user/attilio/vmcontention/bin/sh/exec.c user/attilio/vmcontention/crypto/openssh/auth2.c user/attilio/vmcontention/crypto/openssh/channels.c user/attilio/vmcontention/crypto/openssh/channels.h user/attilio/vmcontention/crypto/openssh/kex.c user/attilio/vmcontention/crypto/openssh/loginrec.c (contents, props changed) user/attilio/vmcontention/crypto/openssh/readconf.c user/attilio/vmcontention/crypto/openssh/readconf.h user/attilio/vmcontention/crypto/openssh/servconf.c user/attilio/vmcontention/crypto/openssh/sftp.1 user/attilio/vmcontention/crypto/openssh/ssh.c user/attilio/vmcontention/crypto/openssh/sshd.c user/attilio/vmcontention/crypto/openssh/sshd_config.5 user/attilio/vmcontention/crypto/openssh/version.h user/attilio/vmcontention/etc/defaults/rc.conf user/attilio/vmcontention/etc/devd/usb.conf user/attilio/vmcontention/etc/mtree/BSD.include.dist user/attilio/vmcontention/etc/rc.d/LOGIN user/attilio/vmcontention/etc/rc.d/Makefile user/attilio/vmcontention/etc/rc.d/SERVERS user/attilio/vmcontention/etc/rc.d/addswap user/attilio/vmcontention/etc/rc.d/amd user/attilio/vmcontention/etc/rc.d/apmd user/attilio/vmcontention/etc/rc.d/cleanvar user/attilio/vmcontention/etc/rc.d/keyserv user/attilio/vmcontention/etc/rc.d/lockd user/attilio/vmcontention/etc/rc.d/mountd user/attilio/vmcontention/etc/rc.d/nfsd user/attilio/vmcontention/etc/rc.d/statd user/attilio/vmcontention/etc/rc.d/var user/attilio/vmcontention/etc/rc.d/watchdogd user/attilio/vmcontention/etc/rc.d/ypbind user/attilio/vmcontention/etc/rc.d/yppasswdd user/attilio/vmcontention/etc/rc.d/ypserv user/attilio/vmcontention/etc/rc.d/ypset user/attilio/vmcontention/etc/rc.d/ypupdated user/attilio/vmcontention/etc/rc.d/ypxfrd user/attilio/vmcontention/etc/rc.subr user/attilio/vmcontention/gnu/usr.bin/cc/cc_tools/auto-host.h user/attilio/vmcontention/include/Makefile user/attilio/vmcontention/include/ctype.h user/attilio/vmcontention/include/langinfo.h user/attilio/vmcontention/include/locale.h user/attilio/vmcontention/include/rpc/svc.h user/attilio/vmcontention/include/runetype.h user/attilio/vmcontention/include/string.h user/attilio/vmcontention/include/time.h user/attilio/vmcontention/include/wchar.h user/attilio/vmcontention/include/wctype.h user/attilio/vmcontention/include/xlocale.h user/attilio/vmcontention/lib/libc/arm/gen/Makefile.inc user/attilio/vmcontention/lib/libc/db/man/hash.3 user/attilio/vmcontention/lib/libc/gen/arc4random.3 user/attilio/vmcontention/lib/libc/gen/getutxent.3 user/attilio/vmcontention/lib/libc/gen/getutxent.c user/attilio/vmcontention/lib/libc/gen/sysctl.3 user/attilio/vmcontention/lib/libc/locale/Symbol.map user/attilio/vmcontention/lib/libc/locale/btowc.3 user/attilio/vmcontention/lib/libc/locale/setrunelocale.c user/attilio/vmcontention/lib/libc/locale/table.c user/attilio/vmcontention/lib/libc/locale/xlocale.c user/attilio/vmcontention/lib/libc/locale/xlocale_private.h user/attilio/vmcontention/lib/libc/net/getifaddrs.c user/attilio/vmcontention/lib/libc/net/nsdispatch.3 user/attilio/vmcontention/lib/libc/rpc/rpc.3 user/attilio/vmcontention/lib/libc/rpc/rpc_clnt_create.3 user/attilio/vmcontention/lib/libc/sys/getdirentries.2 user/attilio/vmcontention/lib/libc/sys/jail.2 user/attilio/vmcontention/lib/libc/sys/nfssvc.2 user/attilio/vmcontention/lib/libcam/cam.3 user/attilio/vmcontention/lib/libcam/cam_cdbparse.3 user/attilio/vmcontention/lib/libdevstat/devstat.3 user/attilio/vmcontention/lib/libipsec/pfkey.c user/attilio/vmcontention/lib/libradius/libradius.3 user/attilio/vmcontention/lib/libthr/arch/arm/arm/pthread_md.c user/attilio/vmcontention/lib/libthr/arch/arm/include/pthread_md.h user/attilio/vmcontention/lib/libthr/thread/thr_list.c user/attilio/vmcontention/libexec/rtld-elf/arm/reloc.c user/attilio/vmcontention/libexec/rtld-elf/arm/rtld_machdep.h user/attilio/vmcontention/libexec/rtld-elf/mips/reloc.c user/attilio/vmcontention/libexec/rtld-elf/mips/rtld_machdep.h user/attilio/vmcontention/libexec/rtld-elf/rtld.c user/attilio/vmcontention/rescue/rescue/Makefile user/attilio/vmcontention/sbin/bsdlabel/bsdlabel.8 user/attilio/vmcontention/sbin/hastd/rangelock.c user/attilio/vmcontention/sbin/ifconfig/Makefile user/attilio/vmcontention/sbin/ifconfig/ifconfig.c user/attilio/vmcontention/sbin/init/init.8 user/attilio/vmcontention/sbin/init/init.c user/attilio/vmcontention/sbin/newfs_msdos/newfs_msdos.8 user/attilio/vmcontention/share/man/man4/agp.4 user/attilio/vmcontention/share/man/man4/icmp6.4 user/attilio/vmcontention/share/man/man4/ip6.4 user/attilio/vmcontention/share/man/man4/isci.4 (contents, props changed) user/attilio/vmcontention/share/man/man4/mem.4 user/attilio/vmcontention/share/man/man4/mtio.4 user/attilio/vmcontention/share/man/man4/natm.4 user/attilio/vmcontention/share/man/man4/net80211.4 user/attilio/vmcontention/share/man/man4/ng_async.4 user/attilio/vmcontention/share/man/man4/ng_bridge.4 user/attilio/vmcontention/share/man/man4/ng_btsocket.4 user/attilio/vmcontention/share/man/man4/ng_car.4 user/attilio/vmcontention/share/man/man4/ng_ccatm.4 user/attilio/vmcontention/share/man/man4/ng_cisco.4 user/attilio/vmcontention/share/man/man4/ng_etf.4 user/attilio/vmcontention/share/man/man4/ng_hci.4 user/attilio/vmcontention/share/man/man4/ng_l2cap.4 user/attilio/vmcontention/share/man/man4/ng_l2tp.4 user/attilio/vmcontention/share/man/man4/ng_mppc.4 user/attilio/vmcontention/share/man/man4/ng_netflow.4 user/attilio/vmcontention/share/man/man4/ng_one2many.4 user/attilio/vmcontention/share/man/man4/ng_ppp.4 user/attilio/vmcontention/share/man/man4/ng_pppoe.4 user/attilio/vmcontention/share/man/man4/ng_pptpgre.4 user/attilio/vmcontention/share/man/man4/ppi.4 user/attilio/vmcontention/share/man/man5/fs.5 user/attilio/vmcontention/share/man/man5/rc.conf.5 user/attilio/vmcontention/share/man/man9/MD5.9 user/attilio/vmcontention/share/man/man9/bios.9 user/attilio/vmcontention/share/man/man9/bus_space.9 user/attilio/vmcontention/share/man/man9/crypto.9 user/attilio/vmcontention/share/man/man9/device_set_flags.9 user/attilio/vmcontention/share/man/man9/devstat.9 user/attilio/vmcontention/share/man/man9/eventtimers.9 user/attilio/vmcontention/share/man/man9/get_cyclecount.9 user/attilio/vmcontention/share/man/man9/mbchain.9 user/attilio/vmcontention/share/man/man9/mbuf_tags.9 user/attilio/vmcontention/share/man/man9/mdchain.9 user/attilio/vmcontention/share/man/man9/netisr.9 user/attilio/vmcontention/share/man/man9/random.9 user/attilio/vmcontention/share/man/man9/rijndael.9 user/attilio/vmcontention/share/man/man9/zone.9 user/attilio/vmcontention/sys/amd64/amd64/vm_machdep.c user/attilio/vmcontention/sys/conf/NOTES user/attilio/vmcontention/sys/conf/files user/attilio/vmcontention/sys/conf/newvers.sh user/attilio/vmcontention/sys/dev/aac/aac.c user/attilio/vmcontention/sys/dev/acpica/Osd/OsdSynch.c user/attilio/vmcontention/sys/dev/ata/ata-queue.c user/attilio/vmcontention/sys/dev/ath/if_ath.c user/attilio/vmcontention/sys/dev/cxgbe/common/t4_hw.c user/attilio/vmcontention/sys/dev/mps/mps_pci.c user/attilio/vmcontention/sys/dev/mpt/mpilib/mpi_type.h user/attilio/vmcontention/sys/dev/mpt/mpt.c user/attilio/vmcontention/sys/dev/mpt/mpt.h user/attilio/vmcontention/sys/dev/mpt/mpt_cam.c user/attilio/vmcontention/sys/dev/mpt/mpt_pci.c user/attilio/vmcontention/sys/dev/mpt/mpt_reg.h user/attilio/vmcontention/sys/dev/netmap/if_em_netmap.h user/attilio/vmcontention/sys/dev/netmap/if_igb_netmap.h user/attilio/vmcontention/sys/dev/netmap/if_lem_netmap.h user/attilio/vmcontention/sys/dev/netmap/if_re_netmap.h user/attilio/vmcontention/sys/dev/netmap/ixgbe_netmap.h user/attilio/vmcontention/sys/dev/netmap/netmap.c user/attilio/vmcontention/sys/dev/netmap/netmap_kern.h user/attilio/vmcontention/sys/dev/pci/pci.c user/attilio/vmcontention/sys/dev/re/if_re.c user/attilio/vmcontention/sys/dev/sound/pcm/sound.c user/attilio/vmcontention/sys/dev/vge/if_vge.c user/attilio/vmcontention/sys/fs/tmpfs/tmpfs_vnops.c user/attilio/vmcontention/sys/kern/subr_syscall.c user/attilio/vmcontention/sys/mips/include/elf.h user/attilio/vmcontention/sys/mips/mips/vm_machdep.c user/attilio/vmcontention/sys/modules/Makefile user/attilio/vmcontention/sys/net/if.h user/attilio/vmcontention/sys/net/rtsock.c user/attilio/vmcontention/sys/net/zlib.h user/attilio/vmcontention/sys/net80211/ieee80211_mesh.c user/attilio/vmcontention/sys/net80211/ieee80211_mesh.h user/attilio/vmcontention/sys/netgraph/ng_cisco.c user/attilio/vmcontention/sys/netgraph/ng_cisco.h user/attilio/vmcontention/sys/netgraph/ng_socket.c user/attilio/vmcontention/sys/netinet/sctp_output.c user/attilio/vmcontention/sys/sys/cdefs.h user/attilio/vmcontention/sys/sys/elf_common.h user/attilio/vmcontention/sys/sys/param.h user/attilio/vmcontention/sys/sys/ptrace.h user/attilio/vmcontention/sys/sys/socket.h user/attilio/vmcontention/sys/ufs/ffs/ffs_softdep.c user/attilio/vmcontention/sys/vm/vm_map.c user/attilio/vmcontention/sys/vm/vm_map.h user/attilio/vmcontention/sys/vm/vm_mmap.c user/attilio/vmcontention/tools/build/mk/OptionalObsoleteFiles.inc user/attilio/vmcontention/tools/build/options/WITHOUT_UTMPX user/attilio/vmcontention/tools/regression/usr.bin/make/execution/joberr/expected.stdout.1 user/attilio/vmcontention/usr.bin/calendar/calendars/calendar.freebsd user/attilio/vmcontention/usr.bin/chpass/util.c user/attilio/vmcontention/usr.bin/login/login_fbtab.c user/attilio/vmcontention/usr.bin/m4/lib/ohash_interval.3 user/attilio/vmcontention/usr.bin/make/job.c user/attilio/vmcontention/usr.bin/who/who.1 user/attilio/vmcontention/usr.bin/who/who.c user/attilio/vmcontention/usr.bin/write/write.1 user/attilio/vmcontention/usr.bin/write/write.c user/attilio/vmcontention/usr.sbin/Makefile user/attilio/vmcontention/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.3 user/attilio/vmcontention/usr.sbin/periodic/periodic.sh user/attilio/vmcontention/usr.sbin/pw/cpdir.c user/attilio/vmcontention/usr.sbin/vipw/vipw.8 Directory Properties: user/attilio/vmcontention/ (props changed) user/attilio/vmcontention/crypto/openssh/ (props changed) user/attilio/vmcontention/gnu/usr.bin/cc/cc_tools/ (props changed) user/attilio/vmcontention/lib/libc/ (props changed) user/attilio/vmcontention/sbin/ (props changed) user/attilio/vmcontention/share/man/man4/ (props changed) user/attilio/vmcontention/sys/ (props changed) user/attilio/vmcontention/sys/conf/ (props changed) user/attilio/vmcontention/usr.bin/calendar/ (props changed) Modified: user/attilio/vmcontention/UPDATING ============================================================================== --- user/attilio/vmcontention/UPDATING Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/UPDATING Tue Feb 14 19:58:00 2012 (r231707) @@ -22,6 +22,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10 machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20120211: + The getifaddrs upgrade path broken with 20111215 has been restored. + If you have upgraded in between 20111215 and 20120209 you need to + recompile libc again with your kernel. You still need to recompile + world to be able to configure CARP but this restriction already + comes from 20111215. + 20120114: The set_rcvar() function has been removed from /etc/rc.subr. All base and ports rc.d scripts have been updated, so if you have a Modified: user/attilio/vmcontention/bin/sh/exec.c ============================================================================== --- user/attilio/vmcontention/bin/sh/exec.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/bin/sh/exec.c Tue Feb 14 19:58:00 2012 (r231707) @@ -231,7 +231,9 @@ hashcmd(int argc __unused, char **argv _ int verbose; struct cmdentry entry; char *name; + int errors; + errors = 0; verbose = 0; while ((c = nextopt("rv")) != '\0') { if (c == 'r') { @@ -254,19 +256,21 @@ hashcmd(int argc __unused, char **argv _ && cmdp->cmdtype == CMDNORMAL) delete_cmd_entry(); find_command(name, &entry, DO_ERR, pathval()); - if (verbose) { - if (entry.cmdtype != CMDUNKNOWN) { /* if no error msg */ - cmdp = cmdlookup(name, 0); - if (cmdp != NULL) - printentry(cmdp, verbose); - else - outfmt(out2, "%s: not found\n", name); + if (entry.cmdtype == CMDUNKNOWN) + errors = 1; + else if (verbose) { + cmdp = cmdlookup(name, 0); + if (cmdp != NULL) + printentry(cmdp, verbose); + else { + outfmt(out2, "%s: not found\n", name); + errors = 1; } flushall(); } argptr++; } - return 0; + return errors; } Modified: user/attilio/vmcontention/crypto/openssh/auth2.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/auth2.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/auth2.c Tue Feb 14 19:58:00 2012 (r231707) @@ -223,8 +223,8 @@ input_userauth_request(int type, u_int32 login_cap_t *lc; const char *from_host, *from_ip; - from_host = get_canonical_hostname(options.use_dns); - from_ip = get_remote_ipaddr(); + from_host = get_canonical_hostname(options.use_dns); + from_ip = get_remote_ipaddr(); #endif if (authctxt == NULL) @@ -272,23 +272,23 @@ input_userauth_request(int type, u_int32 } #ifdef HAVE_LOGIN_CAP - if (authctxt->pw != NULL) { - lc = login_getpwclass(authctxt->pw); - if (lc == NULL) - lc = login_getclassbyname(NULL, authctxt->pw); - if (!auth_hostok(lc, from_host, from_ip)) { - logit("Denied connection for %.200s from %.200s [%.200s].", - authctxt->pw->pw_name, from_host, from_ip); - packet_disconnect("Sorry, you are not allowed to connect."); - } - if (!auth_timeok(lc, time(NULL))) { - logit("LOGIN %.200s REFUSED (TIME) FROM %.200s", - authctxt->pw->pw_name, from_host); - packet_disconnect("Logins not available right now."); - } - login_close(lc); - lc = NULL; - } + if (authctxt->pw != NULL) { + lc = login_getpwclass(authctxt->pw); + if (lc == NULL) + lc = login_getclassbyname(NULL, authctxt->pw); + if (!auth_hostok(lc, from_host, from_ip)) { + logit("Denied connection for %.200s from %.200s [%.200s].", + authctxt->pw->pw_name, from_host, from_ip); + packet_disconnect("Sorry, you are not allowed to connect."); + } + if (!auth_timeok(lc, time(NULL))) { + logit("LOGIN %.200s REFUSED (TIME) FROM %.200s", + authctxt->pw->pw_name, from_host); + packet_disconnect("Logins not available right now."); + } + login_close(lc); + lc = NULL; + } #endif /* HAVE_LOGIN_CAP */ /* reset state */ Modified: user/attilio/vmcontention/crypto/openssh/channels.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/channels.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/channels.c Tue Feb 14 19:58:00 2012 (r231707) @@ -824,7 +824,7 @@ channel_tcpwinsz(void) u_int maxlen; /* If we are not on a socket return 128KB. */ - if (!packet_connection_is_on_socket()) + if (!packet_connection_is_on_socket()) return (128 * 1024); tcpwinsz = 0; @@ -854,7 +854,7 @@ channel_pre_open(Channel *c, fd_set *rea limit = MIN(compat20 ? c->remote_window : packet_get_maxsize(), 2 * c->tcpwinsz); - + if (c->istate == CHAN_INPUT_OPEN && limit > 0 && buffer_len(&c->input) < limit && @@ -2687,10 +2687,10 @@ channel_set_af(int af) IPv4or6 = af; } -void +void channel_set_hpn(int disabled, u_int buf_size) { - hpn_disabled = disabled; + hpn_disabled = disabled; buffer_size = buf_size; debug("HPN Disabled: %d, HPN Buffer Size: %d", hpn_disabled, buffer_size); @@ -2856,10 +2856,10 @@ channel_setup_fwd_listener(int type, con c = channel_new("port listener", type, sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "port listener", 1); - else - c = channel_new("port listener", type, sock, sock, -1, - buffer_size, CHAN_TCP_PACKET_DEFAULT, - 0, "port listener", 1); + else + c = channel_new("port listener", type, sock, sock, -1, + buffer_size, CHAN_TCP_PACKET_DEFAULT, + 0, "port listener", 1); c->path = xstrdup(host); c->host_port = port_to_connect; c->listening_port = listen_port; Modified: user/attilio/vmcontention/crypto/openssh/channels.h ============================================================================== --- user/attilio/vmcontention/crypto/openssh/channels.h Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/channels.h Tue Feb 14 19:58:00 2012 (r231707) @@ -126,7 +126,7 @@ struct Channel { u_int local_window_max; u_int local_consumed; u_int local_maxpacket; - u_int tcpwinsz; + u_int tcpwinsz; int dynamic_window; int extended_usage; int single_connection; @@ -165,13 +165,10 @@ struct Channel { /* default window/packet sizes for tcp/x11-fwd-channel */ #define CHAN_SES_PACKET_DEFAULT (32*1024) #define CHAN_SES_WINDOW_DEFAULT (64*CHAN_SES_PACKET_DEFAULT) - #define CHAN_TCP_PACKET_DEFAULT (32*1024) #define CHAN_TCP_WINDOW_DEFAULT (64*CHAN_TCP_PACKET_DEFAULT) - #define CHAN_X11_PACKET_DEFAULT (16*1024) #define CHAN_X11_WINDOW_DEFAULT (4*CHAN_X11_PACKET_DEFAULT) - #define CHAN_HPN_MIN_WINDOW_DEFAULT (2*1024*1024) /* possible input states */ @@ -302,6 +299,7 @@ void chan_write_failed(Channel *); void chan_obuf_empty(Channel *); /* hpn handler */ -void channel_set_hpn(int, u_int); + +void channel_set_hpn(int, u_int); #endif Modified: user/attilio/vmcontention/crypto/openssh/kex.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/kex.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/kex.c Tue Feb 14 19:58:00 2012 (r231707) @@ -457,13 +457,13 @@ kex_choose_conf(Kex *kex) #ifdef NONE_CIPHER_ENABLED debug("REQUESTED ENC.NAME is '%s'", newkeys->enc.name); if (strcmp(newkeys->enc.name, "none") == 0) { - debug("Requesting NONE. Authflag is %d", auth_flag); + debug("Requesting NONE. Authflag is %d", auth_flag); if (auth_flag == 1) debug("None requested post authentication."); else fatal("Pre-authentication none cipher requests " "are not allowed."); - } + } #endif debug("kex: %s %s %s %s", ctos ? "client->server" : "server->client", Modified: user/attilio/vmcontention/crypto/openssh/loginrec.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/loginrec.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/loginrec.c Tue Feb 14 19:58:00 2012 (r231707) @@ -146,7 +146,6 @@ */ #include "includes.h" -__RCSID("$FreeBSD$"); #include #include @@ -516,10 +515,6 @@ getlast_entry(struct logininfo *li) return (utmpx_get_entry(li)); #endif -#if 1 - return (utmpx_get_entry(li)); -#endif - #if defined(DISABLE_LASTLOG) /* On some systems we shouldn't even try to obtain last login * time, e.g. AIX */ Modified: user/attilio/vmcontention/crypto/openssh/readconf.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/readconf.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/readconf.c Tue Feb 14 19:58:00 2012 (r231707) @@ -264,6 +264,7 @@ static struct { { "noneswitch", oNoneSwitch }, #endif { "versionaddendum", oVersionAddendum }, + { NULL, oBadOption } }; @@ -1092,9 +1093,9 @@ parse_int: case oNoneEnabled: intptr = &options->none_enabled; goto parse_flag; - + /* - * We check to see if the command comes from the command line or not. + * We check to see if the command comes from the command line or not. * If it does then enable it otherwise fail. NONE must never be a * default configuration. */ @@ -1110,7 +1111,7 @@ parse_int: "from the command line", filename); error("Continuing..."); return 0; - } + } #endif case oVersionAddendum: @@ -1458,7 +1459,7 @@ fill_default_options(Options * options) /* options->host_key_alias should not be set by default */ /* options->preferred_authentications will be set in ssh */ if (options->hpn_disabled == -1) - options->hpn_disabled = 0; + options->hpn_disabled = 0; if (options->hpn_buffer_size > -1) { u_int maxlen; @@ -1478,7 +1479,7 @@ fill_default_options(Options * options) } if (options->tcp_rcv_buf == 0) options->tcp_rcv_buf = 1; - if (options->tcp_rcv_buf > -1) + if (options->tcp_rcv_buf > -1) options->tcp_rcv_buf *= 1024; if (options->tcp_rcv_buf_poll == -1) options->tcp_rcv_buf_poll = 1; Modified: user/attilio/vmcontention/crypto/openssh/readconf.h ============================================================================== --- user/attilio/vmcontention/crypto/openssh/readconf.h Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/readconf.h Tue Feb 14 19:58:00 2012 (r231707) @@ -133,6 +133,7 @@ typedef struct { int visual_host_key; int use_roaming; + int request_tty; int hpn_disabled; /* Switch to disable HPN buffer management. */ Modified: user/attilio/vmcontention/crypto/openssh/servconf.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/servconf.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/servconf.c Tue Feb 14 19:58:00 2012 (r231707) @@ -166,7 +166,7 @@ fill_default_server_options(ServerOption _PATH_HOST_KEY_FILE; if (options->protocol & SSH_PROTO_2) { options->host_key_files[options->num_host_key_files++] = - _PATH_HOST_RSA_KEY_FILE; + _PATH_HOST_RSA_KEY_FILE; options->host_key_files[options->num_host_key_files++] = _PATH_HOST_DSA_KEY_FILE; #ifdef OPENSSL_HAS_ECC @@ -286,7 +286,7 @@ fill_default_server_options(ServerOption options->ip_qos_interactive = IPTOS_LOWDELAY; if (options->ip_qos_bulk == -1) options->ip_qos_bulk = IPTOS_THROUGHPUT; - if (options->hpn_disabled == -1) + if (options->hpn_disabled == -1) options->hpn_disabled = 0; if (options->hpn_buffer_size == -1) { /* Modified: user/attilio/vmcontention/crypto/openssh/sftp.1 ============================================================================== --- user/attilio/vmcontention/crypto/openssh/sftp.1 Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/sftp.1 Tue Feb 14 19:58:00 2012 (r231707) @@ -246,7 +246,7 @@ diagnostic messages from Specify how many requests may be outstanding at any one time. Increasing this may slightly improve file transfer speed but will increase memory usage. -The default is 256 outstanding requests providing for 8MB +The default is 256 outstanding requests providing for 8MB of outstanding data with a 32KB buffer. .It Fl r Recursively copy entire directories when uploading and downloading. Modified: user/attilio/vmcontention/crypto/openssh/ssh.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/ssh.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/ssh.c Tue Feb 14 19:58:00 2012 (r231707) @@ -1461,6 +1461,7 @@ ssh_session2_open(void) c->dynamic_window = 1; debug("Enabled Dynamic Window Scaling\n"); } + debug3("ssh_session2_open: channel_new: %d", c->self); channel_send_open(c->self); Modified: user/attilio/vmcontention/crypto/openssh/sshd.c ============================================================================== --- user/attilio/vmcontention/crypto/openssh/sshd.c Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/sshd.c Tue Feb 14 19:58:00 2012 (r231707) @@ -1916,11 +1916,11 @@ main(int ac, char **av) #ifdef __FreeBSD__ /* * Initialize the resolver. This may not happen automatically - * before privsep chroot(). + * before privsep chroot(). */ if ((_res.options & RES_INIT) == 0) { - debug("res_init()"); - res_init(); + debug("res_init()"); + res_init(); } #ifdef GSSAPI /* Modified: user/attilio/vmcontention/crypto/openssh/sshd_config.5 ============================================================================== --- user/attilio/vmcontention/crypto/openssh/sshd_config.5 Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/sshd_config.5 Tue Feb 14 19:58:00 2012 (r231707) @@ -499,7 +499,7 @@ or .Pp .Pa /etc/hosts.equiv and -.Pa /etc/ssh/shosts.equiv +.Pa /etc/ssh/shosts.equiv are still used. The default is .Dq yes . Modified: user/attilio/vmcontention/crypto/openssh/version.h ============================================================================== --- user/attilio/vmcontention/crypto/openssh/version.h Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/crypto/openssh/version.h Tue Feb 14 19:58:00 2012 (r231707) @@ -2,11 +2,11 @@ /* $FreeBSD$ */ #ifndef SSH_VERSION -#define SSH_VERSION_BASE "OpenSSH_5.9p1" -#define SSH_VERSION_ADDENDUM "FreeBSD-20111001" +#define SSH_VERSION_BASE "OpenSSH_5.9p1" +#define SSH_VERSION_ADDENDUM "FreeBSD-20111001" #define SSH_VERSION_HPN "_hpn13v11" #define SSH_VERSION SSH_VERSION_BASE SSH_VERSION_HPN " " SSH_VERSION_ADDENDUM -#define SSH_RELEASE (ssh_version_get()) +#define SSH_RELEASE (ssh_version_get()) const char *ssh_version_get(void); void ssh_version_set_addendum(const char *); Modified: user/attilio/vmcontention/etc/defaults/rc.conf ============================================================================== --- user/attilio/vmcontention/etc/defaults/rc.conf Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/defaults/rc.conf Tue Feb 14 19:58:00 2012 (r231707) @@ -29,6 +29,8 @@ early_late_divider="FILESYSTEMS" # Scrip # stages of the boot process. Make sure you know # the ramifications if you change this. # See rc.conf(5) for more details. +always_force_depends="NO" # Set to check that indicated dependencies are + # running during boot (can increase boot time). swapfile="NO" # Set to name of swapfile if aux swapfile desired. apm_enable="NO" # Set to YES to enable APM BIOS functions (or NO). Modified: user/attilio/vmcontention/etc/devd/usb.conf ============================================================================== --- user/attilio/vmcontention/etc/devd/usb.conf Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/devd/usb.conf Tue Feb 14 19:58:00 2012 (r231707) @@ -157,7 +157,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0403"; - match "product" "(0x6001|0x6004|0x6010|0x6011|0x8372|0x9e90|0xcc48|0xcc49|0xcc4a|0xd678|0xe6c8|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xee18|0xf608|0xf60b|0xf850|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfc08|0xfc09|0xfc0b|0xfc0c|0xfc0d|0xfc82)"; + match "product" "(0x6001|0x6004|0x6010|0x6011|0x8372|0x9e90|0xa6d0|0xa6d0|0xcc48|0xcc49|0xcc4a|0xd678|0xe6c8|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xee18|0xf608|0xf60b|0xf850|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfc08|0xfc09|0xfc0b|0xfc0c|0xfc0d|0xfc82)"; action "kldload uftdi"; }; @@ -293,7 +293,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0411"; - match "product" "(0x0148|0x0150|0x015d|0x016f)"; + match "product" "(0x0148|0x0150|0x015d|0x016f|0x01a2)"; action "kldload if_run"; }; @@ -1021,7 +1021,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x05c6"; - match "product" "(0x6000|0x6613)"; + match "product" "(0x1000|0x6000|0x6613)"; action "kldload u3g"; }; @@ -1301,7 +1301,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0789"; - match "product" "(0x0162|0x0163|0x0164)"; + match "product" "(0x0162|0x0163|0x0164|0x0166)"; action "kldload if_run"; }; @@ -2093,7 +2093,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0b95"; - match "product" "(0x1720|0x1780|0x7720|0x772a|0x772b)"; + match "product" "(0x1720|0x1780|0x7720|0x772a|0x772b|0x7e2b)"; action "kldload if_axe"; }; @@ -4205,6 +4205,15 @@ nomatch 32 { nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; + match "intclass" "0x02"; + match "intsubclass" "0x02"; + match "intprotocol" "0xff"; + action "kldload umodem"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; match "intclass" "0x03"; match "intsubclass" "0x01"; match "intprotocol" "0x01"; @@ -4327,5 +4336,5 @@ nomatch 32 { action "kldload umass"; }; -# 1645 USB entries processed +# 1652 USB entries processed Modified: user/attilio/vmcontention/etc/mtree/BSD.include.dist ============================================================================== --- user/attilio/vmcontention/etc/mtree/BSD.include.dist Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/mtree/BSD.include.dist Tue Feb 14 19:58:00 2012 (r231707) @@ -329,4 +329,6 @@ .. vm .. + xlocale + .. .. Modified: user/attilio/vmcontention/etc/rc.d/LOGIN ============================================================================== --- user/attilio/vmcontention/etc/rc.d/LOGIN Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/LOGIN Tue Feb 14 19:58:00 2012 (r231707) @@ -4,7 +4,7 @@ # # PROVIDE: LOGIN -# REQUIRE: DAEMON +# REQUIRE: DAEMON utx # This is a dummy dependency to ensure user services such as xdm, # inetd, cron and kerberos are started after everything else, in case Modified: user/attilio/vmcontention/etc/rc.d/Makefile ============================================================================== --- user/attilio/vmcontention/etc/rc.d/Makefile Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/Makefile Tue Feb 14 19:58:00 2012 (r231707) @@ -144,6 +144,7 @@ FILES= DAEMON \ tmp \ ${_ubthidhci} \ ugidfw \ + ${_utx} \ var \ virecover \ watchdogd \ @@ -177,6 +178,10 @@ _nscd= nscd _ubthidhci= ubthidhci .endif +.if ${MK_UTMPX} != "no" +_utx= utx +.endif + FILESDIR= /etc/rc.d FILESMODE= ${BINMODE} Modified: user/attilio/vmcontention/etc/rc.d/SERVERS ============================================================================== --- user/attilio/vmcontention/etc/rc.d/SERVERS Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/SERVERS Tue Feb 14 19:58:00 2012 (r231707) @@ -4,7 +4,7 @@ # # PROVIDE: SERVERS -# REQUIRE: mountcritremote abi ldconfig savecore +# REQUIRE: mountcritremote abi ldconfig savecore watchdogd # This is a dummy dependency, for early-start servers relying on # some basic configuration. Modified: user/attilio/vmcontention/etc/rc.d/addswap ============================================================================== --- user/attilio/vmcontention/etc/rc.d/addswap Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/addswap Tue Feb 14 19:58:00 2012 (r231707) @@ -6,7 +6,7 @@ # # PROVIDE: addswap -# REQUIRE: FILESYSTEMS +# REQUIRE: FILESYSTEMS kld # KEYWORD: nojail . /etc/rc.subr Modified: user/attilio/vmcontention/etc/rc.d/amd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/amd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/amd Tue Feb 14 19:58:00 2012 (r231707) @@ -19,15 +19,8 @@ extra_commands="reload" amd_precmd() { - if ! checkyesno nfs_client_enable; then - force_depend nfsclient || return 1 - fi - - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + force_depend nfsclient nfs_client || return 1 + force_depend rpcbind || return 1 case ${amd_map_program} in [Nn][Oo] | '') @@ -49,7 +42,6 @@ amd_precmd() command_args="> /var/run/amd.pid 2> /dev/null" ;; esac - return 0 } load_rc_config $name Modified: user/attilio/vmcontention/etc/rc.d/apmd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/apmd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/apmd Tue Feb 14 19:58:00 2012 (r231707) @@ -19,24 +19,18 @@ apmd_prestart() { case `${SYSCTL_N} hw.machine_arch` in i386) - # Enable apm if it is not already enabled - if ! checkyesno apm_enable && \ - ! /etc/rc.d/apm forcestatus 1>/dev/null 2>&1 - then - force_depend apm || return 1 - fi + force_depend apm || return 1 # Warn user about acpi apm compatibility support which # does not work with apmd. if [ ! -e /dev/apmctl ]; then - warn "/dev/apmctl not found; kernel is missing apm(4)" + warn "/dev/apmctl not found; kernel is missing apm(4)" fi ;; *) return 1 ;; esac - return 0 } load_rc_config $name Modified: user/attilio/vmcontention/etc/rc.d/cleanvar ============================================================================== --- user/attilio/vmcontention/etc/rc.d/cleanvar Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/cleanvar Tue Feb 14 19:58:00 2012 (r231707) @@ -58,8 +58,6 @@ cleanvar_start () { if [ -d /var/run -a ! -f /var/run/clean_var ]; then purgedir /var/run - # And an initial utmpx active session file - (cd /var/run && cp /dev/null utx.active && chmod 644 utx.active) >/var/run/clean_var fi if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then Modified: user/attilio/vmcontention/etc/rc.d/keyserv ============================================================================== --- user/attilio/vmcontention/etc/rc.d/keyserv Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/keyserv Tue Feb 14 19:58:00 2012 (r231707) @@ -19,13 +19,7 @@ start_precmd="keyserv_prestart" keyserv_prestart() { - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - - return 0 + force_depend rpcbind || return 1 } load_rc_config $name Modified: user/attilio/vmcontention/etc/rc.d/lockd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/lockd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/lockd Tue Feb 14 19:58:00 2012 (r231707) @@ -15,28 +15,16 @@ name="lockd" rcvar=rpc_lockd_enable command="/usr/sbin/rpc.${name}" start_precmd='lockd_precmd' -stop_precmd='checkyesno nfs_server_enable || checkyesno nfs_client_enable' -status_precmd=$stop_precmd # Make sure that we are either an NFS client or server, and that we get # the correct flags from rc.conf(5). # lockd_precmd() { - local ret - ret=0 - - if ! checkyesno nfs_server_enable && ! checkyesno nfs_client_enable - then - ret=1 - fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || ret=1 - fi + force_depend rpcbind || return 1 + force_depend statd rpc_statd || return 1 + rc_flags=${rpc_lockd_flags} - return ${ret} } load_rc_config $name Modified: user/attilio/vmcontention/etc/rc.d/mountd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/mountd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/mountd Tue Feb 14 19:58:00 2012 (r231707) @@ -19,11 +19,7 @@ extra_commands="reload" mountd_precmd() { - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + force_depend rpcbind || return 1 # mountd flags will differ depending on rc.conf settings # @@ -48,8 +44,8 @@ mountd_precmd() fi rm -f /var/db/mountdtab - ( umask 022 ; > /var/db/mountdtab ) - return 0 + ( umask 022 ; > /var/db/mountdtab ) || + err 1 'Cannot create /var/db/mountdtab' } load_rc_config $name Modified: user/attilio/vmcontention/etc/rc.d/nfsd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/nfsd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/nfsd Tue Feb 14 19:58:00 2012 (r231707) @@ -48,31 +48,15 @@ nfsd_precmd() if checkyesno nfsv4_server_enable; then sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null - if ! checkyesno nfsuserd_enable && \ - ! /etc/rc.d/nfsuserd forcestatus 1>/dev/null 2>&1 - then - if ! force_depend nfsuserd; then - err 1 "Cannot run nfsuserd" - fi - fi + force_depend nfsuserd || err 1 "Cannot run nfsuserd" else echo 'NFSv4 is disabled' sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null fi fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - - if ! checkyesno mountd_enable && \ - ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1 - then - force_depend mountd || return 1 - fi - return 0 + force_depend rpcbind || return 1 + force_depend mountd || return 1 } run_rc_command "$1" Modified: user/attilio/vmcontention/etc/rc.d/statd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/statd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/statd Tue Feb 14 19:58:00 2012 (r231707) @@ -15,28 +15,15 @@ name="statd" rcvar=rpc_statd_enable command="/usr/sbin/rpc.${name}" start_precmd='statd_precmd' -stop_precmd='checkyesno nfs_server_enable || checkyesno nfs_client_enable' -status_precmd=$stop_precmd # Make sure that we are either an NFS client or server, and that we get # the correct flags from rc.conf(5). # statd_precmd() { - local ret - ret=0 - - if ! checkyesno nfs_server_enable && ! checkyesno nfs_client_enable - then - ret=1 - fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || ret=1 - fi + force_depend rpcbind || return 1 + rc_flags=${rpc_statd_flags} - return ${ret} } load_rc_config $name Copied: user/attilio/vmcontention/etc/rc.d/utx (from r231706, head/etc/rc.d/utx) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/attilio/vmcontention/etc/rc.d/utx Tue Feb 14 19:58:00 2012 (r231707, copy of r231706, head/etc/rc.d/utx) @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: utx +# REQUIRE: DAEMON cleanvar +# KEYWORD: shutdown + +. /etc/rc.subr + +name="utx" +start_cmd="utx boot" +stop_cmd="utx shutdown" + +load_rc_config $name +run_rc_command "$1" Modified: user/attilio/vmcontention/etc/rc.d/var ============================================================================== --- user/attilio/vmcontention/etc/rc.d/var Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/var Tue Feb 14 19:58:00 2012 (r231707) @@ -28,7 +28,7 @@ # # PROVIDE: var -# REQUIRE: FILESYSTEMS kld +# REQUIRE: FILESYSTEMS kld addswap . /etc/rc.subr Modified: user/attilio/vmcontention/etc/rc.d/watchdogd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/watchdogd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/watchdogd Tue Feb 14 19:58:00 2012 (r231707) @@ -28,7 +28,7 @@ # # PROVIDE: watchdogd -# REQUIRE: DAEMON cleanvar +# REQUIRE: FILESYSTEMS cleanvar syslogd # KEYWORD: nojail shutdown . /etc/rc.subr Modified: user/attilio/vmcontention/etc/rc.d/ypbind ============================================================================== --- user/attilio/vmcontention/etc/rc.d/ypbind Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/ypbind Tue Feb 14 19:58:00 2012 (r231707) @@ -11,22 +11,20 @@ . /etc/rc.subr name="ypbind" -command="/usr/sbin/${name}" -start_precmd="ypbind_precmd" +rcvar="nis_client_enable" load_rc_config $name -rcvar="nis_client_enable" + +command="/usr/sbin/${name}" command_args="${nis_client_flags}" +start_precmd="ypbind_precmd" + ypbind_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + force_depend rpcbind || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Modified: user/attilio/vmcontention/etc/rc.d/yppasswdd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/yppasswdd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/yppasswdd Tue Feb 14 19:58:00 2012 (r231707) @@ -11,27 +11,22 @@ . /etc/rc.subr name="yppasswdd" -command="/usr/sbin/rpc.${name}" -start_precmd="yppasswdd_precmd" +rcvar="nis_yppasswdd_enable" load_rc_config $name -rcvar="nis_yppasswdd_enable" + +command="/usr/sbin/rpc.${name}" command_args="${nis_yppasswdd_flags}" +start_precmd="yppasswdd_precmd" + yppasswdd_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_server_enable && \ - ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 - then - force_depend ypserv || return 1 - fi + force_depend rpcbind || return 1 + force_depend ypserv nis_server || return 1 + _domain=`domainname` if [ -z "$_domain" ]; then warn "NIS domainname(1) is not set." Modified: user/attilio/vmcontention/etc/rc.d/ypserv ============================================================================== --- user/attilio/vmcontention/etc/rc.d/ypserv Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/ypserv Tue Feb 14 19:58:00 2012 (r231707) @@ -11,21 +11,20 @@ name="ypserv" rcvar="nis_server_enable" -command="/usr/sbin/${name}" -start_precmd="ypserv_prestart" load_rc_config $name + +command="/usr/sbin/${name}" command_args="${nis_server_flags}" +start_precmd="ypserv_prestart" + ypserv_prestart() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + force_depend rpcbind || return 1 + _domain=`domainname` if [ -z "$_domain" ]; then warn "NIS domainname(1) is not set." Modified: user/attilio/vmcontention/etc/rc.d/ypset ============================================================================== --- user/attilio/vmcontention/etc/rc.d/ypset Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/ypset Tue Feb 14 19:58:00 2012 (r231707) @@ -11,25 +11,20 @@ name="ypset" rcvar="nis_ypset_enable" -command="/usr/sbin/${name}" -start_precmd="ypset_precmd" + load_rc_config $name + +command="/usr/sbin/${name}" command_args="${nis_ypset_flags}" +start_precmd="ypset_precmd" + ypset_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_client_enable && \ - ! /etc/rc.d/ypbind forcestatus 1>/dev/null 2>&1 - then - force_depend ypbind || return 1 - fi + force_depend rpcbind || return 1 + force_depend ypbind nis_client || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Modified: user/attilio/vmcontention/etc/rc.d/ypupdated ============================================================================== --- user/attilio/vmcontention/etc/rc.d/ypupdated Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/ypupdated Tue Feb 14 19:58:00 2012 (r231707) @@ -11,6 +11,9 @@ name="ypupdated" rcvar="rpc_ypupdated_enable" + +load_rc_config $name + command="/usr/sbin/rpc.${name}" start_precmd="rpc_ypupdated_precmd" @@ -18,16 +21,8 @@ rpc_ypupdated_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_server_enable && \ - ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 - then - force_depend ypserv || return 1 - fi + force_depend rpcbind || return 1 + force_depend ypserv nis_server || return 1 _domain=`domainname` if [ -z "$_domain" ]; then @@ -36,5 +31,4 @@ rpc_ypupdated_precmd() fi } -load_rc_config $name run_rc_command "$1" Modified: user/attilio/vmcontention/etc/rc.d/ypxfrd ============================================================================== --- user/attilio/vmcontention/etc/rc.d/ypxfrd Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.d/ypxfrd Tue Feb 14 19:58:00 2012 (r231707) @@ -11,25 +11,20 @@ name="ypxfrd" rcvar="nis_ypxfrd_enable" -command="/usr/sbin/rpc.${name}" -start_precmd="ypxfrd_precmd" + load_rc_config $name + +command="/usr/sbin/rpc.${name}" command_args="${nis_ypxfrd_flags}" +start_precmd="ypxfrd_precmd" + ypxfrd_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_server_enable && \ - ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 - then - force_depend ypserv || return 1 - fi + force_depend rpcbind || return 1 + force_depend ypserv nis_server || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Modified: user/attilio/vmcontention/etc/rc.subr ============================================================================== --- user/attilio/vmcontention/etc/rc.subr Tue Feb 14 19:50:41 2012 (r231706) +++ user/attilio/vmcontention/etc/rc.subr Tue Feb 14 19:58:00 2012 (r231707) @@ -71,22 +71,29 @@ set_rcvar_obsolete() } # -# force_depend script +# force_depend script [rcvar] # Force a service to start. Intended for use by services -# to resolve dependency issues. It is assumed the caller -# has check to make sure this call is necessary +# to resolve dependency issues. # $1 - filename of script, in /etc/rc.d, to run +# $2 - name of the script's rcvar (minus the _enable) # *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 20:12:17 2012 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 444D21065675; Tue, 14 Feb 2012 20:12:17 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19E908FC16; Tue, 14 Feb 2012 20:12:17 +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 q1EKCGsu016346; Tue, 14 Feb 2012 20:12:16 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1EKCG7s016345; Tue, 14 Feb 2012 20:12:16 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201202142012.q1EKCG7s016345@svn.freebsd.org> From: Jim Harris Date: Tue, 14 Feb 2012 20:12:16 +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: r231711 - user/jimharris/ioat 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: Tue, 14 Feb 2012 20:12:17 -0000 Author: jimharris Date: Tue Feb 14 20:12:16 2012 New Revision: 231711 URL: http://svn.freebsd.org/changeset/base/231711 Log: Create branch for ioat driver. Added: - copied from r231708, head/ Directory Properties: user/jimharris/ioat/ (props changed) From owner-svn-src-user@FreeBSD.ORG Wed Feb 15 11:11:59 2012 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 6919B106564A; Wed, 15 Feb 2012 11:11:59 +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 5242F8FC08; Wed, 15 Feb 2012 11:11:59 +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 q1FBBxNC058064; Wed, 15 Feb 2012 11:11:59 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1FBBxni058056; Wed, 15 Feb 2012 11:11:59 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202151111.q1FBBxni058056@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 15 Feb 2012 11:11:59 +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: r231755 - 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: Wed, 15 Feb 2012 11:11:59 -0000 Author: gabor Date: Wed Feb 15 11:11:58 2012 New Revision: 231755 URL: http://svn.freebsd.org/changeset/base/231755 Log: - Separate different compile logics for better later reuse and readability - Rename some functions that belong to a lower layer for clarity Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.h user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Feb 15 11:11:58 2012 (r231755) @@ -51,12 +51,12 @@ tre_fixncomp(fastmatch_t *preg, const ch if (ret != REG_OK) return ret; else - ret = tre_compile_literal(preg, wregex, wlen, cflags); + ret = tre_proc_literal(preg, wregex, wlen, cflags); tre_free_pattern(wregex); return ret; } else - return tre_compile_literal(preg, NULL, 0, cflags); + return tre_proc_literal(preg, NULL, 0, cflags); } int @@ -73,13 +73,13 @@ tre_fastncomp(fastmatch_t *preg, const c return ret; else ret = (cflags & REG_LITERAL) - ? tre_compile_literal(preg, wregex, wlen, cflags) - : tre_compile_fast(preg, wregex, wlen, cflags); + ? tre_proc_literal(preg, wregex, wlen, cflags) + : tre_proc_fast(preg, wregex, wlen, cflags); tre_free_pattern(wregex); return ret; } else - return tre_compile_literal(preg, NULL, 0, cflags); + return tre_proc_literal(preg, NULL, 0, cflags); } @@ -98,15 +98,15 @@ tre_fastcomp(fastmatch_t *preg, const ch int tre_fixwncomp(fastmatch_t *preg, const wchar_t *regex, size_t n, int cflags) { - return tre_compile_literal(preg, regex, n, cflags); + return tre_proc_literal(preg, regex, n, cflags); } int tre_fastwncomp(fastmatch_t *preg, const wchar_t *regex, size_t n, int cflags) { return (cflags & REG_LITERAL) ? - tre_compile_literal(preg, regex, n, cflags) : - tre_compile_fast(preg, regex, n, cflags); + tre_proc_literal(preg, regex, n, cflags) : + tre_proc_fast(preg, regex, n, cflags); } int Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Feb 15 11:11:58 2012 (r231755) @@ -1947,49 +1947,107 @@ tre_free_pattern(tre_char_t *wregex) int tre_compile(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) { + int ret; + + /* + * First, we always compile the NFA and it also serves as + * pattern validation. In this way, validation is not + * scattered through the code. + */ + ret = tre_compile_nfa(preg, regex, n, cflags); + if (ret != REG_OK) + return ret; + + /* + * Check if we can cheat with a fixed string algorithm + * if the pattern is long enough. + */ + ret = tre_compile_bm(preg, regex, n, cflags); + + /* Only try to compile heuristic if the fast matcher failed. */ + if (ret != REG_OK) + ret = tre_compile_heur(preg, regex, n, cflags); + else + preg->heur = NULL; + + /* When here, at least NFA surely succeeded. */ + return REG_OK; +} + +int +tre_compile_bm(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) +{ + fastmatch_t *shortcut; + int ret; + + if (n < 2) + goto too_short; + shortcut = xmalloc(sizeof(fastmatch_t)); + if (!shortcut) + return REG_ESPACE; + ret = (cflags & REG_LITERAL) + ? tre_proc_literal(shortcut, regex, n, cflags) + : tre_proc_fast(shortcut, regex, n, cflags); + if (ret == REG_OK) + { + preg->shortcut = shortcut; + DPRINT("tre_compile_bm: pattern compiled for fast matcher\n"); + } + else + { +too_short: + xfree(shortcut); + preg->shortcut = NULL; + DPRINT("tre_compile_bm: pattern compilation failed for fast matcher\n"); + } + return ret; +} + +int +tre_compile_heur(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) +{ + heur_t *heur; + int ret; + + heur = xmalloc(sizeof(heur_t)); + if (!heur) + return REG_ESPACE; + + ret = tre_proc_heur(heur, regex, n, cflags); + if (ret != REG_OK) + { + xfree(heur); + preg->heur = NULL; + DPRINT("tre_compile_heur: heuristic compilation failed, NFA will be used " + "entirely\n"); + } + else + { + preg->heur = heur; + DPRINT("tre_compile_heur: heuristic compiled to speed up the search\n"); + } + + return ret; +} + +int +tre_compile_nfa(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) +{ tre_stack_t *stack; tre_ast_node_t *tree, *tmp_ast_l, *tmp_ast_r; tre_pos_and_tags_t *p; int *counts = NULL, *offs = NULL; - int i, add = 0, ret; + int i, add = 0; tre_tnfa_transition_t *transitions, *initial; tre_tnfa_t *tnfa = NULL; tre_submatch_data_t *submatch_data; tre_tag_direction_t *tag_directions = NULL; reg_errcode_t errcode; tre_mem_t mem; - fastmatch_t *shortcut; - heur_t *heur; /* Parse context. */ tre_parse_ctx_t parse_ctx; - /* - * Check if we can cheat with a fixed string algorithm - * if the pattern is long enough. - */ - if (n >= 2) - { - shortcut = xmalloc(sizeof(fastmatch_t)); - if (!shortcut) - return REG_ESPACE; - ret = (cflags & REG_LITERAL) - ? tre_compile_literal(shortcut, regex, n, cflags) - : tre_compile_fast(shortcut, regex, n, cflags); - if (ret == REG_OK) - { - preg->shortcut = shortcut; - preg->re_nsub = 0; - DPRINT("tre_compile: pattern compiled for fast matcher\n"); - } - else - { - xfree(shortcut); - preg->shortcut = NULL; - DPRINT("tre_compile: pattern compilation failed for fast matcher\n"); - } - } - /* Allocate a stack used throughout the compilation process for various purposes. */ stack = tre_stack_new(512, 10240, 128); @@ -2008,7 +2066,7 @@ tre_compile(regex_t *preg, const tre_cha parse_ctx.len = n; parse_ctx.cflags = cflags; parse_ctx.max_backref = -1; - DPRINT(("tre_compile: parsing '%.*" STRF "'\n", (int)n, regex)); + DPRINT(("tre_compile_nfa: parsing '%.*" STRF "'\n", (int)n, regex)); errcode = tre_parse(&parse_ctx); if (errcode != REG_OK) ERROR_EXIT(errcode); @@ -2040,7 +2098,7 @@ tre_compile(regex_t *preg, const tre_cha regexp does not have back references, this can be skipped. */ if (tnfa->have_backrefs || !(cflags & REG_NOSUB)) { - DPRINT(("tre_compile: setting up tags\n")); + DPRINT(("tre_compile_nfa: setting up tags\n")); /* Figure out how many tags we will need. */ errcode = tre_add_tags(NULL, stack, tree, tnfa); @@ -2277,42 +2335,10 @@ tre_compile(regex_t *preg, const tre_cha preg->TRE_REGEX_T_FIELD = (void *)tnfa; - /* - * If we reach here, the regex is parsed and legal. Now we try to construct - * a heuristic to speed up matching if we do not already have a shortcut - * pattern. - */ - if (!preg->shortcut) - { - heur = xmalloc(sizeof(heur_t)); - if (!heur) - ERROR_EXIT(REG_ESPACE); - - ret = tre_compile_heur(heur, regex, n, cflags); - if (ret != REG_OK) - { - xfree(heur); - preg->heur = NULL; - DPRINT("tre_compile: heuristic compilation failed, NFA will be used " - "entirely\n"); - } - else - { - preg->heur = heur; - DPRINT("tre_compile: heuristic compiled to speed up the search\n"); - } - } - else - preg->heur = NULL; - return REG_OK; error_exit: /* Free everything that was allocated and return the error code. */ - if (shortcut != NULL) - xfree(shortcut); - if (heur != NULL) - xfree(heur); if (mem != NULL) tre_mem_destroy(mem); if (stack != NULL) Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.h Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.h Wed Feb 15 11:11:58 2012 (r231755) @@ -10,6 +10,8 @@ #ifndef TRE_COMPILE_H #define TRE_COMPILE_H 1 +#include + typedef struct { int position; int code_min; @@ -22,6 +24,13 @@ typedef struct { int *params; } tre_pos_and_tags_t; +int tre_compile_bm(regex_t *preg, const tre_char_t *regex, size_t n, + int cflags); +int tre_compile_heur(regex_t *preg, const tre_char_t *regex, size_t n, + int cflags); +int tre_compile_nfa(regex_t *preg, const tre_char_t *regex, size_t n, + int cflags); + #endif /* TRE_COMPILE_H */ /* EOF */ Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Feb 15 11:11:58 2012 (r231755) @@ -402,8 +402,8 @@ static int fastcmp(const fastmatch_t *fg * Returns: REG_OK on success, error code otherwise */ int -tre_compile_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, - int cflags) +tre_proc_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, + int cflags) { INIT_COMP; @@ -421,7 +421,7 @@ tre_compile_literal(fastmatch_t *fg, con SAVE_PATTERN(pat, n, fg->pattern, fg->len); #endif - DPRINT(("tre_compile_literal: pattern: %s, len %zu, icase: %c, word: %c, " + DPRINT(("tre_proc_literal: pattern: %s, len %zu, icase: %c, word: %c, " "newline %c\n", fg->pattern, fg->len, fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', fg->newline ? 'y' : 'n')); @@ -439,8 +439,8 @@ tre_compile_literal(fastmatch_t *fg, con * Returns: REG_OK on success, error code otherwise */ int -tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, - int cflags) +tre_proc_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, + int cflags) { tre_char_t *tmp; size_t pos = 0; @@ -563,7 +563,7 @@ tre_compile_fast(fastmatch_t *fg, const continue; badpat: xfree(tmp); - DPRINT(("tre_compile_fast: compilation of pattern failed, falling" + DPRINT(("tre_proc_fast: compilation of pattern failed, falling" "back to NFA\n")); return REG_BADPAT; } @@ -582,7 +582,7 @@ badpat: xfree(tmp); - DPRINT(("tre_compile_fast: pattern: %s, len %zu, bol %c, eol %c, " + DPRINT(("tre_proc_fast: pattern: %s, len %zu, bol %c, eol %c, " "icase: %c, word: %c, newline %c\n", fg->pattern, fg->len, fg->bol ? 'y' : 'n', fg->eol ? 'y' : 'n', fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Feb 15 11:11:58 2012 (r231755) @@ -9,9 +9,9 @@ #include "hashtable.h" #include "tre-internal.h" -int tre_compile_literal(fastmatch_t *preg, const tre_char_t *regex, +int tre_proc_literal(fastmatch_t *preg, const tre_char_t *regex, size_t, int); -int tre_compile_fast(fastmatch_t *preg, const tre_char_t *regex, size_t, int); +int tre_proc_fast(fastmatch_t *preg, const tre_char_t *regex, size_t, int); int tre_match_fast(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); void tre_free_fast(fastmatch_t *preg); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Wed Feb 15 11:11:58 2012 (r231755) @@ -124,7 +124,7 @@ * heuristic cannot be constructed. */ int -tre_compile_heur(heur_t *h, const tre_char_t *regex, size_t len, int cflags) +tre_proc_heur(heur_t *h, const tre_char_t *regex, size_t len, int cflags) { tre_char_t **arr, *heur; tre_char_t **farr; @@ -513,7 +513,7 @@ ok: errcode = REG_ESPACE; goto err; } - ret = tre_compile_literal(h->heurs[i], farr[i], fsiz[i], 0); + ret = tre_proc_literal(h->heurs[i], farr[i], fsiz[i], 0); if (ret != REG_OK) { errcode = REG_BADPAT; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Wed Feb 15 10:33:29 2012 (r231754) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Wed Feb 15 11:11:58 2012 (r231755) @@ -23,8 +23,8 @@ typedef struct { int type; } heur_t; -extern int tre_compile_heur(heur_t *h, const tre_char_t *regex, - size_t len, int cflags); +extern int tre_proc_heur(heur_t *h, const tre_char_t *regex, + size_t len, int cflags); extern void tre_free_heur(heur_t *h); #endif /* TRE_HEURISTIC_H */ From owner-svn-src-user@FreeBSD.ORG Wed Feb 15 21:48:29 2012 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 E1A2A106566C; Wed, 15 Feb 2012 21:48:29 +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 C54318FC0C; Wed, 15 Feb 2012 21:48:29 +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 q1FLmTef083242; Wed, 15 Feb 2012 21:48:29 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1FLmTbK083232; Wed, 15 Feb 2012 21:48:29 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202152148.q1FLmTbK083232@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 15 Feb 2012 21:48:29 +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: r231782 - 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: Wed, 15 Feb 2012 21:48:30 -0000 Author: gabor Date: Wed Feb 15 21:48:29 2012 New Revision: 231782 URL: http://svn.freebsd.org/changeset/base/231782 Log: - Provide MBS patterns to lower layers for better flexibility and avoid converting back and forth. Except with calculated results where it is probably cheaper to convert back than calculating the same in MBS. - Fix a bug in converting back calculated heuristics to MBS. Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/mregcomp.c user/gabor/tre-integration/contrib/tre/lib/regcomp.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.h user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Feb 15 21:48:29 2012 (r231782) @@ -47,12 +47,12 @@ tre_fixncomp(fastmatch_t *preg, const ch if (n != 0) { - ret = tre_convert_pattern(regex, n, &wregex, &wlen); + ret = tre_convert_pattern_to_wcs(regex, n, &wregex, &wlen); if (ret != REG_OK) return ret; else ret = tre_proc_literal(preg, wregex, wlen, cflags); - tre_free_pattern(wregex); + tre_free_wcs_pattern(wregex); return ret; } else @@ -68,14 +68,14 @@ tre_fastncomp(fastmatch_t *preg, const c if (n != 0) { - ret = tre_convert_pattern(regex, n, &wregex, &wlen); + ret = tre_convert_pattern_to_wcs(regex, n, &wregex, &wlen); if (ret != REG_OK) return ret; else ret = (cflags & REG_LITERAL) ? tre_proc_literal(preg, wregex, wlen, cflags) : tre_proc_fast(preg, wregex, wlen, cflags); - tre_free_pattern(wregex); + tre_free_wcs_pattern(wregex); return ret; } else Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Wed Feb 15 21:48:29 2012 (r231782) @@ -80,7 +80,7 @@ tre_mregncomp(mregex_t *preg, size_t nr, for (i = 0; i++; i < nr) { - ret = tre_convert_pattern(regex[i], n[i], &wregex[i], &wlen[i]); + ret = tre_convert_pattern_to_wcs(regex[i], n[i], &wregex[i], &wlen[i]); if (ret != REG_OK) goto fail; } @@ -89,7 +89,7 @@ tre_mregncomp(mregex_t *preg, size_t nr, fail: for (int j = 0; j++; j < i) - tre_free_pattern(wregex[j]); + tre_free_wcs_pattern(wregex[j]); return ret; } @@ -117,7 +117,30 @@ int tre_mregwncomp(mregex_t *preg, size_t nr, const wchar_t *regex[], size_t n[], int cflags) { - return tre_compile(preg, nr, regex, n, cflags); + int i, ret; + char **sregex; + size_t *slen; + + sregex = xmalloc(nr * sizeof(char *); + if (!sregex) + return REG_ENOMEM; + slen = xmalloc(nr * sizeof(size_t); + if (!slen) + return REG_ENOMEM; + + for (i = 0; i++; i < nr) + { + ret = tre_convert_pattern_to_mbs(regex[i], n[i], &sregex[i], &slen[i]); + if (ret != REG_OK) + goto fail; + } + + ret = tre_mcompile(preg, nr, regex, n, cflags); + +fail: + for (int j = 0; j++; j < i) + tre_free_mbs_pattern(wregex[j]); + return ret; } int Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Wed Feb 15 21:48:29 2012 (r231782) @@ -35,12 +35,12 @@ tre_regncomp(regex_t *preg, const char * tre_char_t *wregex; size_t wlen; - ret = tre_convert_pattern(regex, n, &wregex, &wlen); + ret = tre_convert_pattern_to_wcs(regex, n, &wregex, &wlen); if (ret != REG_OK) return ret; else - ret = tre_compile(preg, wregex, wlen, cflags); - tre_free_pattern(wregex); + ret = tre_compile(preg, wregex, wlen, regex, n, cflags); + tre_free_wcs_pattern(wregex); return ret; } @@ -58,16 +58,26 @@ tre_regcomp(regex_t *preg, const char *r int tre_regwncomp(regex_t *preg, const wchar_t *regex, size_t n, int cflags) { - return tre_compile(preg, regex, n, cflags); + int ret; + char *sregex; + size_t slen; + + ret = tre_convert_pattern_to_mbs(regex, n, &sregex, &slen); + if (ret != REG_OK) + return ret; + else + ret = tre_compile(preg, regex, n, sregex, slen, cflags); + tre_free_mbs_pattern(sregex); + return ret; } int tre_regwcomp(regex_t *preg, const wchar_t *regex, int cflags) { if ((cflags & REG_PEND) && (preg->re_wendp >= regex)) - return tre_compile(preg, regex, preg->re_wendp - regex, cflags); + return tre_regwncomp(preg, regex, preg->re_wendp - regex, cflags); else - return tre_compile(preg, regex, regex ? wcslen(regex) : 0, cflags); + return tre_regwncomp(preg, regex, regex ? wcslen(regex) : 0, cflags); } #endif /* TRE_WCHAR */ Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Feb 15 21:48:29 2012 (r231782) @@ -1844,8 +1844,8 @@ tre_ast_to_tnfa(tre_ast_node_t *node, tr } int -tre_convert_pattern(const char *regex, size_t n, tre_char_t **w, - size_t *wn) +tre_convert_pattern_to_wcs(const char *regex, size_t n, tre_char_t **w, + size_t *wn) { #if TRE_WCHAR tre_char_t *wregex; @@ -1926,14 +1926,50 @@ tre_convert_pattern(const char *regex, s #endif /* !TRE_WCHAR */ } +int +tre_convert_pattern_to_mbs(const tre_char_t *wregex, size_t n, char **s, + size_t *sn) +{ +#ifdef TRE_WCHAR + size_t siz; + char *mbs; + + siz = wcstombs(NULL, wregex, 0); + if (siz == (size_t)-1) + return REG_BADPAT; + + mbs = xmalloc(siz + 1); + if (!mbs) + return REG_ESPACE; + + wcstombs(mbs, wregex, siz); + mbs[siz] = '\0'; + *s = mbs; + *sn = siz; + return REG_OK; +#else /* !TRE_WCHAR */ + *s = (char * const *)wregex; + *sn = n; + return REG_OK; +#endif +} + void -tre_free_pattern(tre_char_t *wregex) +tre_free_wcs_pattern(tre_char_t *wregex) { #if TRE_WCHAR xfree(wregex); #endif } +void +tre_free_mbs_pattern(char *regex) +{ +#if TRE_WCHAR + xfree(regex); +#endif +} + #define ERROR_EXIT(err) \ do \ { \ @@ -1945,7 +1981,8 @@ tre_free_pattern(tre_char_t *wregex) int -tre_compile(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) +tre_compile(regex_t *preg, const tre_char_t *wregex, size_t wn, + const char *regex, size_t n, int cflags) { int ret; @@ -1954,7 +1991,7 @@ tre_compile(regex_t *preg, const tre_cha * pattern validation. In this way, validation is not * scattered through the code. */ - ret = tre_compile_nfa(preg, regex, n, cflags); + ret = tre_compile_nfa(preg, wregex, wn, cflags); if (ret != REG_OK) return ret; @@ -1962,11 +1999,11 @@ tre_compile(regex_t *preg, const tre_cha * Check if we can cheat with a fixed string algorithm * if the pattern is long enough. */ - ret = tre_compile_bm(preg, regex, n, cflags); + ret = tre_compile_bm(preg, wregex, wn, regex, n, cflags); /* Only try to compile heuristic if the fast matcher failed. */ if (ret != REG_OK) - ret = tre_compile_heur(preg, regex, n, cflags); + ret = tre_compile_heur(preg, wregex, wn, cflags); else preg->heur = NULL; @@ -1975,7 +2012,8 @@ tre_compile(regex_t *preg, const tre_cha } int -tre_compile_bm(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) +tre_compile_bm(regex_t *preg, const tre_char_t *wregex, size_t wn, + const char *regex, size_t n, int cflags) { fastmatch_t *shortcut; int ret; @@ -1986,8 +2024,8 @@ tre_compile_bm(regex_t *preg, const tre_ if (!shortcut) return REG_ESPACE; ret = (cflags & REG_LITERAL) - ? tre_proc_literal(shortcut, regex, n, cflags) - : tre_proc_fast(shortcut, regex, n, cflags); + ? tre_proc_literal(shortcut, wregex, wn, regex, n, cflags) + : tre_proc_fast(shortcut, wregex, wn, regex, n, cflags); if (ret == REG_OK) { preg->shortcut = shortcut; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.h Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.h Wed Feb 15 21:48:29 2012 (r231782) @@ -24,8 +24,8 @@ typedef struct { int *params; } tre_pos_and_tags_t; -int tre_compile_bm(regex_t *preg, const tre_char_t *regex, size_t n, - int cflags); +int tre_compile_bm(regex_t *preg, const tre_char_t *wregex, size_t wn, + const char *regex, size_t n, int cflags); int tre_compile_heur(regex_t *preg, const tre_char_t *regex, size_t n, int cflags); int tre_compile_nfa(regex_t *preg, const tre_char_t *regex, size_t n, Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Feb 15 21:48:29 2012 (r231782) @@ -344,13 +344,13 @@ static int fastcmp(const fastmatch_t *fg * Copies the pattern pat having lenght n to p and stores * the size in l. */ -#define SAVE_PATTERN(src, srclen, dst, dstlen) \ +#define SAVE_PATTERN(src, srclen, dst, dstlen, l) \ dstlen = srclen; \ - dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ + dst = xmalloc((dstlen + 1) * sizeof(l)); \ if (dst == NULL) \ return REG_ESPACE; \ if (dstlen > 0) \ - memcpy(dst, src, dstlen * sizeof(tre_char_t)); \ + memcpy(dst, src, dstlen * sizeof(l)); \ dst[dstlen] = TRE_CHAR('\0'); /* @@ -402,8 +402,8 @@ static int fastcmp(const fastmatch_t *fg * Returns: REG_OK on success, error code otherwise */ int -tre_proc_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, - int cflags) +tre_proc_literal(fastmatch_t *fg, const tre_char_t *wpat, size_t wn, + const char *pat, size_t n, int cflags) { INIT_COMP; @@ -415,10 +415,10 @@ tre_proc_literal(fastmatch_t *fg, const return REG_BADPAT; #ifdef TRE_WCHAR - SAVE_PATTERN(pat, n, fg->wpattern, fg->wlen); - STORE_MBS_PAT; + SAVE_PATTERN(wpat, wn, fg->wpattern, fg->wlen, tre_char_t); + SAVE_PATTERN(pat, n, fg->pattern, fg->len, char); #else - SAVE_PATTERN(pat, n, fg->pattern, fg->len); + SAVE_PATTERN(pat, n, fg->pattern, fg->len, char); #endif DPRINT(("tre_proc_literal: pattern: %s, len %zu, icase: %c, word: %c, " @@ -439,8 +439,8 @@ tre_proc_literal(fastmatch_t *fg, const * Returns: REG_OK on success, error code otherwise */ int -tre_proc_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, - int cflags) +tre_proc_fast(fastmatch_t *fg, const tre_char_t *wpat, size_t wn, + const char *pat, size_t n, int cflags) { tre_char_t *tmp; size_t pos = 0; @@ -449,23 +449,23 @@ tre_proc_fast(fastmatch_t *fg, const tre INIT_COMP; /* Remove beginning-of-line character ('^'). */ - if (pat[0] == TRE_CHAR('^')) + if (wpat[0] == TRE_CHAR('^')) { fg->bol = true; - n--; - pat++; + wn--; + wpat++; } CHECK_MATCHALL(false); /* Handle word-boundary matching when GNU extensions are enabled */ - if ((cflags & REG_GNU) && (n >= 14) && - (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && - (memcmp(pat + n - 7, TRE_CHAR("[[:>:]]"), + if ((cflags & REG_GNU) && (wn >= 14) && + (memcmp(wpat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && + (memcmp(wpat + wn - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) { - n -= 14; - pat += 7; + wn -= 14; + wpat += 7; fg->word = true; } @@ -473,7 +473,7 @@ tre_proc_fast(fastmatch_t *fg, const tre if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; - tmp = xmalloc((n + 1) * sizeof(tre_char_t)); + tmp = xmalloc((wn + 1) * sizeof(tre_char_t)); if (tmp == NULL) return REG_ESPACE; @@ -481,15 +481,15 @@ tre_proc_fast(fastmatch_t *fg, const tre #define STORE_CHAR \ do \ { \ - tmp[pos++] = pat[i]; \ + tmp[pos++] = wpat[i]; \ escaped = false; \ continue; \ } while (0) /* Traverse the input pattern for processing */ - for (unsigned int i = 0; i < n; i++) + for (unsigned int i = 0; i < wn; i++) { - switch (pat[i]) + switch (wpat[i]) { case TRE_CHAR('\\'): if (escaped) @@ -574,10 +574,12 @@ badpat: * classes stripped out. */ #ifdef TRE_WCHAR - SAVE_PATTERN(tmp, pos, fg->wpattern, fg->wlen); + SAVE_PATTERN(tmp, pos, fg->wpattern, fg->wlen, tre_char_t); + + /* Convert back to MBS instead of processing again */ STORE_MBS_PAT; #else - SAVE_PATTERN(tmp, pos, fg->pattern, fg->len); + SAVE_PATTERN(tmp, pos, fg->pattern, fg->len, char); #endif xfree(tmp); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Feb 15 21:48:29 2012 (r231782) @@ -9,9 +9,10 @@ #include "hashtable.h" #include "tre-internal.h" -int tre_proc_literal(fastmatch_t *preg, const tre_char_t *regex, - size_t, int); -int tre_proc_fast(fastmatch_t *preg, const tre_char_t *regex, size_t, int); +int tre_proc_literal(fastmatch_t *, const tre_char_t *, size_t, + const char *, size_t, int); +int tre_proc_fast(fastmatch_t *, const tre_char_t *, size_t, + const char *, size_t, int); int tre_match_fast(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); void tre_free_fast(fastmatch_t *preg); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Wed Feb 15 21:48:29 2012 (r231782) @@ -475,14 +475,14 @@ ok: for (i = 0; farr[i] != NULL; i++) { - bsiz[i] = mbstowcs(farr[i], NULL, 0); + bsiz[i] = wcstombs(NULL, farr[i], 0); barr[i] = xmalloc(bsiz[i] + 1); if (!barr[i]) { errcode = REG_ESPACE; goto err; } - mbstowcs(farr[i], barr[i], bsiz[i]); + wcstombs(barr[i], farr[i], bsiz[i]); barr[i][bsiz[i]] = '\0'; } barr[i] = NULL; @@ -513,7 +513,13 @@ ok: errcode = REG_ESPACE; goto err; } - ret = tre_proc_literal(h->heurs[i], farr[i], fsiz[i], 0); +#ifdef TRE_WCHAR + ret = tre_proc_literal(h->heurs[i], farr[i], fsiz[i], + barr[i], bsiz[i], 0); +#else + ret = tre_proc_literal(h->heurs[i], farr[i], fsiz[i], + farr[i], fsiz[i], 0); +#endif if (ret != REG_OK) { errcode = REG_BADPAT; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-internal.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Wed Feb 15 21:32:05 2012 (r231781) +++ user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Wed Feb 15 21:48:29 2012 (r231782) @@ -277,14 +277,22 @@ struct tnfa { } while (0 /*CONSTCOND*/) int -tre_convert_pattern(const char *regex, size_t n, tre_char_t **w, - size_t *wn); +tre_convert_pattern_to_wcs(const char *regex, size_t n, tre_char_t **w, + size_t *wn); void -tre_free_pattern(tre_char_t *wregex); +tre_free_wcs_pattern(tre_char_t *wregex); int -tre_compile(regex_t *preg, const tre_char_t *regex, size_t n, int cflags); +tre_convert_pattern_to_mbs(const tre_char_t *wregex, size_t n, char **s, + size_t *sn); + +void +tre_free_mbs_pattern(char *wregex); + +int +tre_compile(regex_t *preg, const tre_char_t *wregex, size_t wn, + const char *regex, size_t n, int cflags); void tre_free(regex_t *preg); From owner-svn-src-user@FreeBSD.ORG Wed Feb 15 22:26:52 2012 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 58ED1106564A; Wed, 15 Feb 2012 22:26:52 +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 4785F8FC0C; Wed, 15 Feb 2012 22:26:52 +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 q1FMQq7q084937; Wed, 15 Feb 2012 22:26:52 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1FMQqRr084934; Wed, 15 Feb 2012 22:26:52 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202152226.q1FMQqRr084934@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 15 Feb 2012 22:26:52 +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: r231788 - in user/gabor/tre-integration: contrib/tre/lib include lib/libc/regex 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: Wed, 15 Feb 2012 22:26:52 -0000 Author: gabor Date: Wed Feb 15 22:26:51 2012 New Revision: 231788 URL: http://svn.freebsd.org/changeset/base/231788 Log: - Axe out unused interface Deleted: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/include/fastmatch.h Modified: user/gabor/tre-integration/include/Makefile user/gabor/tre-integration/lib/libc/regex/Makefile.inc Modified: user/gabor/tre-integration/include/Makefile ============================================================================== --- user/gabor/tre-integration/include/Makefile Wed Feb 15 22:10:33 2012 (r231787) +++ user/gabor/tre-integration/include/Makefile Wed Feb 15 22:26:51 2012 (r231788) @@ -9,7 +9,7 @@ CLEANFILES= osreldate.h version vers.c SUBDIR= arpa gssapi protocols rpcsvc rpc INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \ db.h \ - dirent.h dlfcn.h elf.h elf-hints.h err.h fastmatch.h fmtmsg.h fnmatch.h \ + dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h \ fstab.h fts.h ftw.h getopt.h glob.h grp.h gssapi.h \ ieeefp.h ifaddrs.h \ inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \ Modified: user/gabor/tre-integration/lib/libc/regex/Makefile.inc ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/Makefile.inc Wed Feb 15 22:10:33 2012 (r231787) +++ user/gabor/tre-integration/lib/libc/regex/Makefile.inc Wed Feb 15 22:26:51 2012 (r231788) @@ -5,7 +5,7 @@ CFLAGS+=-DHAVE_CONFIG_H -DTRE_LIBC_BUILD -I${.CURDIR}/../../contrib/tre -SRCS+= fastmatch.c hashtable.c regcomp.c regerror.c regexec.c tre-ast.c \ +SRCS+= hashtable.c regcomp.c regerror.c regexec.c tre-ast.c \ tre-compile.c tre-fastmatch.c tre-heuristic.c tre-match-approx.c \ tre-match-backtrack.c tre-match-parallel.c tre-mem.c tre-parse.c \ tre-stack.c xmalloc.c From owner-svn-src-user@FreeBSD.ORG Thu Feb 16 14:54:20 2012 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 BB458106564A; Thu, 16 Feb 2012 14:54:20 +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 A5D5D8FC12; Thu, 16 Feb 2012 14:54:20 +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 q1GEsK8c021531; Thu, 16 Feb 2012 14:54:20 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1GEsKTN021528; Thu, 16 Feb 2012 14:54:20 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202161454.q1GEsKTN021528@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 16 Feb 2012 14:54:20 +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: r231824 - in user/gabor/tre-integration: contrib/tre/lib include 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, 16 Feb 2012 14:54:20 -0000 Author: gabor Date: Thu Feb 16 14:54:20 2012 New Revision: 231824 URL: http://svn.freebsd.org/changeset/base/231824 Log: - Take wmsearch_t instead of mregex_t because the fields of the latter belong to higher level code - In mregex_t, it is necessary to store the number of fragments that will be used for multiple pattern heuristic matching Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c user/gabor/tre-integration/include/mregex.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Thu Feb 16 14:44:52 2012 (r231823) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Thu Feb 16 14:54:20 2012 (r231824) @@ -167,11 +167,10 @@ */ int -tre_wmcomp(mregex_t *preg, size_t nr, const char *regex[], +tre_wmcomp(wmsearch_t *wm, size_t nr, const tre_char_t *regex[], size_t n[], int cflags) { wmentry_t *entry = NULL; - wmsearch_t *wm = NULL; int err; #ifdef TRE_WCHAR char **bregex; @@ -179,7 +178,6 @@ tre_wmcomp(mregex_t *preg, size_t nr, co #endif ALLOC(wm, sizeof(wmsearch_t)); - preg->n = nr; #ifdef TRE_WCHAR PROC_WM_WIDE(regex, n); @@ -216,7 +214,6 @@ tre_wmcomp(mregex_t *preg, size_t nr, co SAVE_PATTERNS; #endif - preg->searchdata = &wm; return REG_OK; fail: #ifdef TRE_WCHAR @@ -295,13 +292,12 @@ fail: int tre_wmexec(const void *str, size_t len, tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], int eflags, - const mregex_t *preg, regmatch_t *match) + const wmsearch_t *wm, regmatch_t *match) { - wmsearch_t *wm = preg->wm; wmentry_t *s_entry, *p_entry; tre_char_t *wide_str = str; char *byte_str = str; - size_t pos = preg->m; + size_t pos = (type == STR_WIDE) ? wm->wm : wm->m; size_t shift; int ret; int err = REG_NOMATCH; @@ -327,9 +323,8 @@ finish: } void -wmfree(mregex_t *preg) +tre_wmfree(wmsearch_t *wm) { - wmsearch_t wm = preg->wm; if (wm->hash) hashtable_free(wm->hash); Modified: user/gabor/tre-integration/include/mregex.h ============================================================================== --- user/gabor/tre-integration/include/mregex.h Thu Feb 16 14:44:52 2012 (r231823) +++ user/gabor/tre-integration/include/mregex.h Thu Feb 16 14:54:20 2012 (r231824) @@ -8,6 +8,7 @@ typedef struct { size_t k; /* Number of patterns */ regex_t *patterns; /* regex_t structure for each pattern */ + size_t mfrag; /* Number of fragments */ void *searchdata; } mregex_t; From owner-svn-src-user@FreeBSD.ORG Thu Feb 16 14:54:51 2012 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 DD696106566B; Thu, 16 Feb 2012 14:54:51 +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 AE11F8FC18; Thu, 16 Feb 2012 14:54:51 +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 q1GEsp2M021581; Thu, 16 Feb 2012 14:54:51 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1GEspfa021579; Thu, 16 Feb 2012 14:54:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202161454.q1GEspfa021579@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 16 Feb 2012 14:54:51 +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: r231825 - 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, 16 Feb 2012 14:54:51 -0000 Author: gabor Date: Thu Feb 16 14:54:51 2012 New Revision: 231825 URL: http://svn.freebsd.org/changeset/base/231825 Log: - Implement compilation of multiple patterns for heuristic matching Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Thu Feb 16 14:54:20 2012 (r231824) +++ user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Thu Feb 16 14:54:51 2012 (r231825) @@ -48,19 +48,88 @@ __weak_reference(tre_mregfree, mregfree) /* TODO: * - * - compilation * - REG_ICASE * - Test */ int -tre_mcompile(mregex_t *preg, size_t nr, const char *regex[], - size_t n[], int cflags) +tre_mcompile(mregex_t *preg, size_t nr, const tre_char_t *wregex[], + size_t wn[], int cflags) { + int ret; + size_t mfrag = 0; + tre_char_t **frags; + size_t *siz; + wmsearch_t *wm; + + preg->k = nr; + preg->patterns = xmalloc(nr * sizeof(regex_t)); + if (!preg->patterns) + return REG_ESPACE; + + for (int i = 0; i < nr; i++) + { + ret = tre_compile_nfa(&preg->patterns[i], wregex[i], wn[i], cflags); + if (ret != REG_OK) + goto err; + ret = tre_compile_heur(&preg->patterns[i], wregex[i], wn[i], cflags); + if (ret != REG_OK) + goto err; + } + + for (mfrag = 0; mfrag < nr; mfrag++) + for (int j = 0; j < nr; j++) + if (((heur_t)preg->patterns[j]->heur)->arr[mfrag] == NULL) + goto out; +out: + + preg->mfrag = mfrag; + + /* Worst case, not all patterns have a literal prefix */ + if (mfrag == 0) + return REG_OK; + + wm = xmalloc(mfrag * sizeof(wmsearch_t)); + if (!wm) + goto err; + + frags = xmalloc(nr * sizeof(char *)); + if (!frags) + goto err; + + siz = xmalloc(nr * sizeof(size_t)); + // XXX: check NULL - // TODO: Get heuristics and then use Wu-Manber + for (int i = 0; i < mfrag; i++) + { + for (int j = 0; j < nr; j++) + { + frags[j] = &((heur_t)preg->patterns[j]->heur)->arr[i]; + siz[j] = ((heur_t)preg->patterns[j]->heur)->siz[i]; + } + ret = tre_wmcomp(&wm[i], nr, frags, siz, cflags); + if (ret != REG_OK) + goto err; + } + + preg->searchdata = wm; return REG_OK; + +err: + if (preg->patterns) + xfree(preg->patterns); + if (wm) + { + for (int i = 0; i < mfrag; i++) + tre_wmfree(&wm[i]); + xfree(wm); + } + if (frags) + xfree(frags); + if (siz) + xfree(siz); + return ret; } int From owner-svn-src-user@FreeBSD.ORG Fri Feb 17 11:47:19 2012 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 26DC0106566B; Fri, 17 Feb 2012 11:47:19 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF1938FC13; Fri, 17 Feb 2012 11:47:18 +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 q1HBlIJW076895; Fri, 17 Feb 2012 11:47:18 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1HBlIDj076894; Fri, 17 Feb 2012 11:47:18 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <201202171147.q1HBlIDj076894@svn.freebsd.org> From: Brooks Davis Date: Fri, 17 Feb 2012 11:47:18 +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: r231872 - user/brooks/tchacks 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: Fri, 17 Feb 2012 11:47:19 -0000 Author: brooks Date: Fri Feb 17 11:47:18 2012 New Revision: 231872 URL: http://svn.freebsd.org/changeset/base/231872 Log: Create a branch for build system work in progress. Added: - copied from r231871, head/ Directory Properties: user/brooks/tchacks/ (props changed) From owner-svn-src-user@FreeBSD.ORG Fri Feb 17 13:22:00 2012 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 034B0106566C; Fri, 17 Feb 2012 13:22:00 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E36B28FC08; Fri, 17 Feb 2012 13:21:59 +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 q1HDLxvW079861; Fri, 17 Feb 2012 13:21:59 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1HDLxiZ079859; Fri, 17 Feb 2012 13:21:59 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <201202171321.q1HDLxiZ079859@svn.freebsd.org> From: Brooks Davis Date: Fri, 17 Feb 2012 13:21:59 +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: r231874 - user/brooks/tchacks/usr.sbin/wpa/hostapd 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: Fri, 17 Feb 2012 13:22:00 -0000 Author: brooks Date: Fri Feb 17 13:21:59 2012 New Revision: 231874 URL: http://svn.freebsd.org/changeset/base/231874 Log: At least with ld from binutils hostapd does depend on symbols in libcrypto. Modified: user/brooks/tchacks/usr.sbin/wpa/hostapd/Makefile Modified: user/brooks/tchacks/usr.sbin/wpa/hostapd/Makefile ============================================================================== --- user/brooks/tchacks/usr.sbin/wpa/hostapd/Makefile Fri Feb 17 12:40:27 2012 (r231873) +++ user/brooks/tchacks/usr.sbin/wpa/hostapd/Makefile Fri Feb 17 13:21:59 2012 (r231874) @@ -47,7 +47,7 @@ CFLAGS+= -DCONFIG_IPV6 .endif #CFLAGS+= -g DPADD+= ${LIBPCAP} ${LIBSSL} -LDADD+= -lpcap -lssl +LDADD+= -lpcap -lssl -lcrypto # User customizations for wpa_supplicant/hostapd build environment CFLAGS+=${HOSTAPD_CFLAGS} From owner-svn-src-user@FreeBSD.ORG Fri Feb 17 13:24:29 2012 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 17053106566C; Fri, 17 Feb 2012 13:24:29 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 026118FC16; Fri, 17 Feb 2012 13:24:29 +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 q1HDOSsj079979; Fri, 17 Feb 2012 13:24:28 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1HDOSqe079976; Fri, 17 Feb 2012 13:24:28 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <201202171324.q1HDOSqe079976@svn.freebsd.org> From: Brooks Davis Date: Fri, 17 Feb 2012 13:24: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: r231875 - in user/brooks/tchacks: gnu/lib/libssp lib/libbsnmp/libbsnmp 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: Fri, 17 Feb 2012 13:24:29 -0000 Author: brooks Date: Fri Feb 17 13:24:28 2012 New Revision: 231875 URL: http://svn.freebsd.org/changeset/base/231875 Log: Make linker warnings non-fatal to avoid errors when linking with ld from binutils 2.22. It's not clear to me why we don't get errors during cross build with the normal linker. Modified: user/brooks/tchacks/gnu/lib/libssp/Makefile user/brooks/tchacks/lib/libbsnmp/libbsnmp/Makefile Modified: user/brooks/tchacks/gnu/lib/libssp/Makefile ============================================================================== --- user/brooks/tchacks/gnu/lib/libssp/Makefile Fri Feb 17 13:21:59 2012 (r231874) +++ user/brooks/tchacks/gnu/lib/libssp/Makefile Fri Feb 17 13:24:28 2012 (r231875) @@ -36,3 +36,6 @@ ssp.h: ssp.h.in SUBDIR+= libssp_nonshared .include + +# Code users gets() so don't let linker warnings be fatal. +SOLINKOPTS+= -Wl,--no-fatal-warnings Modified: user/brooks/tchacks/lib/libbsnmp/libbsnmp/Makefile ============================================================================== --- user/brooks/tchacks/lib/libbsnmp/libbsnmp/Makefile Fri Feb 17 13:21:59 2012 (r231874) +++ user/brooks/tchacks/lib/libbsnmp/libbsnmp/Makefile Fri Feb 17 13:24:28 2012 (r231875) @@ -23,3 +23,6 @@ INCS= asn1.h snmp.h snmpagent.h snmpclie MAN= asn1.3 bsnmplib.3 bsnmpclient.3 bsnmpagent.3 .include + +# Code uses mktemp() so don't let linker warnings be fatal. +SOLINKOPTS+= -Wl,--no-fatal-warnings From owner-svn-src-user@FreeBSD.ORG Fri Feb 17 13:26:29 2012 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 D890B106566B; Fri, 17 Feb 2012 13:26:29 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C4B718FC0A; Fri, 17 Feb 2012 13:26:29 +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 q1HDQTjR080073; Fri, 17 Feb 2012 13:26:29 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1HDQT1X080069; Fri, 17 Feb 2012 13:26:29 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <201202171326.q1HDQT1X080069@svn.freebsd.org> From: Brooks Davis Date: Fri, 17 Feb 2012 13:26:29 +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: r231876 - in user/brooks/tchacks: . share/mk 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: Fri, 17 Feb 2012 13:26:30 -0000 Author: brooks Date: Fri Feb 17 13:26:29 2012 New Revision: 231876 URL: http://svn.freebsd.org/changeset/base/231876 Log: Introduce a new variable, TCPATH which overrides other path elements during a full world build. This allows portions of the toolchain to be replaced with external components. It has been tested with cc, c++, nm, and ld replaced. TCPATH is used by installed the tools you with to use under their common names and then building world with a command like: make TCPATH=/tmp/tc buildworld TCPATH support depends on the ability to call cc/c++ with --sysroot which in turn requires that the linker the compiler users (hard coded at compile time) also support --sysroot. In the case of GNU ld this is non-default. You can produce a linker that works exactly like normal but also supports --sysroot by building binutils with the configure argument "--with-sysroot=/". The current patch is quite inefficient. It still builds all crossbuild tools including copies of gcc and clang. A more efficient and selective approach is certainly possible. Modified: user/brooks/tchacks/Makefile.inc1 user/brooks/tchacks/share/mk/bsd.dep.mk user/brooks/tchacks/share/mk/sys.mk Modified: user/brooks/tchacks/Makefile.inc1 ============================================================================== --- user/brooks/tchacks/Makefile.inc1 Fri Feb 17 13:24:28 2012 (r231875) +++ user/brooks/tchacks/Makefile.inc1 Fri Feb 17 13:26:29 2012 (r231876) @@ -180,7 +180,11 @@ WORLDTMP= ${OBJTREE}${.CURDIR}/tmp BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games STRICTTMPPATH= ${BPATH}:${XPATH} +.if defined(TCPATH) +TMPPATH= ${TCPATH}:${STRICTTMPPATH}:${PATH} +.else TMPPATH= ${STRICTTMPPATH}:${PATH} +.endif # # Avoid running mktemp(1) unless actually needed. @@ -272,6 +276,9 @@ WMAKEENV= ${CROSSENV} \ WMAKEENV+= NO_CTF=1 .endif WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP} +.if defined(TCPATH) +WMAKE+= SYSROOT=${WORLDTMP} +.endif .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" # 32 bit world Modified: user/brooks/tchacks/share/mk/bsd.dep.mk ============================================================================== --- user/brooks/tchacks/share/mk/bsd.dep.mk Fri Feb 17 13:24:28 2012 (r231875) +++ user/brooks/tchacks/share/mk/bsd.dep.mk Fri Feb 17 13:26:29 2012 (r231876) @@ -125,8 +125,8 @@ depend: beforedepend ${DEPENDFILE} after # Different types of sources are compiled with slightly different flags. # Split up the sources, and filter out headers and non-applicable flags. -MKDEP_CFLAGS= ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BIDU]*} ${CFLAGS:M-std=*} ${CFLAGS:M-ansi} -MKDEP_CXXFLAGS= ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BIDU]*} ${CXXFLAGS:M-std=*} ${CXXFLAGS:M-ansi} +MKDEP_CFLAGS= ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BIDU]*} ${CFLAGS:M-std=*} ${CFLAGS:M-ansi} ${CFLAGS:M--sysroot*} +MKDEP_CXXFLAGS= ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BIDU]*} ${CXXFLAGS:M-std=*} ${CXXFLAGS:M-ansi} ${CFLAGS:M--sysroot*} DPSRCS+= ${SRCS} ${DEPENDFILE}: ${DPSRCS} Modified: user/brooks/tchacks/share/mk/sys.mk ============================================================================== --- user/brooks/tchacks/share/mk/sys.mk Fri Feb 17 13:24:28 2012 (r231875) +++ user/brooks/tchacks/share/mk/sys.mk Fri Feb 17 13:26:29 2012 (r231876) @@ -53,6 +53,9 @@ CFLAGS ?= -O -pipe .else CFLAGS ?= -O2 -pipe .endif +.if defined(SYSROOT) +CFLAGS += --sysroot=${SYSROOT} +.endif .if defined(NO_STRICT_ALIASING) CFLAGS += -fno-strict-aliasing .endif From owner-svn-src-user@FreeBSD.ORG Fri Feb 17 15:31:06 2012 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 E173E1065670; Fri, 17 Feb 2012 15:31:06 +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 CCABD8FC13; Fri, 17 Feb 2012 15:31:06 +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 q1HFV6iE084513; Fri, 17 Feb 2012 15:31:06 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1HFV6hX084510; Fri, 17 Feb 2012 15:31:06 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202171531.q1HFV6hX084510@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 17 Feb 2012 15:31:06 +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: r231882 - 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: Fri, 17 Feb 2012 15:31:07 -0000 Author: gabor Date: Fri Feb 17 15:31:06 2012 New Revision: 231882 URL: http://svn.freebsd.org/changeset/base/231882 Log: - Move a macro definition to the header file Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Fri Feb 17 14:09:04 2012 (r231881) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Fri Feb 17 15:31:06 2012 (r231882) @@ -54,8 +54,6 @@ * performance impact. */ -#define MAX_FRAGMENTS 32 - /* * Parses bracket expression seeking to the end of the enclosed text. * The parameters are the opening (oe) and closing elements (ce). Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Fri Feb 17 14:09:04 2012 (r231881) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Fri Feb 17 15:31:06 2012 (r231882) @@ -7,6 +7,8 @@ #include "tre-fastmatch.h" #include "tre-internal.h" +#define MAX_FRAGMENTS 32 + #define HEUR_ARRAY 0 #define HEUR_PREFIX_ARRAY 1 #define HEUR_LONGEST 2 From owner-svn-src-user@FreeBSD.ORG Fri Feb 17 22:40:52 2012 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 B4802106566B; Fri, 17 Feb 2012 22:40:52 +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 948F48FC12; Fri, 17 Feb 2012 22:40:52 +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 q1HMeqJx098909; Fri, 17 Feb 2012 22:40:52 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1HMeqmR098906; Fri, 17 Feb 2012 22:40:52 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202172240.q1HMeqmR098906@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 17 Feb 2012 22:40:52 +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: r231884 - 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: Fri, 17 Feb 2012 22:40:52 -0000 Author: gabor Date: Fri Feb 17 22:40:52 2012 New Revision: 231884 URL: http://svn.freebsd.org/changeset/base/231884 Log: - Clean up interfaces 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 Fri Feb 17 22:33:46 2012 (r231883) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Fri Feb 17 22:40:52 2012 (r231884) @@ -158,10 +158,13 @@ tre_have_approx(const regex_t *preg) } static int -tre_match(const tre_tnfa_t *tnfa, const void *string, size_t len, +tre_match(const regex_t *preg, const void *string, size_t len, tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], - int eflags, fastmatch_t *shortcut, heur_t *heur) + int eflags) { + tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; + fastmatch_t *shortcut = preg->shortcut; + heur_t *heur = preg->heur; if ((shortcut != NULL) && (type != STR_USER)) tre_match_fast(shortcut, string, len, type, nmatch, @@ -170,8 +173,7 @@ tre_match(const tre_tnfa_t *tnfa, const return tre_match_heur(tnfa, heur, string, len, type, nmatch, pmatch, eflags); - return tre_match_nfa(tnfa, string, len, type, nmatch, - pmatch, eflags); + return tre_match_nfa(tnfa, string, len, type, nmatch, pmatch, eflags); } static int @@ -402,15 +404,13 @@ int tre_regnexec(const regex_t *preg, const char *str, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) { - tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; if (eflags & REG_STARTEND) - CALL_WITH_OFFSET(tre_match(tnfa, &str[offset], slen, type, nmatch, - pmatch, eflags, preg->shortcut, preg->heur)); + CALL_WITH_OFFSET(tre_match(preg, &str[offset], slen, type, nmatch, + pmatch, eflags)); else - return tre_match(tnfa, str, len, type, nmatch, pmatch, eflags, - preg->shortcut, preg->heur); + return tre_match(preg, str, len, type, nmatch, pmatch, eflags); } int @@ -427,15 +427,13 @@ int tre_regwnexec(const regex_t *preg, const wchar_t *str, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) { - tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; tre_str_type_t type = STR_WIDE; if (eflags & REG_STARTEND) - CALL_WITH_OFFSET(tre_match(tnfa, &str[offset], slen, type, nmatch, - pmatch, eflags, preg->shortcut, preg->heur)); + CALL_WITH_OFFSET(tre_match(preg, &str[offset], slen, type, nmatch, + pmatch, eflags)); else - return tre_match(tnfa, str, len, STR_WIDE, nmatch, pmatch, eflags, - preg->shortcut, preg->heur); + return tre_match(preg, str, len, STR_WIDE, nmatch, pmatch, eflags); } int @@ -451,9 +449,7 @@ int tre_reguexec(const regex_t *preg, const tre_str_source *str, size_t nmatch, regmatch_t pmatch[], int eflags) { - tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; - return tre_match(tnfa, str, (unsigned)-1, STR_USER, nmatch, pmatch, eflags, - preg->shortcut, preg->heur); + return tre_match(preg, str, (unsigned)-1, STR_USER, nmatch, pmatch, eflags); } @@ -464,10 +460,11 @@ tre_reguexec(const regex_t *preg, const */ static int -tre_match_approx(const tre_tnfa_t *tnfa, const void *string, size_t len, +tre_match_approx(const regex_t *preg, const void *string, size_t len, tre_str_type_t type, regamatch_t *match, regaparams_t params, int eflags) { + tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; reg_errcode_t status; int *tags = NULL, eo; @@ -476,8 +473,8 @@ tre_match_approx(const tre_tnfa_t *tnfa, use the exact matcher instead. */ if (params.max_cost == 0 && !tnfa->have_approx && !(eflags & REG_APPROX_MATCHER)) - return tre_match(tnfa, string, len, type, match->nmatch, match->pmatch, - eflags, NULL, NULL); + return tre_match(preg, string, len, type, match->nmatch, match->pmatch, + eflags); /* Back references are not supported by the approximate matcher. */ if (tnfa->have_backrefs) @@ -508,10 +505,9 @@ int tre_reganexec(const regex_t *preg, const char *str, size_t len, regamatch_t *match, regaparams_t params, int eflags) { - tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; - return tre_match_approx(tnfa, str, len, type, match, params, eflags); + return tre_match_approx(preg, str, len, type, match, params, eflags); } int @@ -527,8 +523,7 @@ int tre_regawnexec(const regex_t *preg, const wchar_t *str, size_t len, regamatch_t *match, regaparams_t params, int eflags) { - tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; - return tre_match_approx(tnfa, str, len, STR_WIDE, + return tre_match_approx(preg, str, len, STR_WIDE, match, params, eflags); } Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Fri Feb 17 22:33:46 2012 (r231883) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Fri Feb 17 22:40:52 2012 (r231884) @@ -1999,11 +1999,11 @@ tre_compile(regex_t *preg, const tre_cha * Check if we can cheat with a fixed string algorithm * if the pattern is long enough. */ - ret = tre_compile_bm(preg, wregex, wn, regex, n, cflags); + tre_compile_bm(preg, wregex, wn, regex, n, cflags); - /* Only try to compile heuristic if the fast matcher failed. */ - if (ret != REG_OK) - ret = tre_compile_heur(preg, wregex, wn, cflags); + /* Only try to compile heuristic if the pattern is not literal */ + if (!(cflags & REG_LITERAL)) + tre_compile_heur(preg, wregex, wn, cflags); else preg->heur = NULL; From owner-svn-src-user@FreeBSD.ORG Sat Feb 18 19:37:02 2012 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 732B9106566C; Sat, 18 Feb 2012 19:37:02 +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 5D1B18FC08; Sat, 18 Feb 2012 19:37:02 +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 q1IJb216045064; Sat, 18 Feb 2012 19:37:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1IJb2MU045059; Sat, 18 Feb 2012 19:37:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202181937.q1IJb2MU045059@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 18 Feb 2012 19:37:02 +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: r231897 - 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: Sat, 18 Feb 2012 19:37:02 -0000 Author: gabor Date: Sat Feb 18 19:37:02 2012 New Revision: 231897 URL: http://svn.freebsd.org/changeset/base/231897 Log: Implement multi-pattern heuristic matching. Not yet connected to the build and totally untested. Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c user/gabor/tre-integration/contrib/tre/lib/mregexec.c user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Sat Feb 18 16:54:01 2012 (r231896) +++ user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Sat Feb 18 19:37:02 2012 (r231897) @@ -54,81 +54,102 @@ __weak_reference(tre_mregfree, mregfree) int tre_mcompile(mregex_t *preg, size_t nr, const tre_char_t *wregex[], - size_t wn[], int cflags) + size_t wn[], const char *regex[], size_t n, int cflags) { int ret; - size_t mfrag = 0; tre_char_t **frags; size_t *siz; wmsearch_t *wm; preg->k = nr; + preg->cflags = cflags; preg->patterns = xmalloc(nr * sizeof(regex_t)); if (!preg->patterns) return REG_ESPACE; + /* Compile NFA, BM and heuristic for each pattern. */ for (int i = 0; i < nr; i++) { - ret = tre_compile_nfa(&preg->patterns[i], wregex[i], wn[i], cflags); + ret = tre_compile(&preg->patterns[i], wregex[i], wn[i], + regex[i], n[i], cflags); if (ret != REG_OK) - goto err; - ret = tre_compile_heur(&preg->patterns[i], wregex[i], wn[i], cflags); - if (ret != REG_OK) - goto err; + return ret; } - for (mfrag = 0; mfrag < nr; mfrag++) - for (int j = 0; j < nr; j++) - if (((heur_t)preg->patterns[j]->heur)->arr[mfrag] == NULL) - goto out; -out: - - preg->mfrag = mfrag; - - /* Worst case, not all patterns have a literal prefix */ - if (mfrag == 0) - return REG_OK; - - wm = xmalloc(mfrag * sizeof(wmsearch_t)); - if (!wm) - goto err; + /* If not literal, check if any of them have fixed-length prefix. */ + if (!(cflags & REG_LITERAL)) + for (int i = 0; i < nr; i++) + if ((preg->patterns[i]->heur == NULL) || + (((heur_t)preg->patterns[i]->heur)->arr[0] == NULL)) + { + preg->type = MHEUR_NONE; + goto finish; + } - frags = xmalloc(nr * sizeof(char *)); - if (!frags) - goto err; + /* + * Set frag and siz to point to the fragments to compile and + * their respective sizes. + */ + if (!(cflags & REG_LITERAL)) + { + frags = xmalloc(nr * sizeof(char *)); + if (!frags) + goto err; - siz = xmalloc(nr * sizeof(size_t)); - // XXX: check NULL + siz = xmalloc(nr * sizeof(size_t)); + if (!siz) + goto err; - for (int i = 0; i < mfrag; i++) - { for (int j = 0; j < nr; j++) { - frags[j] = &((heur_t)preg->patterns[j]->heur)->arr[i]; - siz[j] = ((heur_t)preg->patterns[j]->heur)->siz[i]; + frags[j] = &((heur_t)preg->patterns[j]->heur)->arr[0]; + siz[j] = ((heur_t)preg->patterns[j]->heur)->siz[0]; } - ret = tre_wmcomp(&wm[i], nr, frags, siz, cflags); - if (ret != REG_OK) - goto err; + } + else + { + frags = wregex; + siz = wn; } + /* Alloc and compile the fragments for Wu-Manber algorithm. */ + wm = xmalloc(sizeof(wmsearch_t)); + if (!wm) + goto err; + ret = tre_wmcomp(wm, nr, frags, siz, cflags); + if (ret != REG_OK) + goto err; preg->searchdata = wm; - return REG_OK; + /* Set the specific type of matching. */ + if (cflags & REG_LITERAL) + preg->type = MHEUR_LITERAL; + else if (cflags & REG_NEWLINE) + preg->type = MHEUR_LONGEST; + else + preg->type = MHEUR_PREFIX; + + goto finish; err: if (preg->patterns) - xfree(preg->patterns); + { + for (int i = 1; i < nr; i++) + if (preg->patterns[i]) + tre_regfree(preg->patterns[i]); + xfree(preg->patterns); + } if (wm) + xfree(wm); + +finish: + if (!(cflags & REG_LITERAL)) { - for (int i = 0; i < mfrag; i++) - tre_wmfree(&wm[i]); - xfree(wm); - } - if (frags) - xfree(frags); - if (siz) - xfree(siz); + if (frag) + xfree(frag); + if (siz) + xfree(siz); + } return ret; } Modified: user/gabor/tre-integration/contrib/tre/lib/mregexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sat Feb 18 16:54:01 2012 (r231896) +++ user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sat Feb 18 19:37:02 2012 (r231897) @@ -80,8 +80,230 @@ tre_mmatch(const void *str, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags, const mregex_t *preg) { - - // XXX: Wu-Manber search with specific cases + tre_char_t *str_wide = str; + char *str_byte = str; + int ret; + bool need_offsets; + + need_offsets = (preg->cflags & REG_NOSUB) && (nmatch > 0); + +#define INPUT(pos) ((type == STR_WIDE) ? str_wide[pos] : str_byte[pos]) + + /* + * Worst case: at least one pattern does not have a literal + * prefix so the Wu-Manber algorithm cannot be used to speed + * up the match. There is no trivial best solution either, + * so just try matching for each of the patterns and return + * the earliest. + */ + if (preg->type == MHEUR_NONE) + { + regmatch_t **pm; + int i, first = -1; + + /* Alloc one regmatch_t for each pattern */ + if (need_offsets) + { + pm = xmalloc(preg->k * sizeof(regmatch_t *)); + if (!pm) + return REG_ESPACE; + for (i = 0; i < preg->k; i++) + { + pm[i] = xmalloc(nmatch * sizeof(regmatch_t)); + if (!pm[i]) + goto finish; + } + } + + /* Run matches for each pattern and save first matching offsets. */ + for (i = 0; i < preg->k; i++) + { + ret = tre_match(&preg->patterns[i], str, len, type, + need_offsets ? nmatch : 0, pm[i], eflags); + + /* Mark if there is no match for the pattern. */ + if (!need_offsets) + { + if (ret == REG_OK) + return REG_OK; + } + else if (ret == REG_NOMATCH) + pm[i][0].rm_so = -1; + else if (ret != REG_OK) + goto finish; + } + + if (!need_offsets) + return REG_NOMATCH; + + /* Check whether there has been a match at all. */ + for (i; i < preg->k; i++) + if (pm[i][0].rm_so != -1) + { + first = i; + break; + } + + if (first == -1) + ret = REG_NOMATCH; + + /* If there are matches, find the first one. */ + else + { + for (i = first + 1; i < preg->k; i++) + if ((pm[i][0].rm_so < pm[first][0].rm_so) || (pm[i][0].rm_eo > pm[first][0].rm_eo)) + { + first = i; + } + } + + /* Fill int the offsets before returning. */ + for (i = 0; need_offsets && (i < 0); i++) + { + pmatch[i].rm_so = pm[first][i].rm_so; + pmatch[i].rm_eo = pm[first][i].rm_eo; + pmatch[i].p = i; + } + ret = REG_OK; + +finish: + if (pm) + { + for (i = 0; i < preg->k; i++) + if (pm[i]) + xfree(pm[i]); + xfree(pm); + } + return ret; + } + + /* + * REG_NEWLINE: only searching the longest fragment of each + * pattern and then isolating the line and calling the + * automaton. + */ + else if (preg->type == MHEUR_LONGEST) + { + regmatch_t *pm, rpm; + size_t st = 0, bl, el; + + /* Alloc regmatch_t structures for results */ + if (need_offsets) + { + pm = xmalloc(nmatch * sizeof(regmatch_t *)); + if (!pm) + return REG_ESPACE; + } + + while (st < len) + { + /* Look for a possible match. */ + ret = tre_wmexec(INPUT(st), len, type, 1, &rpm, + eflags, preg->wm); + if (ret != REG_OK) + goto finish; + + /* Need to start from here if this fails. */ + st += rpm.rm_so + 1; + + /* Look for the beginning of the line. */ + for (bl = st; bl > 0; bl--) + if ((type == STR_WIDE) ? (str_wide[bl] == TRE_CHAR('\n')) + (str_byte[bl] == '\n') + break; + + /* Look for the end of the line. */ + for (el = st; el < len; el++) + if ((type == STR_WIDE) ? (str_wide[el] == TRE_CHAR('\n')) + (str_byte[el] == '\n') + break; + + /* Try to match the pattern on the line. */ + ret = tre_match(&preg->patterns[rpm.p], INPUT(bl), el - bl, + type, need_offsets ? nmatch : 0, &pm, eflags); + + /* Evaluate result. */ + if (ret == REG_NOMATCH) + continue; + else if (ret == REG_OK) + { + if (!need_offsets) + return REG_OK; + else + { + for (int i = 0; i < nmatch; i++) + { + pmatch[i].rm_so = pm[i].rm_so; + pmatch[i].rm_eo = pm[i].rm_eo; + pmatch[i].p = rpm.p; + goto finish; + } + } + } + else + goto finish; + } +finish: + if (!pm) + xfree(pm) + return ret; + } + + /* + * Literal case. It is enough to search with Wu-Manber and immediately + * return the match. + */ + else if (preg->type == MHEUR_LITERAL) + { + return tre_wmexec(str, len, type, nmatch, pmatch, eflags, preg->wm); + } + + /* + * General case. Look for the beginning of any of the patterns with the + * Wu-Manber algorithm and try to match from there with the automaton. + */ + else + { + regmatch_t *pm, rpm; + size_t st = 0; + + /* Alloc regmatch_t structures for results */ + if (need_offsets) + { + pm = xmalloc(nmatch * sizeof(regmatch_t *)); + if (!pm) + return REG_ESPACE; + } + + while (st < len) + { + ret = tre_wmexec(INPUT(st), len, type, nmatch, &rpm, eflags, preg->wm); + if (ret != REG_OK) + return ret; + + ret = tre_match(&preg->patterns[rpm.p], INPUT(rpm.rm_so), + len - rpm.rm_so, type, need_offsets ? nmatch : 0, + pm, eflags); + if ((ret == REG_OK) && (pm[0].rm_so == 0)) + { + for (int i = 0; i < nmatch; i++) + { + pm[i].rm_so += st; + pm[i].rm_eo += eo; + pm[i].p = rpm.p; + } + goto finish; + } + else if ((ret != REG_NOMATCH) || (ret != REG_OK)) + goto finish; + st += pm1.rm_so + 1; + } + +finish: + if (pm) + xfree(pm); + return ret; + } } Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Sat Feb 18 16:54:01 2012 (r231896) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Sat Feb 18 19:37:02 2012 (r231897) @@ -232,11 +232,14 @@ fail: #define MATCH(beg, end, p) \ do \ { \ - match->rm_so = beg; \ - match->rm_eo = end; \ - match->p = p; \ - err = REG_OK; \ - goto finish; \ + if (!(preg->cflags & REG_NOSUB) && (nmatch > 0)) \ + { \ + pmatch->rm_so = beg; \ + pmatch->rm_eo = end; \ + pmatch->p = p; \ + err = REG_OK; \ + goto finish; \ + } \ } while (0); #define _WMSEARCH(data, pats, sizes, mlen, tbl, dshift) \ @@ -292,7 +295,7 @@ fail: int tre_wmexec(const void *str, size_t len, tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], int eflags, - const wmsearch_t *wm, regmatch_t *match) + const wmsearch_t *wm) { wmentry_t *s_entry, *p_entry; tre_char_t *wide_str = str; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sat Feb 18 16:54:01 2012 (r231896) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sat Feb 18 19:37:02 2012 (r231897) @@ -9,7 +9,13 @@ #define WM_MAXPAT 64 +#define MHEUR_NONE 0 +#define MHEUR_PREFIX 1 +#define MHEUR_LONGEST 2 +#define MHEUR_LITERAL 3 + typedef struct { + int cflags; char **pat; /* Patterns */ size_t *siz; /* Pattern sizes */ size_t n; /* No of patterns */ From owner-svn-src-user@FreeBSD.ORG Sat Feb 18 20:17:17 2012 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 6C8291065672; Sat, 18 Feb 2012 20:17:17 +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 3EBE48FC08; Sat, 18 Feb 2012 20:17:17 +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 q1IKHHew046434; Sat, 18 Feb 2012 20:17:17 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1IKHHTj046430; Sat, 18 Feb 2012 20:17:17 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202182017.q1IKHHTj046430@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 18 Feb 2012 20:17:17 +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: r231898 - 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: Sat, 18 Feb 2012 20:17:17 -0000 Author: gabor Date: Sat Feb 18 20:17:16 2012 New Revision: 231898 URL: http://svn.freebsd.org/changeset/base/231898 Log: - Change paramter order of tre_wmexec - Add prototypes to the header file Modified: user/gabor/tre-integration/contrib/tre/lib/mregexec.c user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/mregexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sat Feb 18 19:37:02 2012 (r231897) +++ user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sat Feb 18 20:17:16 2012 (r231898) @@ -198,8 +198,8 @@ finish: while (st < len) { /* Look for a possible match. */ - ret = tre_wmexec(INPUT(st), len, type, 1, &rpm, - eflags, preg->wm); + ret = tre_wmexec(preg->wm, INPUT(st), len, type, 1, &rpm, + eflags); if (ret != REG_OK) goto finish; @@ -255,7 +255,7 @@ finish: */ else if (preg->type == MHEUR_LITERAL) { - return tre_wmexec(str, len, type, nmatch, pmatch, eflags, preg->wm); + return tre_wmexec(preg->wm, str, len, type, nmatch, pmatch, eflags); } /* @@ -277,7 +277,7 @@ finish: while (st < len) { - ret = tre_wmexec(INPUT(st), len, type, nmatch, &rpm, eflags, preg->wm); + ret = tre_wmexec(preg->wm, INPUT(st), len, type, nmatch, &rpm, eflags); if (ret != REG_OK) return ret; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Sat Feb 18 19:37:02 2012 (r231897) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Sat Feb 18 20:17:16 2012 (r231898) @@ -293,9 +293,9 @@ fail: wm->wdefsh) int -tre_wmexec(const void *str, size_t len, tre_str_type_t type, - size_t nmatch, regmatch_t pmatch[], int eflags, - const wmsearch_t *wm) +tre_wmexec(const wmsearch_t *wm, const void *str, size_t len, + tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], + int eflags) { wmentry_t *s_entry, *p_entry; tre_char_t *wide_str = str; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sat Feb 18 19:37:02 2012 (r231897) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sat Feb 18 20:17:16 2012 (r231898) @@ -40,4 +40,14 @@ typedef struct { uint8_t pref_list[WM_MAXPAT]; /* Pats starting w/ fragment */ } wmentry_t; +int +tre_wmcomp(wmsearch_t *wm, size_t nr, const tre_char_t *regex[], + size_t n[], int cflags); +int +tre_wmexec(const wmsearch_t *wm, const void *str, size_t len, + tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], + int eflags); +void +tre_wmfree(wmsearch_t *wm); + #endif /* TRE_MFASTMATCH_H */ From owner-svn-src-user@FreeBSD.ORG Sat Feb 18 20:22:54 2012 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 E7E161065674; Sat, 18 Feb 2012 20:22:54 +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 BA4B38FC12; Sat, 18 Feb 2012 20:22:54 +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 q1IKMs9M046670; Sat, 18 Feb 2012 20:22:54 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1IKMs4S046667; Sat, 18 Feb 2012 20:22:54 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202182022.q1IKMs4S046667@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 18 Feb 2012 20:22:54 +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: r231899 - 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: Sat, 18 Feb 2012 20:22:55 -0000 Author: gabor Date: Sat Feb 18 20:22:54 2012 New Revision: 231899 URL: http://svn.freebsd.org/changeset/base/231899 Log: - TRE coding style changes Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Sat Feb 18 20:17:16 2012 (r231898) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Sat Feb 18 20:22:54 2012 (r231899) @@ -9,12 +9,16 @@ #include "hashtable.h" #include "tre-internal.h" -int tre_proc_literal(fastmatch_t *, const tre_char_t *, size_t, - const char *, size_t, int); -int tre_proc_fast(fastmatch_t *, const tre_char_t *, size_t, - const char *, size_t, int); -int tre_match_fast(const fastmatch_t *fg, const void *data, size_t len, - tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); -void tre_free_fast(fastmatch_t *preg); +int +tre_proc_literal(fastmatch_t *, const tre_char_t *, size_t, + const char *, size_t, int); +int +tre_proc_fast(fastmatch_t *, const tre_char_t *, size_t, + const char *, size_t, int); +int +tre_match_fast(const fastmatch_t *fg, const void *data, size_t len, + tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); +void +tre_free_fast(fastmatch_t *preg); #endif /* TRE_FASTMATCH_H */ Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sat Feb 18 20:17:16 2012 (r231898) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.h Sat Feb 18 20:22:54 2012 (r231899) @@ -42,12 +42,11 @@ typedef struct { int tre_wmcomp(wmsearch_t *wm, size_t nr, const tre_char_t *regex[], - size_t n[], int cflags); + size_t n[], int cflags); int tre_wmexec(const wmsearch_t *wm, const void *str, size_t len, - tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], - int eflags); + tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], + int eflags); void tre_wmfree(wmsearch_t *wm); - #endif /* TRE_MFASTMATCH_H */ From owner-svn-src-user@FreeBSD.ORG Sat Feb 18 20:23:22 2012 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 88C141065672; Sat, 18 Feb 2012 20:23:22 +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 753F78FC16; Sat, 18 Feb 2012 20:23:22 +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 q1IKNM3i046718; Sat, 18 Feb 2012 20:23:22 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1IKNMEc046716; Sat, 18 Feb 2012 20:23:22 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202182023.q1IKNMEc046716@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 18 Feb 2012 20:23:22 +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: r231900 - user/gabor/tre-integration/include 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: Sat, 18 Feb 2012 20:23:22 -0000 Author: gabor Date: Sat Feb 18 20:23:22 2012 New Revision: 231900 URL: http://svn.freebsd.org/changeset/base/231900 Log: - Add public interfaces for multiple-pattern matching Modified: user/gabor/tre-integration/include/mregex.h Modified: user/gabor/tre-integration/include/mregex.h ============================================================================== --- user/gabor/tre-integration/include/mregex.h Sat Feb 18 20:22:54 2012 (r231899) +++ user/gabor/tre-integration/include/mregex.h Sat Feb 18 20:23:22 2012 (r231900) @@ -8,10 +8,39 @@ typedef struct { size_t k; /* Number of patterns */ regex_t *patterns; /* regex_t structure for each pattern */ - size_t mfrag; /* Number of fragments */ + size_t mfrag; /* XXX Number of fragments */ + size_t type; /* XXX Matching type */ void *searchdata; } mregex_t; -#endif /* REGEX_H */ +int +tre_mregncomp(mregex_t *preg, size_t nr, const char *regex[], + size_t n[], int cflags); +int +tre_mregcomp(mregex_t *preg, size_t nr, const char *regex[], int cflags); +int +tre_mregnexec(const mregex_t *preg, const char *str, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags); +int +tre_regexec(const mregex_t *preg, const char *str, + size_t nmatch, regmatch_t pmatch[], int eflags); +void +tre_mregfree(mregex_t *preg); +#ifdef TRE_WCHAR +int +tre_mregwncomp(mregex_t *preg, size_t nr, const wchar_t *regex[], + size_t n[], int cflags); +int +tre_mregwcomp(mregex_t *preg, size_t nr, const wchar_t *regex[], + int cflags); +int +tre_mregwnexec(const mregex_t *preg, const wchar_t *str, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags); +int +tre_mregwexec(const mregex_t *preg, const wchar_t *str, + size_t nmatch, regmatch_t pmatch[], int eflags); +#endif /* TRE_WCHAR */ + +#endif /* MREGEX_H */ /* EOF */ From owner-svn-src-user@FreeBSD.ORG Sat Feb 18 20:27:01 2012 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 EDB24106570D; Sat, 18 Feb 2012 20:27:01 +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 BFB188FC0A; Sat, 18 Feb 2012 20:27:01 +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 q1IKR1OM046883; Sat, 18 Feb 2012 20:27:01 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1IKR1eF046880; Sat, 18 Feb 2012 20:27:01 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202182027.q1IKR1eF046880@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 18 Feb 2012 20:27:01 +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: r231901 - 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: Sat, 18 Feb 2012 20:27:02 -0000 Author: gabor Date: Sat Feb 18 20:27:01 2012 New Revision: 231901 URL: http://svn.freebsd.org/changeset/base/231901 Log: - header cleanup Modified: user/gabor/tre-integration/contrib/tre/lib/mregexec.c user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/mregexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sat Feb 18 20:23:22 2012 (r231900) +++ user/gabor/tre-integration/contrib/tre/lib/mregexec.c Sat Feb 18 20:27:01 2012 (r231901) @@ -28,44 +28,16 @@ #include #endif /* HAVE_CONFIG_H */ -#ifdef TRE_USE_ALLOCA -/* AIX requires this to be the first thing in the file. */ -#ifndef __GNUC__ -# if HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -#endif -#endif /* TRE_USE_ALLOCA */ - -#include +#include +#include #include -#include -#include #ifdef HAVE_WCHAR_H #include #endif /* HAVE_WCHAR_H */ -#ifdef HAVE_WCTYPE_H -#include -#endif /* HAVE_WCTYPE_H */ -#ifndef TRE_WCHAR -#include -#endif /* !TRE_WCHAR */ -#ifdef HAVE_MALLOC_H -#include -#endif /* HAVE_MALLOC_H */ -#include -#include "tre-fastmatch.h" #include "tre-heuristic.h" #include "tre-internal.h" +#include "tre-mfastmatch.h" #include "xmalloc.h" #ifdef TRE_LIBC_BUILD Modified: user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Sat Feb 18 20:23:22 2012 (r231900) +++ user/gabor/tre-integration/contrib/tre/lib/tre-mfastmatch.c Sat Feb 18 20:27:01 2012 (r231901) @@ -29,6 +29,7 @@ #endif /* HAVE_CONFIG_H */ #include #include + #include "tre-mfastmatch.h" #include "xmalloc.h"