CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: joerg Date: Mon Apr 20 13:56:07 UTC 2020 Modified Files: src/external/bsd/tre/dist/lib: tre-match-approx.c Log Message: Fix indentation To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/tre/dist/lib/tre-match-approx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-approx.c diff -u src/external/bsd/tre/dist/lib/tre-match-approx.c:1.6 src/external/bsd/tre/dist/lib/tre-match-approx.c:1.7 --- src/external/bsd/tre/dist/lib/tre-match-approx.c:1.6 Tue Nov 21 02:50:35 2017 +++ src/external/bsd/tre/dist/lib/tre-match-approx.c Mon Apr 20 13:56:07 2020 @@ -759,10 +759,10 @@ tre_tnfa_run_approx(const tre_tnfa_t *tn default_params); /* Set the costs after this transition. */ - memcpy(_next[dest_id].costs, - reach[id].costs, - sizeof(reach[id].costs[0][0]) - * TRE_M_LAST * (depth + 1)); + memcpy(_next[dest_id].costs, + reach[id].costs, + sizeof(reach[id].costs[0][0]) + * TRE_M_LAST * (depth + 1)); reach_next[dest_id].costs[depth][TRE_M_COST] = cost; reach_next[dest_id].costs[depth][TRE_M_NUM_SUBST] += err; reach_next[dest_id].costs[depth][TRE_M_NUM_ERR] += err;
CVS commit: src/external/bsd/tre/dist
Module Name:src Committed By: rin Date: Tue Nov 21 08:19:55 UTC 2017 Removed Files: src/external/bsd/tre/dist/doc: Makefile.in src/external/bsd/tre/dist/lib: Makefile.in src/external/bsd/tre/dist/m4: Makefile.in gettext.m4 iconv.m4 intlmacosx.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4 src/external/bsd/tre/dist/po: Makefile.in.in Rules-quot boldquot.sed en@boldquot.header en@quot.header insert-header.sin quot.sed remove-potcdate.sin stamp-po tre.pot src/external/bsd/tre/dist/src: Makefile.in src/external/bsd/tre/dist/tests: Makefile.in src/external/bsd/tre/dist/tests/agrep: Makefile.in src/external/bsd/tre/dist/utils: Makefile.in compile config.guess config.rpath config.sub depcomp install-sh ltmain.sh missing mkinstalldirs src/external/bsd/tre/dist/win32: retest.dsp tre.dsp tre.dsw Log Message: Remove more files that should be removed when tre was imported from github repository. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/doc/Makefile.in cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/lib/Makefile.in cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/m4/Makefile.in \ src/external/bsd/tre/dist/m4/gettext.m4 \ src/external/bsd/tre/dist/m4/iconv.m4 \ src/external/bsd/tre/dist/m4/intlmacosx.m4 \ src/external/bsd/tre/dist/m4/lib-ld.m4 \ src/external/bsd/tre/dist/m4/lib-link.m4 \ src/external/bsd/tre/dist/m4/lib-prefix.m4 \ src/external/bsd/tre/dist/m4/nls.m4 src/external/bsd/tre/dist/m4/po.m4 \ src/external/bsd/tre/dist/m4/progtest.m4 cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/po/Makefile.in.in \ src/external/bsd/tre/dist/po/Rules-quot \ src/external/bsd/tre/dist/po/boldquot.sed \ src/external/bsd/tre/dist/po/en@boldquot.header \ src/external/bsd/tre/dist/po/en@quot.header \ src/external/bsd/tre/dist/po/insert-header.sin \ src/external/bsd/tre/dist/po/quot.sed \ src/external/bsd/tre/dist/po/remove-potcdate.sin \ src/external/bsd/tre/dist/po/stamp-po \ src/external/bsd/tre/dist/po/tre.pot cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/src/Makefile.in cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/tests/Makefile.in cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/tests/agrep/Makefile.in cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/utils/Makefile.in \ src/external/bsd/tre/dist/utils/compile \ src/external/bsd/tre/dist/utils/config.rpath \ src/external/bsd/tre/dist/utils/depcomp \ src/external/bsd/tre/dist/utils/install-sh \ src/external/bsd/tre/dist/utils/ltmain.sh \ src/external/bsd/tre/dist/utils/missing \ src/external/bsd/tre/dist/utils/mkinstalldirs cvs rdiff -u -r1.2 -r0 src/external/bsd/tre/dist/utils/config.guess \ src/external/bsd/tre/dist/utils/config.sub cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/win32/retest.dsp \ src/external/bsd/tre/dist/win32/tre.dsp \ src/external/bsd/tre/dist/win32/tre.dsw Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Tue Nov 21 02:53:20 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre.h Log Message: Add REG_INVARG and REG_STARTEND ifndef TRE_USE_SYSTEM_REGEX_H. No functional changes at the moment. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/tre/dist/lib/tre.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre.h diff -u src/external/bsd/tre/dist/lib/tre.h:1.5 src/external/bsd/tre/dist/lib/tre.h:1.6 --- src/external/bsd/tre/dist/lib/tre.h:1.5 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre.h Tue Nov 21 02:53:20 2017 @@ -98,7 +98,8 @@ typedef enum { REG_BADBR, /* Invalid content of {} */ REG_ERANGE, /* Invalid use of range operator */ REG_ESPACE, /* Out of memory. */ - REG_BADRPT/* Invalid use of repetition operators. */ + REG_BADRPT, /* Invalid use of repetition operators. */ + REG_INVARG, /* Invalid arguments. */ } reg_errcode_t; /* POSIX tre_regcomp() flags. */ @@ -122,6 +123,7 @@ typedef enum { /* Extra tre_regexec() flags. */ #define REG_APPROX_MATCHER (REG_NOTEOL << 1) #define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER << 1) +#define REG_STARTEND (REG_BACKTRACKING_MATCHER << 1) #endif /* !TRE_USE_SYSTEM_REGEX_H */
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Tue Nov 21 02:50:35 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-match-approx.c tre-match-parallel.c Log Message: Some systems need for SIZE_MAX. No functional changes on NetBSD. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/tre/dist/lib/tre-match-approx.c \ src/external/bsd/tre/dist/lib/tre-match-parallel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-approx.c diff -u src/external/bsd/tre/dist/lib/tre-match-approx.c:1.5 src/external/bsd/tre/dist/lib/tre-match-approx.c:1.6 --- src/external/bsd/tre/dist/lib/tre-match-approx.c:1.5 Sun Nov 19 14:03:35 2017 +++ src/external/bsd/tre/dist/lib/tre-match-approx.c Tue Nov 21 02:50:35 2017 @@ -30,6 +30,7 @@ #ifdef HAVE_MALLOC_H #include #endif /* HAVE_MALLOC_H */ +#include #include "tre-internal.h" #include "tre-match-utils.h" Index: src/external/bsd/tre/dist/lib/tre-match-parallel.c diff -u src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.5 src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.6 --- src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.5 Sun Nov 19 14:03:35 2017 +++ src/external/bsd/tre/dist/lib/tre-match-parallel.c Tue Nov 21 02:50:35 2017 @@ -44,6 +44,7 @@ #ifdef HAVE_MALLOC_H #include #endif /* HAVE_MALLOC_H */ +#include #include "tre-internal.h" #include "tre-match-utils.h"
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 21:54:31 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-match-backtrack.c Log Message: Fix an apparent typo. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/tre/dist/lib/tre-match-backtrack.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-backtrack.c diff -u src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.6 src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.7 --- src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.6 Sun Nov 19 13:21:02 2017 +++ src/external/bsd/tre/dist/lib/tre-match-backtrack.c Sun Nov 19 21:54:31 2017 @@ -409,7 +409,7 @@ tre_tnfa_run_backtrack(const tre_tnfa_t DPRINT((" should match back reference %d\n", bt)); /* Get the substring we need to match against. Remember to turn off REG_NOSUB temporarily. */ - tre_fill_pmatch(bt + 1, pmatch, tnfa->cflags & /*LINTED*/!REG_NOSUB, + tre_fill_pmatch(bt + 1, pmatch, tnfa->cflags & ~REG_NOSUB, tnfa, tags, pos); /* LINTED */so = pmatch[bt].rm_so; /* LINTED */eo = pmatch[bt].rm_eo;
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 14:03:35 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-match-approx.c tre-match-parallel.c Log Message: Add missing integer overflow checks to avoid out-of-bound write reported in CVE-2016-8859, partially taken from musl libc: https://git.musl-libc.org/cgit/musl/commit/src/regex/regexec.c?id=c3edc06d1e1360f3570db9155d6b318ae0d0f0f7 https://git.musl-libc.org/cgit/musl/commit/src/regex/regexec.c?id=6582baa752a8facb2c8a7b5b3dcf67331429cdc1 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/tre-match-approx.c \ src/external/bsd/tre/dist/lib/tre-match-parallel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-approx.c diff -u src/external/bsd/tre/dist/lib/tre-match-approx.c:1.4 src/external/bsd/tre/dist/lib/tre-match-approx.c:1.5 --- src/external/bsd/tre/dist/lib/tre-match-approx.c:1.4 Sun Nov 19 13:22:58 2017 +++ src/external/bsd/tre/dist/lib/tre-match-approx.c Sun Nov 19 14:03:35 2017 @@ -252,6 +252,16 @@ tre_tnfa_run_approx(const tre_tnfa_t *tn or with malloc() if alloca is unavailable. */ { unsigned char *buf_cursor; + +/* Ensure that tag_bytes*num_states cannot overflow, and that it don't + * contribute more than 1/8 of SIZE_MAX to total_bytes. */ +if (num_tags > SIZE_MAX/(8 * sizeof(*tmp_tags) * tnfa->num_states)) + return REG_ESPACE; + +/* Likewise check reach_bytes. */ +if (tnfa->num_states > SIZE_MAX/(8 * sizeof(*reach_next))) + return REG_ESPACE; + /* Space needed for one array of tags. */ size_t tag_bytes = sizeof(*tmp_tags) * num_tags; /* Space needed for one reach table. */ Index: src/external/bsd/tre/dist/lib/tre-match-parallel.c diff -u src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.4 src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.5 --- src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.4 Sun Nov 19 13:22:58 2017 +++ src/external/bsd/tre/dist/lib/tre-match-parallel.c Sun Nov 19 14:03:35 2017 @@ -141,6 +141,20 @@ tre_tnfa_run_parallel(const tre_tnfa_t * { size_t tbytes, rbytes, pbytes, xbytes, total_bytes; char *tmp_buf; + +/* Ensure that tbytes and xbytes*num_states cannot overflow, and that + * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */ +if (num_tags > SIZE_MAX/(8 * sizeof(int) * tnfa->num_states)) + return REG_ESPACE; + +/* Likewise check rbytes. */ +if (tnfa->num_states+1 > SIZE_MAX/(8 * sizeof(*reach_next))) + return REG_ESPACE; + +/* Likewise check pbytes. */ +if (tnfa->num_states > SIZE_MAX/(8 * sizeof(*reach_pos))) + return REG_ESPACE; + /* Compute the length of the block we need. */ tbytes = sizeof(*tmp_tags) * num_tags; rbytes = sizeof(*reach_next) * (tnfa->num_states + 1);
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 13:22:58 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-match-approx.c tre-match-parallel.c tre-match-utils.h Log Message: Fix memory leak when input contains illegal multibyte sequence, partially taken from musl libc: https://git.musl-libc.org/cgit/musl/commit/src/regex/regexec.c?id=546f6b322bcafa2452925c19f9607d9689c75f95 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/lib/tre-match-approx.c \ src/external/bsd/tre/dist/lib/tre-match-parallel.c \ src/external/bsd/tre/dist/lib/tre-match-utils.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-approx.c diff -u src/external/bsd/tre/dist/lib/tre-match-approx.c:1.3 src/external/bsd/tre/dist/lib/tre-match-approx.c:1.4 --- src/external/bsd/tre/dist/lib/tre-match-approx.c:1.3 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre-match-approx.c Sun Nov 19 13:22:58 2017 @@ -225,6 +225,8 @@ tre_tnfa_run_approx(const tre_tnfa_t *tn size_t i, id; + reg_errcode_t ret; + if (!match_tags) num_tags = 0; else @@ -781,16 +783,17 @@ tre_tnfa_run_approx(const tre_tnfa_t *tn DPRINT(("match end offset = %d, match cost = %d\n", match_eo, match_costs[TRE_M_COST])); -#ifndef TRE_USE_ALLOCA - if (buf) -xfree(buf); -#endif /* !TRE_USE_ALLOCA */ - match->cost = match_costs[TRE_M_COST]; match->num_ins = match_costs[TRE_M_NUM_INS]; match->num_del = match_costs[TRE_M_NUM_DEL]; match->num_subst = match_costs[TRE_M_NUM_SUBST]; *match_end_ofs = match_eo; - return match_eo >= 0 ? REG_OK : REG_NOMATCH; + ret = match_eo >= 0 ? REG_OK : REG_NOMATCH; +error_exit: +#ifndef TRE_USE_ALLOCA + if (buf) +xfree(buf); +#endif /* !TRE_USE_ALLOCA */ + return ret; } Index: src/external/bsd/tre/dist/lib/tre-match-parallel.c diff -u src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.3 src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.4 --- src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.3 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre-match-parallel.c Sun Nov 19 13:22:58 2017 @@ -121,6 +121,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t * int new_match = 0; int *tmp_tags = NULL; int *tmp_iptr; + reg_errcode_t ret; #ifdef TRE_MBSTATE memset(, '\0', sizeof(mbstate)); @@ -474,13 +475,14 @@ tre_tnfa_run_parallel(const tre_tnfa_t * DPRINT(("match end offset = %d\n", match_eo)); + *match_end_ofs = match_eo; + ret = match_eo >= 0 ? REG_OK : REG_NOMATCH; +error_exit: #ifndef TRE_USE_ALLOCA if (buf) xfree(buf); #endif /* !TRE_USE_ALLOCA */ - - *match_end_ofs = match_eo; - return match_eo >= 0 ? REG_OK : REG_NOMATCH; + return ret; } /* EOF */ Index: src/external/bsd/tre/dist/lib/tre-match-utils.h diff -u src/external/bsd/tre/dist/lib/tre-match-utils.h:1.3 src/external/bsd/tre/dist/lib/tre-match-utils.h:1.4 --- src/external/bsd/tre/dist/lib/tre-match-utils.h:1.3 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre-match-utils.h Sun Nov 19 13:22:58 2017 @@ -52,8 +52,10 @@ else \ { \ w = tre_mbrtowc(_c, str_byte, (size_t)max, );\ - if (w == (size_t)-1 || w == (size_t)-2) \ - return REG_NOMATCH; \ + if (w == (size_t)-1 || w == (size_t)-2) { \ + ret = REG_NOMATCH; \ + goto error_exit; \ + } \ if (w == 0 && len >= 0) \ { \ pos_add_next = 1; \
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 13:21:03 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-match-backtrack.c Log Message: ret should be reg_errcode_t. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/tre/dist/lib/tre-match-backtrack.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-backtrack.c diff -u src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.5 src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.6 --- src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.5 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre-match-backtrack.c Sun Nov 19 13:21:02 2017 @@ -230,7 +230,7 @@ tre_tnfa_run_backtrack(const tre_tnfa_t tre_tnfa_transition_t *trans_i; regmatch_t *pmatch = NULL; - int ret; + reg_errcode_t ret; #ifdef TRE_MBSTATE memset(, '\0', sizeof(mbstate));
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 13:00:31 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: regexec.c Log Message: nmatch and pmatch should be ignored when regex was compiled with REG_NOSUB, partially taken from musl libc: https://git.musl-libc.org/cgit/musl/commit/src/regex/regexec.c?id=72ed3d47e567b1635a35d3c1d174c8a8b2787e30 To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/tre/dist/lib/regexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/regexec.c diff -u src/external/bsd/tre/dist/lib/regexec.c:1.9 src/external/bsd/tre/dist/lib/regexec.c:1.10 --- src/external/bsd/tre/dist/lib/regexec.c:1.9 Fri Nov 17 16:16:19 2017 +++ src/external/bsd/tre/dist/lib/regexec.c Sun Nov 19 13:00:31 2017 @@ -43,8 +43,11 @@ tre_fill_pmatch(size_t nmatch, regmatch_ unsigned int i, j; int *parents; + if (cflags & REG_NOSUB) +return; + i = 0; - if (match_eo >= 0 && !(cflags & REG_NOSUB)) + if (match_eo >= 0) { /* Construct submatch offsets from the tags. */ DPRINT(("end tag = t%d = %d\n", tnfa->end_tag, match_eo)); @@ -127,6 +130,7 @@ tre_match(const tre_tnfa_t *tnfa, const { reg_errcode_t status; int *tags = NULL, eo; + if (tnfa->cflags & REG_NOSUB) nmatch = 0; if (tnfa->num_tags > 0 && nmatch > 0) { #ifdef TRE_USE_ALLOCA @@ -315,20 +319,26 @@ tre_match_approx(const tre_tnfa_t *tnfa, { reg_errcode_t status; int *tags = NULL, eo; + size_t nmatch; + + if (tnfa->cflags & REG_NOSUB) +nmatch = 0; + else +nmatch = match->nmatch; /* If the regexp does not use approximate matching features, the maximum cost is zero, and the approximate matcher isn't forced, 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, +return tre_match(tnfa, string, len, type, nmatch, match->pmatch, eflags); /* Back references are not supported by the approximate matcher. */ if (tnfa->have_backrefs) return REG_BADPAT; - if (tnfa->num_tags > 0 && match->nmatch > 0) + if (tnfa->num_tags > 0 && nmatch > 0) { #if TRE_USE_ALLOCA tags = alloca(sizeof(*tags) * tnfa->num_tags); @@ -341,7 +351,7 @@ tre_match_approx(const tre_tnfa_t *tnfa, status = tre_tnfa_run_approx(tnfa, string, (int)len, type, tags, match, params, eflags, ); if (status == REG_OK) -tre_fill_pmatch(match->nmatch, match->pmatch, tnfa->cflags, tnfa, tags, eo); +tre_fill_pmatch(nmatch, match->pmatch, tnfa->cflags, tnfa, tags, eo); #ifndef TRE_USE_ALLOCA if (tags) xfree(tags);
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 12:35:39 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-compile.c Log Message: Fix use of uninitialized value, taken from musl libc: https://git.musl-libc.org/cgit/musl/commit/src/regex/regcomp.c?id=51eeb6ebc94d965768143c45e9f39b0a7998bdbd To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/tre/dist/lib/tre-compile.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-compile.c diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.6 src/external/bsd/tre/dist/lib/tre-compile.c:1.7 --- src/external/bsd/tre/dist/lib/tre-compile.c:1.6 Sun Nov 19 12:26:25 2017 +++ src/external/bsd/tre/dist/lib/tre-compile.c Sun Nov 19 12:35:39 2017 @@ -61,6 +61,7 @@ tre_add_tag_left(tre_mem_t mem, tre_ast_ c->right->firstpos = NULL; c->right->lastpos = NULL; c->right->num_tags = 0; + c->right->num_submatches = 0; node->obj = c; node->type = CATENATION; return REG_OK; @@ -93,6 +94,7 @@ tre_add_tag_right(tre_mem_t mem, tre_ast c->left->firstpos = NULL; c->left->lastpos = NULL; c->left->num_tags = 0; + c->left->num_submatches = 0; node->obj = c; node->type = CATENATION; return REG_OK;
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 12:26:25 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-compile.c Log Message: Check error code from allocating function, from musl libc: https://git.musl-libc.org/cgit/musl/commit/src/regex/regcomp.c?id=4260dfe1ecc43d92d1e6d30daa0f22bd746d1740 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/tre/dist/lib/tre-compile.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-compile.c diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.5 src/external/bsd/tre/dist/lib/tre-compile.c:1.6 --- src/external/bsd/tre/dist/lib/tre-compile.c:1.5 Sun Nov 19 12:13:14 2017 +++ src/external/bsd/tre/dist/lib/tre-compile.c Sun Nov 19 12:26:25 2017 @@ -594,7 +594,8 @@ tre_add_tags(tre_mem_t mem, tre_stack_t { status = tre_add_tag_right(mem, left, tag_left); tnfa->tag_directions[tag_left] = TRE_TAG_MAXIMIZE; - status = tre_add_tag_right(mem, right, tag_right); + if (status == REG_OK) + status = tre_add_tag_right(mem, right, tag_right); tnfa->tag_directions[tag_right] = TRE_TAG_MAXIMIZE; } DPRINT((" num_tags += 2\n"));
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 19 12:13:14 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: tre-compile.c tre-parse.c Log Message: Fix allocation size with wrong use of sizeof, taken from musl libc: https://git.musl-libc.org/cgit/musl/commit/src/regex/regcomp.c?id=1e81fa4524ecfd51e6a6578ff8038b4c05393101 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/tre-compile.c \ src/external/bsd/tre/dist/lib/tre-parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-compile.c diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.4 src/external/bsd/tre/dist/lib/tre-compile.c:1.5 --- src/external/bsd/tre/dist/lib/tre-compile.c:1.4 Fri Nov 17 16:16:19 2017 +++ src/external/bsd/tre/dist/lib/tre-compile.c Sun Nov 19 12:13:14 2017 @@ -1949,7 +1949,7 @@ tre_compile(regex_t *preg, const tre_cha sizeof(*tag_directions) * (tnfa->num_tags + 1)); } tnfa->minimal_tags = xcalloc((unsigned)tnfa->num_tags * 2 + 1, - sizeof(tnfa->minimal_tags)); + sizeof(*tnfa->minimal_tags)); if (tnfa->minimal_tags == NULL) ERROR_EXIT(REG_ESPACE); Index: src/external/bsd/tre/dist/lib/tre-parse.c diff -u src/external/bsd/tre/dist/lib/tre-parse.c:1.4 src/external/bsd/tre/dist/lib/tre-parse.c:1.5 --- src/external/bsd/tre/dist/lib/tre-parse.c:1.4 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre-parse.c Sun Nov 19 12:13:14 2017 @@ -108,7 +108,7 @@ tre_new_item(tre_mem_t mem, int min, int if (*max_i > 1024) return REG_ESPACE; *max_i *= 2; - new_items = xrealloc(array, sizeof(*items) * *max_i); + new_items = xrealloc(array, sizeof(*array) * *max_i); if (new_items == NULL) return REG_ESPACE; *items = array = new_items; @@ -509,7 +509,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx, if (num_neg_classes > 0) { l->neg_classes = tre_mem_alloc(ctx->mem, - (sizeof(l->neg_classes) + (sizeof(*l->neg_classes) * (num_neg_classes + 1))); if (l->neg_classes == NULL) { @@ -550,7 +550,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx, if (num_neg_classes > 0) { l->neg_classes = tre_mem_alloc(ctx->mem, - (sizeof(l->neg_classes) + (sizeof(*l->neg_classes) * (num_neg_classes + 1))); if (l->neg_classes == NULL) {
CVS commit: src/external/bsd/tre/dist
Module Name:src Committed By: rin Date: Fri Nov 17 16:44:01 UTC 2017 Added Files: src/external/bsd/tre/dist: ChangeLog.old Log Message: Add ChangeLog.old, which has been newly added to github repository. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/external/bsd/tre/dist/ChangeLog.old Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/external/bsd/tre/dist/ChangeLog.old diff -u /dev/null src/external/bsd/tre/dist/ChangeLog.old:1.1 --- /dev/null Fri Nov 17 16:44:01 2017 +++ src/external/bsd/tre/dist/ChangeLog.old Fri Nov 17 16:44:01 2017 @@ -0,0 +1,815 @@ +Fri Dec 10 21:15:14 2004 Ville Laurikari+ + * Released tre-0.7.2. + +Sat Dec 4 12:04:29 2004 Ville Laurikari + + * lib/tre-compile.c (tre_expand_ast): Bugfix. If a back reference + occurred after {m,n} in a regexp, its position was not updated + causing incorrect match results. + + * lib/tre-compile.c (tre_make_trans): Bugfix. If a back reference + was immediately followed by $ or ^, it triggered an assertion + failure when compiling the regexp. + + * tre/retest.c: Added regression tests to catch the above bugs. + + * lib/tre-compile.c (tre_version): Changed to return a better + human-readable string instead of just the version number. + + * src/agrep.c (tre_agrep_handle_file): Bugfix. The read buffer + must be reset when starting to read a new file because the read + loop may bail out without reading the full file. + +Sun Nov 21 18:22:26 2004 Ville Laurikari + + * Released tre-0.7.1. + +Sat Nov 20 10:10:12 2004 Ville Laurikari + + * src/agrep.c: Added the --delimiter-after command line option. + It can be used to output the record delimiter after the matching + record when a custom delimiter regex has been given instead of + before the matching record, which is the default. + + * src/agrep.c: Added the --color (and --colour) command line + option. It highlights the matching part of the text with a color + code from the GREP_COLOR environment variable, or red by default. + + * src/agrep.c: Made some changes which hopefully make agrep faster + in certain conditions. + + * win32/tre.def: Added reguexec. + +Sun Nov 7 17:26:54 2004 Ville Laurikari + + * Makefile.am: Fixed to include all files under the python + directory to distributions. + + * lib/*: Divided tre-compile.c to several smaller files, to make + things easier to maintain. + + * doc/agrep.1.in: Added this man page for agrep. + +Fri Sep 10 21:47:23 2004 Ville Laurikari + + * Released tre-0.7.0. + +Sat Sep 4 14:55:00 2004 Ville Laurikari + + * lib/tre-compile.c (tre_parse): Added support for the \x1B and + \x{263a} extensions for entering 8 bit and wide characters in + hexadecimal. + + * tests/retest.c: Added tests for the above. + + * python/{tre-python.c, setup.py.in, example.py}, configure.ac: + Added Python language bindings contributed by Nikolai SAOUKH. + Thanks! + + * lib/regex.c (tre_have_backrefs, tre_have_approx): Added these + functions to query from a compiled regexp whether it uses back + references or approximate matching, respectively. + +Sun Aug 29 19:30:01 2004 Ville Laurikari + + * Added the reguexec() function. It can be used to match regexps + over arbitrary data structures, since characters are fed to the + matcher loop one by one with a user specified function. Unless + the backtracking matcher is used, the user specified function does + not even need to keep the whole string in memory at once. + + * tests/test-str-source.c: Test program for the above. + +Tue Aug 3 12:59:15 2004 Ville Laurikari + + * lib/regex.h: Added the REG_APPROX_MATCHER and + REG_BACKTRACKING_MATCHER execution flags to force using the + approximate matcher and backtracking matcher, respectively. + + * tests/retest.c: Rewrote to run tests with different pmatch[] and + nmatch arguments, different compilation flags and different + matcher loops. + + * lib/tre-match-approx.c (tre_tnfa_run_approx): Fixed to work + correctly in multibyte mode. Before the approximate matcher did + not find matches if there were characters more than one byte long + in the string. + +Sun Aug 1 19:42:59 2004 Ville Laurikari + + * lib/tre-compile.c (tre_parse): Added support for \Q and \E for + turning REG_LITERAL on for parts of a regexp. + +Mon Jul 5 16:22:11 2004 Ville Laurikari + + * configure.ac: Fixed to prepend "-lgnugetopt" to LIBS if + gnugetopt is needed for getopt_long(). + +Sat Jul 3 12:47:51 2004 Ville Laurikari + + * lib/tre-compile.c, lib/regex.h: Added a new compilation flag + REG_RIGHT_ASSOC. It can be used to change concatenation + associativity from left associative (the default) to right + associative. + + * lib/tre-compile.c (tre_parse): Added support for (?inr-inr) + and
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Fri Nov 17 16:16:19 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: regcomp.c regexec.c tre-compile.c Log Message: Disable tre_reg*b() when we don't have REG_USEBYTES. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/regcomp.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/tre/dist/lib/regexec.c cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/lib/tre-compile.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/regcomp.c diff -u src/external/bsd/tre/dist/lib/regcomp.c:1.4 src/external/bsd/tre/dist/lib/regcomp.c:1.5 --- src/external/bsd/tre/dist/lib/regcomp.c:1.4 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/regcomp.c Fri Nov 17 16:16:19 2017 @@ -99,6 +99,7 @@ tre_regncomp(regex_t *preg, const char * return ret; } +#ifdef REG_USEBYTES /* this version takes bytes literally, to be used with raw vectors */ int tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags) @@ -123,6 +124,7 @@ tre_regncompb(regex_t *preg, const char return ret; } +#endif /* REG_USEBYTES */ int tre_regcomp(regex_t *preg, const char *regex, int cflags) @@ -130,6 +132,7 @@ tre_regcomp(regex_t *preg, const char *r return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } +#ifdef REG_USEBYTES int tre_regcompb(regex_t *preg, const char *regex, int cflags) { @@ -151,6 +154,7 @@ tre_regcompb(regex_t *preg, const char * xfree(wregex); return ret; } +#endif /* REG_USEBYTES */ #ifdef TRE_WCHAR Index: src/external/bsd/tre/dist/lib/regexec.c diff -u src/external/bsd/tre/dist/lib/regexec.c:1.8 src/external/bsd/tre/dist/lib/regexec.c:1.9 --- src/external/bsd/tre/dist/lib/regexec.c:1.8 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/regexec.c Fri Nov 17 16:16:19 2017 @@ -227,6 +227,7 @@ tre_regexec(const regex_t *preg, const c return ret; } +#ifdef REG_USEBYTES int tre_regexecb(const regex_t *preg, const char *str, size_t nmatch, regmatch_t pmatch[], int eflags) @@ -244,6 +245,7 @@ tre_regnexecb(const regex_t *preg, const return tre_match(tnfa, str, len, STR_BYTE, nmatch, pmatch, eflags); } +#endif /* REG_USEBYTES */ #ifdef TRE_WCHAR @@ -364,6 +366,7 @@ tre_regaexec(const regex_t *preg, const return tre_reganexec(preg, str, (unsigned)-1, match, params, eflags); } +#ifdef REG_USEBYTES int tre_regaexecb(const regex_t *preg, const char *str, regamatch_t *match, regaparams_t params, int eflags) @@ -373,6 +376,7 @@ tre_regaexecb(const regex_t *preg, const return tre_match_approx(tnfa, str, (unsigned)-1, STR_BYTE, match, params, eflags); } +#endif /* REG_USEBYTES */ #ifdef TRE_WCHAR Index: src/external/bsd/tre/dist/lib/tre-compile.c diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.3 src/external/bsd/tre/dist/lib/tre-compile.c:1.4 --- src/external/bsd/tre/dist/lib/tre-compile.c:1.3 Fri Nov 17 16:14:30 2017 +++ src/external/bsd/tre/dist/lib/tre-compile.c Fri Nov 17 16:16:19 2017 @@ -1891,7 +1891,11 @@ tre_compile(regex_t *preg, const tre_cha parse_ctx.cflags = cflags; parse_ctx.max_backref = -1; /* workaround for PR#14408: use 8-bit optimizations in 8-bit mode */ +#ifdef REG_USEBYTES parse_ctx.cur_max = (cflags & REG_USEBYTES) ? 1 : TRE_MB_CUR_MAX; +#else + parse_ctx.cur_max = TRE_MB_CUR_MAX; +#endif DPRINT(("tre_compile: parsing '%.*" STRF "'\n", (int)n, regex)); errcode = tre_parse(_ctx); if (errcode != REG_OK)
CVS commit: src/external/bsd/tre/dist
Module Name:src Committed By: rin Date: Fri Nov 17 16:14:31 UTC 2017 Modified Files: src/external/bsd/tre/dist: configure.ac src/external/bsd/tre/dist/lib: regcomp.c regexec.c tre-compile.c tre-internal.h tre-match-approx.c tre-match-backtrack.c tre-match-parallel.c tre-match-utils.h tre-parse.c tre-parse.h tre-stack.h tre.h Removed Files: src/external/bsd/tre/dist: ABOUT-NLS ChangeLog INSTALL Makefile.in README aclocal.m4 config.h.in configure Log Message: Merge tre as of 20171117. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/ABOUT-NLS \ src/external/bsd/tre/dist/ChangeLog src/external/bsd/tre/dist/INSTALL \ src/external/bsd/tre/dist/Makefile.in src/external/bsd/tre/dist/README \ src/external/bsd/tre/dist/aclocal.m4 \ src/external/bsd/tre/dist/config.h.in src/external/bsd/tre/dist/configure cvs rdiff -u -r1.2 -r1.3 src/external/bsd/tre/dist/configure.ac cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/lib/regcomp.c \ src/external/bsd/tre/dist/lib/tre-parse.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/tre/dist/lib/regexec.c cvs rdiff -u -r1.2 -r1.3 src/external/bsd/tre/dist/lib/tre-compile.c \ src/external/bsd/tre/dist/lib/tre-internal.h \ src/external/bsd/tre/dist/lib/tre-match-approx.c \ src/external/bsd/tre/dist/lib/tre-match-parallel.c \ src/external/bsd/tre/dist/lib/tre-match-utils.h \ src/external/bsd/tre/dist/lib/tre-parse.h \ src/external/bsd/tre/dist/lib/tre-stack.h cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/tre-match-backtrack.c \ src/external/bsd/tre/dist/lib/tre.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/configure.ac diff -u src/external/bsd/tre/dist/configure.ac:1.2 src/external/bsd/tre/dist/configure.ac:1.3 --- src/external/bsd/tre/dist/configure.ac:1.2 Fri Nov 17 14:37:37 2017 +++ src/external/bsd/tre/dist/configure.ac Fri Nov 17 16:14:30 2017 @@ -1,9 +1,9 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(TRE, 0.8.0, [tre-gene...@lists.laurikari.net]) +AC_INIT(TRE, 0.8.0) AC_CONFIG_SRCDIR([lib/regcomp.c]) AC_CONFIG_AUX_DIR(utils) AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE(1.9.0) +AM_INIT_AUTOMAKE([foreign]) AC_PREREQ(2.59) AM_GNU_GETTEXT_VERSION(0.17) Index: src/external/bsd/tre/dist/lib/regcomp.c diff -u src/external/bsd/tre/dist/lib/regcomp.c:1.3 src/external/bsd/tre/dist/lib/regcomp.c:1.4 --- src/external/bsd/tre/dist/lib/regcomp.c:1.3 Sat Nov 5 22:39:13 2011 +++ src/external/bsd/tre/dist/lib/regcomp.c Fri Nov 17 16:14:30 2017 @@ -99,12 +99,59 @@ tre_regncomp(regex_t *preg, const char * return ret; } +/* this version takes bytes literally, to be used with raw vectors */ +int +tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags) +{ + int ret; +#if TRE_WCHAR /* wide chars = we need to convert it all to the wide format */ + tre_char_t *wregex; + size_t i; + + wregex = xmalloc(sizeof(tre_char_t) * n); + if (wregex == NULL) +return REG_ESPACE; + + for (i = 0; i < n; i++) +wregex[i] = (tre_char_t) ((unsigned char) regex[i]); + + ret = tre_compile(preg, wregex, n, cflags | REG_USEBYTES); + xfree(wregex); +#else /* !TRE_WCHAR */ + ret = tre_compile(preg, (const tre_char_t *)regex, n, cflags | REG_USEBYTES); +#endif /* !TRE_WCHAR */ + + return ret; +} + int tre_regcomp(regex_t *preg, const char *regex, int cflags) { return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } +int +tre_regcompb(regex_t *preg, const char *regex, int cflags) +{ + int ret; + tre_char_t *wregex; + size_t wlen, n = strlen(regex); + unsigned int i; + const unsigned char *str = (const unsigned char *)regex; + tre_char_t *wstr; + + wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); + if (wregex == NULL) return REG_ESPACE; + wstr = wregex; + + for (i = 0; i < n; i++) *(wstr++) = *(str++); + wlen = n; + wregex[wlen] = L'\0'; + ret = tre_compile(preg, wregex, wlen, cflags | REG_USEBYTES); + xfree(wregex); + return ret; +} + #ifdef TRE_WCHAR int Index: src/external/bsd/tre/dist/lib/tre-parse.c diff -u src/external/bsd/tre/dist/lib/tre-parse.c:1.3 src/external/bsd/tre/dist/lib/tre-parse.c:1.4 --- src/external/bsd/tre/dist/lib/tre-parse.c:1.3 Sat Nov 5 22:39:13 2011 +++ src/external/bsd/tre/dist/lib/tre-parse.c Fri Nov 17 16:14:30 2017 @@ -133,7 +133,7 @@ tre_expand_ctype(tre_mem_t mem, tre_ctyp DPRINT((" expanding class to character ranges\n")); for (j = 0; (j < 256) && (status == REG_OK); j++) { - c = j; + c = (tre_cint_t) j; if (tre_isctype(c, class) || ((cflags & REG_ICASE) && (tre_isctype(tre_tolower(c), class) @@ -346,7 +346,7 @@ tre_parse_bracket_items(tre_parse_ctx_t if (!class) status = REG_ECTYPE; /* Optimize character classes for 8 bit
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Mon Nov 13 00:53:05 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: regexec.c Log Message: Apply the previous fix to tre_regwexec(). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/tre/dist/lib/regexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/regexec.c diff -u src/external/bsd/tre/dist/lib/regexec.c:1.6 src/external/bsd/tre/dist/lib/regexec.c:1.7 --- src/external/bsd/tre/dist/lib/regexec.c:1.6 Sun Nov 12 20:56:37 2017 +++ src/external/bsd/tre/dist/lib/regexec.c Mon Nov 13 00:53:05 2017 @@ -243,26 +243,25 @@ tre_regwexec(const regex_t *preg, const size_t nmatch, regmatch_t pmatch[], int eflags) { size_t shift, len, i; - int startend, ret; + int ret; tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; regmatch_t *p; if (eflags & REG_STARTEND) { - if (pmatch == NULL || pmatch->rm_so < 0 + if (pmatch == NULL || pmatch->rm_so < 0 || pmatch->rm_eo < 0 || pmatch->rm_so > pmatch->rm_eo) return REG_INVARG; str += shift = pmatch->rm_so; len = pmatch->rm_eo - pmatch->rm_so; - eflags = (unsigned)(eflags & ~REG_STARTEND); - startend = 1; + eflags &= ~REG_STARTEND; } else { + shift = 0; len = (size_t)-1; - startend = 0; } ret = tre_regwnexec(preg, str, len, nmatch, pmatch, eflags); - if (!ret && !(tnfa->cflags & REG_NOSUB) && startend) { + if (!ret && !(tnfa->cflags & REG_NOSUB) && len != (size_t)-1) { for (i = nmatch, p = pmatch; i > 0; p++, i--) { if (p->rm_so >= 0) p->rm_so += shift; if (p->rm_eo >= 0) p->rm_eo += shift;
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: christos Date: Sun Nov 12 20:56:37 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: regexec.c Log Message: check more eo, initialize shift, remove useless variable. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/tre/dist/lib/regexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/regexec.c diff -u src/external/bsd/tre/dist/lib/regexec.c:1.5 src/external/bsd/tre/dist/lib/regexec.c:1.6 --- src/external/bsd/tre/dist/lib/regexec.c:1.5 Sun Nov 12 11:10:59 2017 +++ src/external/bsd/tre/dist/lib/regexec.c Sun Nov 12 15:56:37 2017 @@ -199,26 +199,25 @@ tre_regexec(const regex_t *preg, const c size_t nmatch, regmatch_t pmatch[], int eflags) { size_t shift, len, i; - int startend, ret; + int ret; tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; regmatch_t *p; if (eflags & REG_STARTEND) { - if (pmatch == NULL || pmatch->rm_so < 0 + if (pmatch == NULL || pmatch->rm_so < 0 || pmatch->rm_eo < 0 || pmatch->rm_so > pmatch->rm_eo) return REG_INVARG; str += shift = pmatch->rm_so; len = pmatch->rm_eo - pmatch->rm_so; - eflags = (unsigned)(eflags & ~REG_STARTEND); - startend = 1; + eflags &= ~REG_STARTEND; } else { + shift = 0; len = (size_t)-1; - startend = 0; } ret = tre_regnexec(preg, str, len, nmatch, pmatch, eflags); - if (!ret && !(tnfa->cflags & REG_NOSUB) && startend) { + if (!ret && !(tnfa->cflags & REG_NOSUB) && len != (size_t)-1) { for (i = nmatch, p = pmatch; i > 0; p++, i--) { if (p->rm_so >= 0) p->rm_so += shift; if (p->rm_eo >= 0) p->rm_eo += shift;
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: rin Date: Sun Nov 12 16:10:59 UTC 2017 Modified Files: src/external/bsd/tre/dist/lib: regexec.c Log Message: Make REG_STARTEND for tre_regcomp() working actually: - correct string length - shift pmatch after pattern matching - check validity of arguments Do the same thing for tre_regwcomp() To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/regexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/regexec.c diff -u src/external/bsd/tre/dist/lib/regexec.c:1.4 src/external/bsd/tre/dist/lib/regexec.c:1.5 --- src/external/bsd/tre/dist/lib/regexec.c:1.4 Sat Nov 5 22:39:13 2011 +++ src/external/bsd/tre/dist/lib/regexec.c Sun Nov 12 16:10:59 2017 @@ -198,22 +198,34 @@ int tre_regexec(const regex_t *preg, const char *str, size_t nmatch, regmatch_t pmatch[], int eflags) { - const char *newstr; - unsigned newflags; - size_t newlen; + size_t shift, len, i; + int startend, ret; + tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; + regmatch_t *p; if (eflags & REG_STARTEND) { - /* LINTED */ - newstr = [pmatch[0].rm_so]; - /* LINTED */ - newlen = pmatch[0].rm_eo; - newflags = (unsigned)(eflags & ~REG_STARTEND); + if (pmatch == NULL || pmatch->rm_so < 0 + || pmatch->rm_so > pmatch->rm_eo) + return REG_INVARG; + str += shift = pmatch->rm_so; + len = pmatch->rm_eo - pmatch->rm_so; + eflags = (unsigned)(eflags & ~REG_STARTEND); + startend = 1; } else { - newstr = str; - newlen = (size_t)-1; - newflags = (unsigned)eflags; + len = (size_t)-1; + startend = 0; } - return tre_regnexec(preg, newstr, newlen, nmatch, pmatch, (int)newflags); + + ret = tre_regnexec(preg, str, len, nmatch, pmatch, eflags); + + if (!ret && !(tnfa->cflags & REG_NOSUB) && startend) { + for (i = nmatch, p = pmatch; i > 0; p++, i--) { + if (p->rm_so >= 0) p->rm_so += shift; + if (p->rm_eo >= 0) p->rm_eo += shift; + } + } + + return ret; } @@ -231,7 +243,34 @@ int tre_regwexec(const regex_t *preg, const wchar_t *str, size_t nmatch, regmatch_t pmatch[], int eflags) { - return tre_regwnexec(preg, str, (unsigned)-1, nmatch, pmatch, eflags); + size_t shift, len, i; + int startend, ret; + tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; + regmatch_t *p; + + if (eflags & REG_STARTEND) { + if (pmatch == NULL || pmatch->rm_so < 0 + || pmatch->rm_so > pmatch->rm_eo) + return REG_INVARG; + str += shift = pmatch->rm_so; + len = pmatch->rm_eo - pmatch->rm_so; + eflags = (unsigned)(eflags & ~REG_STARTEND); + startend = 1; + } else { + len = (size_t)-1; + startend = 0; + } + + ret = tre_regwnexec(preg, str, len, nmatch, pmatch, eflags); + + if (!ret && !(tnfa->cflags & REG_NOSUB) && startend) { + for (i = nmatch, p = pmatch; i > 0; p++, i--) { + if (p->rm_so >= 0) p->rm_so += shift; + if (p->rm_eo >= 0) p->rm_eo += shift; + } + } + + return ret; } #endif /* TRE_WCHAR */
CVS commit: src/external/bsd/tre/dist/src
Module Name:src Committed By: joerg Date: Thu Nov 17 16:21:08 UTC 2011 Modified Files: src/external/bsd/tre/dist/src: agrep.c Log Message: Use __dead To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/tre/dist/src/agrep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/src/agrep.c diff -u src/external/bsd/tre/dist/src/agrep.c:1.1.1.1 src/external/bsd/tre/dist/src/agrep.c:1.2 --- src/external/bsd/tre/dist/src/agrep.c:1.1.1.1 Thu Feb 25 07:33:19 2010 +++ src/external/bsd/tre/dist/src/agrep.c Thu Nov 17 16:21:08 2011 @@ -88,7 +88,7 @@ static struct option const long_options[ }; #endif /* HAVE_GETOPT_LONG */ -static void +__dead static void tre_agrep_usage(int status) { if (status != 0)
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: joerg Date: Tue Nov 8 16:45:43 UTC 2011 Modified Files: src/external/bsd/tre/dist/lib: tre-match-backtrack.c Log Message: Don't use constant macros in conditionals, use a #if check. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/lib/tre-match-backtrack.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-match-backtrack.c diff -u src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.3 src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.4 --- src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.3 Sat Nov 5 22:39:13 2011 +++ src/external/bsd/tre/dist/lib/tre-match-backtrack.c Tue Nov 8 16:45:43 2011 @@ -585,12 +585,14 @@ tre_tnfa_run_backtrack(const tre_tnfa_t if (stack-prev) { DPRINT(( backtracking\n)); - if (stack-item.state-assertions ASSERT_BACKREF) +#if ASSERT_BACKREF + if (stack-item.state-assertions) { DPRINT(( states_seen[%d] = 0\n, stack-item.state_id)); states_seen[stack-item.state_id] = 0; } +#endif BT_STACK_POP(); }
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: agc Date: Thu Apr 22 17:28:59 UTC 2010 Modified Files: src/external/bsd/tre/dist/lib: tre-mem.c Log Message: clean up some lint To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/tre/dist/lib/tre-mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre-mem.c diff -u src/external/bsd/tre/dist/lib/tre-mem.c:1.1.1.1 src/external/bsd/tre/dist/lib/tre-mem.c:1.2 --- src/external/bsd/tre/dist/lib/tre-mem.c:1.1.1.1 Thu Feb 25 07:33:19 2010 +++ src/external/bsd/tre/dist/lib/tre-mem.c Thu Apr 22 17:28:59 2010 @@ -106,7 +106,7 @@ } else { - int block_size; + unsigned block_size; if (size * 8 TRE_MEM_BLOCK_SIZE) block_size = size * 8; else
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: agc Date: Thu Apr 22 17:32:37 UTC 2010 Modified Files: src/external/bsd/tre/dist/lib: tre.h Log Message: don't include parameter names in the namespace for function prototypes. define REG_STARTEND include tre-config.h inplace in tre.h, since it is small, always gets included anyway, and this means that we don't have to install tre-config.h in the dest tree. this will be addressed differently long-term. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/tre/dist/lib/tre.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/tre.h diff -u src/external/bsd/tre/dist/lib/tre.h:1.1.1.1 src/external/bsd/tre/dist/lib/tre.h:1.2 --- src/external/bsd/tre/dist/lib/tre.h:1.1.1.1 Thu Feb 25 07:33:19 2010 +++ src/external/bsd/tre/dist/lib/tre.h Thu Apr 22 17:32:37 2010 @@ -9,7 +9,58 @@ #ifndef TRE_H #define TRE_H 1 -#include tre-config.h +/* #include tre-config.h */ + +/* included tre-config.h inline below - agc */ +/* */ +/* lib/tre-config.h. Generated from tre-config.h.in by configure. */ +/* tre-config.h.in. This file has all definitions that are needed in + `tre.h'. Note that this file must contain only the bare minimum + of definitions without the TRE_ prefix to avoid conflicts between + definitions here and definitions included from somewhere else. */ + +/* Define to 1 if you have the libutf8.h header file. */ +/* #undef HAVE_LIBUTF8_H */ + +/* Define to 1 if the system has the type `reg_errcode_t'. */ +/* #undef HAVE_REG_ERRCODE_T */ + +/* Define to 1 if you have the sys/types.h header file. */ +/* #undef HAVE_SYS_TYPES_H */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define if you want to enable approximate matching functionality. */ +#define TRE_APPROX 1 + +/* Define to enable multibyte character set support. */ +#define TRE_MULTIBYTE 1 + +/* Define to the absolute path to the system tre.h */ +/* #undef TRE_SYSTEM_REGEX_H_PATH */ + +/* Define to include the system regex.h from tre.h */ +/* #undef TRE_USE_SYSTEM_REGEX_H */ + +/* Define to enable wide character (wchar_t) support. */ +#define TRE_WCHAR 1 + +/* TRE version string. */ +#define TRE_VERSION 0.8.0 + +/* TRE version level 1. */ +#define TRE_VERSION_1 0 + +/* TRE version level 2. */ +#define TRE_VERSION_2 8 + +/* TRE version level 3. */ +#define TRE_VERSION_3 0 + +/* */ +/* end of tre-config.h */ #ifdef HAVE_SYS_TYPES_H #include sys/types.h @@ -114,6 +165,9 @@ #define REG_APPROX_MATCHER (REG_NOTEOL 1) #define REG_BACKTRACKING_MATCHER (REG_APPROX_MATCHER 1) +/* emulate Spencer regexp behavior with tre_regnexec */ +#define REG_STARTEND (REG_BACKTRACKING_MATCHER 1) + #endif /* !TRE_USE_SYSTEM_REGEX_H */ /* REG_NOSPEC and REG_LITERAL mean the same thing. */ @@ -129,18 +183,16 @@ /* The POSIX.2 regexp functions */ extern int -tre_regcomp(regex_t *preg, const char *regex, int cflags); +tre_regcomp(regex_t *, const char *, int); extern int -tre_regexec(const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags); +tre_regexec(const regex_t *, const char *, size_t, regmatch_t *, int); extern size_t -tre_regerror(int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size); +tre_regerror(int, const regex_t *, char *, size_t); extern void -tre_regfree(regex_t *preg); +tre_regfree(regex_t *); #ifdef TRE_WCHAR #ifdef HAVE_WCHAR_H @@ -149,29 +201,29 @@ /* Wide character versions (not in POSIX.2). */ extern int -tre_regwcomp(regex_t *preg, const wchar_t *regex, int cflags); +tre_regwcomp(regex_t *, const wchar_t *, int); extern int -tre_regwexec(const regex_t *preg, const wchar_t *string, - size_t nmatch, regmatch_t pmatch[], int eflags); +tre_regwexec(const regex_t *, const wchar_t *, + size_t, regmatch_t [], int); #endif /* TRE_WCHAR */ /* Versions with a maximum length argument and therefore the capability to handle null characters in the middle of the strings (not in POSIX.2). */ extern int -tre_regncomp(regex_t *preg, const char *regex, size_t len, int cflags); +tre_regncomp(regex_t *, const char *, size_t, int); extern int -tre_regnexec(const regex_t *preg, const char *string, size_t len, - size_t nmatch, regmatch_t pmatch[], int eflags); +tre_regnexec(const regex_t *, const char *, size_t, + size_t, regmatch_t [], int); #ifdef TRE_WCHAR extern int -tre_regwncomp(regex_t *preg, const wchar_t *regex, size_t len, int cflags); +tre_regwncomp(regex_t *, const wchar_t *, size_t, int); extern int -tre_regwnexec(const regex_t *preg, const wchar_t *string, size_t len, - size_t nmatch, regmatch_t pmatch[], int eflags); +tre_regwnexec(const regex_t *, const wchar_t *, size_t, + size_t, regmatch_t [], int); #endif /* TRE_WCHAR */ #ifdef TRE_APPROX @@ -202,26 +254,26 @@ /*
CVS commit: src/external/bsd/tre/dist/lib
Module Name:src Committed By: agc Date: Thu Apr 22 17:33:54 UTC 2010 Modified Files: src/external/bsd/tre/dist/lib: regexec.c Log Message: implement the REG_STARTEND extension using tre_regnexec - REG_STARTEND is used by mail(1), and file(1), to name but two. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/tre/dist/lib/regexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/tre/dist/lib/regexec.c diff -u src/external/bsd/tre/dist/lib/regexec.c:1.1.1.1 src/external/bsd/tre/dist/lib/regexec.c:1.2 --- src/external/bsd/tre/dist/lib/regexec.c:1.1.1.1 Thu Feb 25 07:33:19 2010 +++ src/external/bsd/tre/dist/lib/regexec.c Thu Apr 22 17:33:54 2010 @@ -213,7 +213,20 @@ tre_regexec(const regex_t *preg, const char *str, size_t nmatch, regmatch_t pmatch[], int eflags) { - return tre_regnexec(preg, str, (unsigned)-1, nmatch, pmatch, eflags); + const char *newstr; + unsigned newflags; + size_t newlen; + + if (eflags REG_STARTEND) { + newstr = str[pmatch[0].rm_so]; + newlen = pmatch[0].rm_eo; + newflags = (unsigned)(eflags ~REG_STARTEND); + } else { + newstr = str; + newlen = (size_t)-1; + newflags = (unsigned)eflags; + } + return tre_regnexec(preg, newstr, newlen, nmatch, pmatch, (int)newflags); }
CVS commit: src/external/bsd/tre/dist
Module Name:src Committed By: agc Date: Thu Feb 25 07:33:20 UTC 2010 Update of /cvsroot/src/external/bsd/tre/dist In directory ivanova.netbsd.org:/tmp/cvs-serv24396 Log Message: initial import of tre-0.8.0 into the external sources framework. with many thanks to ville laurikari for writing tre in the first place and for changing the licensing to a 2-clause bsd license; thanks also to matthias-christian ott for his work on the google summer of code 2009 project. this import brings the distribution to src/external - the reachover build files will follow Status: Vendor Tag: LAURIKARI Release Tags: tre-0-8-0-base N src/external/bsd/tre/dist/NEWS N src/external/bsd/tre/dist/Makefile.am N src/external/bsd/tre/dist/ChangeLog N src/external/bsd/tre/dist/tre.pc.in N src/external/bsd/tre/dist/AUTHORS N src/external/bsd/tre/dist/config.h.in N src/external/bsd/tre/dist/THANKS N src/external/bsd/tre/dist/LICENSE N src/external/bsd/tre/dist/tre.spec.in N src/external/bsd/tre/dist/README N src/external/bsd/tre/dist/configure N src/external/bsd/tre/dist/Makefile.in N src/external/bsd/tre/dist/ABOUT-NLS N src/external/bsd/tre/dist/configure.ac N src/external/bsd/tre/dist/TODO N src/external/bsd/tre/dist/aclocal.m4 N src/external/bsd/tre/dist/INSTALL N src/external/bsd/tre/dist/python/example.py N src/external/bsd/tre/dist/python/setup.py N src/external/bsd/tre/dist/python/tre-python.c N src/external/bsd/tre/dist/doc/tre-syntax.html N src/external/bsd/tre/dist/doc/Makefile.am N src/external/bsd/tre/dist/doc/default.css N src/external/bsd/tre/dist/doc/Makefile.in N src/external/bsd/tre/dist/doc/agrep.1.in N src/external/bsd/tre/dist/doc/tre-api.html N src/external/bsd/tre/dist/utils/mkinstalldirs N src/external/bsd/tre/dist/utils/config.guess N src/external/bsd/tre/dist/utils/Makefile.am N src/external/bsd/tre/dist/utils/build-rpm.sh N src/external/bsd/tre/dist/utils/missing N src/external/bsd/tre/dist/utils/install-sh N src/external/bsd/tre/dist/utils/Makefile.in N src/external/bsd/tre/dist/utils/depcomp N src/external/bsd/tre/dist/utils/autogen.sh N src/external/bsd/tre/dist/utils/config.sub N src/external/bsd/tre/dist/utils/compile N src/external/bsd/tre/dist/utils/ltmain.sh N src/external/bsd/tre/dist/utils/config.rpath N src/external/bsd/tre/dist/lib/tre-match-backtrack.c N src/external/bsd/tre/dist/lib/tre-config.h.in N src/external/bsd/tre/dist/lib/tre-internal.h N src/external/bsd/tre/dist/lib/tre-compile.h N src/external/bsd/tre/dist/lib/Makefile.am N src/external/bsd/tre/dist/lib/tre-parse.c N src/external/bsd/tre/dist/lib/xmalloc.h N src/external/bsd/tre/dist/lib/tre-stack.c N src/external/bsd/tre/dist/lib/xmalloc.c N src/external/bsd/tre/dist/lib/tre-match-approx.c N src/external/bsd/tre/dist/lib/regerror.c N src/external/bsd/tre/dist/lib/tre-compile.c N src/external/bsd/tre/dist/lib/regcomp.c N src/external/bsd/tre/dist/lib/tre-stack.h N src/external/bsd/tre/dist/lib/Makefile.in N src/external/bsd/tre/dist/lib/regexec.c N src/external/bsd/tre/dist/lib/tre-ast.c N src/external/bsd/tre/dist/lib/regex.h N src/external/bsd/tre/dist/lib/tre-ast.h N src/external/bsd/tre/dist/lib/tre-parse.h N src/external/bsd/tre/dist/lib/README N src/external/bsd/tre/dist/lib/tre-match-utils.h N src/external/bsd/tre/dist/lib/tre-mem.c N src/external/bsd/tre/dist/lib/tre.h N src/external/bsd/tre/dist/lib/tre-mem.h N src/external/bsd/tre/dist/lib/tre-match-parallel.c N src/external/bsd/tre/dist/tests/build-tests.sh N src/external/bsd/tre/dist/tests/Makefile.am N src/external/bsd/tre/dist/tests/test-str-source.c N src/external/bsd/tre/dist/tests/randtest.c N src/external/bsd/tre/dist/tests/retest.c N src/external/bsd/tre/dist/tests/bench.c N src/external/bsd/tre/dist/tests/Makefile.in N src/external/bsd/tre/dist/tests/agrep/exitstatus.input N src/external/bsd/tre/dist/tests/agrep/Makefile.am N src/external/bsd/tre/dist/tests/agrep/delimiters.ok N src/external/bsd/tre/dist/tests/agrep/run-tests.sh N src/external/bsd/tre/dist/tests/agrep/records.args N src/external/bsd/tre/dist/tests/agrep/delimiters.input N src/external/bsd/tre/dist/tests/agrep/delimiters.args N src/external/bsd/tre/dist/tests/agrep/exitstatus.ok N src/external/bsd/tre/dist/tests/agrep/basic.input N src/external/bsd/tre/dist/tests/agrep/exitstatus.args N src/external/bsd/tre/dist/tests/agrep/basic.args N src/external/bsd/tre/dist/tests/agrep/Makefile.in N src/external/bsd/tre/dist/tests/agrep/records.ok N src/external/bsd/tre/dist/tests/agrep/records.input N src/external/bsd/tre/dist/tests/agrep/basic.ok N src/external/bsd/tre/dist/m4/ax_decl_wchar_max.m4 N src/external/bsd/tre/dist/m4/intlmacosx.m4 N src/external/bsd/tre/dist/m4/Makefile.am N src/external/bsd/tre/dist/m4/iconv.m4 N src/external/bsd/tre/dist/m4/lib-prefix.m4 N src/external/bsd/tre/dist/m4/gettext.m4 N src/external/bsd/tre/dist/m4/progtest.m4 N src/external/bsd/tre/dist/m4/po.m4 N src/external/bsd/tre/dist/m4/nls.m4 N