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, [[email protected]])
+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 character sets. */
- /* CONSTCOND */if (status == REG_OK && TRE_MB_CUR_MAX == 1)
+ if (status == REG_OK && ctx->cur_max == 1)
{
status = tre_expand_ctype(ctx->mem, class, items,
&i, &max_i, ctx->cflags);
@@ -1224,7 +1224,7 @@ tre_parse(tre_parse_ctx_t *ctx)
DPRINT(("tre_parse: extension: '%.*" STRF "\n",
REST(ctx->re)));
ctx->re += 2;
- while (/*CONSTCOND*/1)
+ while (/*CONSTCOND*/(void)1,1)
{
if (*ctx->re == L'i')
{
Index: src/external/bsd/tre/dist/lib/regexec.c
diff -u src/external/bsd/tre/dist/lib/regexec.c:1.7 src/external/bsd/tre/dist/lib/regexec.c:1.8
--- src/external/bsd/tre/dist/lib/regexec.c:1.7 Mon Nov 13 00:53:05 2017
+++ src/external/bsd/tre/dist/lib/regexec.c Fri Nov 17 16:14:30 2017
@@ -227,6 +227,24 @@ tre_regexec(const regex_t *preg, const c
return ret;
}
+int
+tre_regexecb(const regex_t *preg, const char *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_BYTE, nmatch, pmatch, eflags);
+}
+
+int
+tre_regnexecb(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;
+
+ return tre_match(tnfa, str, len, STR_BYTE, nmatch, pmatch, eflags);
+}
+
#ifdef TRE_WCHAR
@@ -346,6 +364,16 @@ tre_regaexec(const regex_t *preg, const
return tre_reganexec(preg, str, (unsigned)-1, match, params, eflags);
}
+int
+tre_regaexecb(const regex_t *preg, const char *str,
+ regamatch_t *match, regaparams_t params, int eflags)
+{
+ tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
+
+ return tre_match_approx(tnfa, str, (unsigned)-1, STR_BYTE,
+ match, params, eflags);
+}
+
#ifdef TRE_WCHAR
int
Index: src/external/bsd/tre/dist/lib/tre-compile.c
diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.2 src/external/bsd/tre/dist/lib/tre-compile.c:1.3
--- src/external/bsd/tre/dist/lib/tre-compile.c:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-compile.c Fri Nov 17 16:14:30 2017
@@ -1619,8 +1619,8 @@ tre_make_trans(tre_pos_and_tags_t *p1, t
(trans + 1)->state = NULL;
/* Use the character ranges, assertions, etc. from `p1' for
the transition from `p1' to `p2'. */
- trans->code_min = p1->code_min;
- trans->code_max = p1->code_max;
+ trans->code_min = (tre_cint_t) p1->code_min;
+ trans->code_max = (tre_cint_t) p1->code_max;
trans->state = transitions + offs[p2->position];
trans->state_id = p2->position;
trans->assertions = p1->assertions | p2->assertions
@@ -1845,10 +1845,10 @@ tre_ast_to_tnfa(tre_ast_node_t *node, tr
do \
{ \
errcode = err; \
- if (/*CONSTCOND*/1) \
+ if (/*CONSTCOND*/(void)1,1) \
goto error_exit; \
} \
- while (/*CONSTCOND*/0)
+ while (/*CONSTCOND*/(void)0,0)
int
@@ -1890,6 +1890,8 @@ tre_compile(regex_t *preg, const tre_cha
parse_ctx.len = n;
parse_ctx.cflags = cflags;
parse_ctx.max_backref = -1;
+ /* workaround for PR#14408: use 8-bit optimizations in 8-bit mode */
+ parse_ctx.cur_max = (cflags & REG_USEBYTES) ? 1 : TRE_MB_CUR_MAX;
DPRINT(("tre_compile: parsing '%.*" STRF "'\n", (int)n, regex));
errcode = tre_parse(&parse_ctx);
if (errcode != REG_OK)
Index: src/external/bsd/tre/dist/lib/tre-internal.h
diff -u src/external/bsd/tre/dist/lib/tre-internal.h:1.2 src/external/bsd/tre/dist/lib/tre-internal.h:1.3
--- src/external/bsd/tre/dist/lib/tre-internal.h:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-internal.h Fri Nov 17 16:14:30 2017
@@ -22,9 +22,9 @@
#ifdef TRE_DEBUG
#include <stdio.h>
-#define DPRINT(msg) do {printf msg; fflush(stdout);} while(/*CONSTCOND*/0)
+#define DPRINT(msg) do {printf msg; fflush(stdout);} while(/*CONSTCOND*/(void)0,0)
#else /* !TRE_DEBUG */
-#define DPRINT(msg) do { } while(/*CONSTCOND*/0)
+#define DPRINT(msg) do { } while(/*CONSTCOND*/(void)0,0)
#endif /* !TRE_DEBUG */
#define elementsof(x) ( sizeof(x) / sizeof(x[0]) )
Index: src/external/bsd/tre/dist/lib/tre-match-approx.c
diff -u src/external/bsd/tre/dist/lib/tre-match-approx.c:1.2 src/external/bsd/tre/dist/lib/tre-match-approx.c:1.3
--- src/external/bsd/tre/dist/lib/tre-match-approx.c:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-match-approx.c Fri Nov 17 16:14:30 2017
@@ -307,7 +307,7 @@ tre_tnfa_run_approx(const tre_tnfa_t *tn
GET_NEXT_WCHAR();
pos = 0;
- while (/*CONSTCOND*/1)
+ while (/*CONSTCOND*/(void)1,1)
{
DPRINT(("%03d:%2lc/%05d\n", pos, (tre_cint_t)next_c, (int)next_c));
Index: src/external/bsd/tre/dist/lib/tre-match-parallel.c
diff -u src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.2 src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.3
--- src/external/bsd/tre/dist/lib/tre-match-parallel.c:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-match-parallel.c Fri Nov 17 16:14:30 2017
@@ -254,7 +254,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *
DPRINT(("-------------+------------------------------------------------\n"));
reach_next_i = reach_next;
- while (/*CONSTCOND*/1)
+ while (/*CONSTCOND*/(void)1,1)
{
/* If no match found yet, add the initial states to `reach_next'. */
if (match_eo < 0)
@@ -305,7 +305,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *
else
{
if (num_tags == 0 || reach_next_i == reach_next)
- /*�We have found a match. */
+ /* We have found a match. */
break;
}
Index: src/external/bsd/tre/dist/lib/tre-match-utils.h
diff -u src/external/bsd/tre/dist/lib/tre-match-utils.h:1.2 src/external/bsd/tre/dist/lib/tre-match-utils.h:1.3
--- src/external/bsd/tre/dist/lib/tre-match-utils.h:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-match-utils.h Fri Nov 17 16:14:30 2017
@@ -71,10 +71,9 @@
case STR_USER: \
pos += pos_add_next; \
str_user_end = str_source->get_next_char(&next_c, &pos_add_next, \
- str_source->context); \
- break; \
- } \
- } while(/*CONSTCOND*/0)
+ str_source->context); \
+ } \
+ } while(/*CONSTCOND*/(void)0,0)
#else /* !TRE_MULTIBYTE */
@@ -102,9 +101,8 @@
pos += pos_add_next; \
str_user_end = str_source->get_next_char(&next_c, &pos_add_next, \
str_source->context); \
- break; \
- } \
- } while(/*CONSTCOND*/0)
+ } \
+ } while(/*CONSTCOND*/(void)0,0)
#endif /* !TRE_MULTIBYTE */
@@ -127,9 +125,8 @@
pos += pos_add_next; \
str_user_end = str_source->get_next_char(&next_c, &pos_add_next, \
str_source->context); \
- break; \
- } \
- } while(/*CONSTCOND*/0)
+ } \
+ } while(/*CONSTCOND*/(void)0,0)
#endif /* !TRE_WCHAR */
Index: src/external/bsd/tre/dist/lib/tre-parse.h
diff -u src/external/bsd/tre/dist/lib/tre-parse.h:1.2 src/external/bsd/tre/dist/lib/tre-parse.h:1.3
--- src/external/bsd/tre/dist/lib/tre-parse.h:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-parse.h Fri Nov 17 16:14:30 2017
@@ -38,6 +38,8 @@ typedef struct {
int nofirstsub;
/* The currently set approximate matching parameters. */
int params[TRE_PARAM_LAST];
+ /* the CUR_MAX in use */
+ int cur_max;
} tre_parse_ctx_t;
/* Parses a wide character regexp pattern into a syntax tree. This parser
Index: src/external/bsd/tre/dist/lib/tre-stack.h
diff -u src/external/bsd/tre/dist/lib/tre-stack.h:1.2 src/external/bsd/tre/dist/lib/tre-stack.h:1.3
--- src/external/bsd/tre/dist/lib/tre-stack.h:1.2 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-stack.h Fri Nov 17 16:14:30 2017
@@ -56,7 +56,7 @@ declare_popf(long, long);
{ \
status = tre_stack_push_ ## typetag(s, value); \
} \
- while (/*CONSTCOND*/0)
+ while (/*CONSTCOND*/(void)0,0)
#define STACK_PUSHX(s, typetag, value) \
{ \
Index: src/external/bsd/tre/dist/lib/tre-match-backtrack.c
diff -u src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.4 src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.5
--- src/external/bsd/tre/dist/lib/tre-match-backtrack.c:1.4 Tue Nov 8 16:45:43 2011
+++ src/external/bsd/tre/dist/lib/tre-match-backtrack.c Fri Nov 17 16:14:30 2017
@@ -99,7 +99,7 @@ typedef struct tre_backtrack_struct {
#ifdef TRE_USE_ALLOCA
#define tre_bt_mem_new tre_mem_newa
#define tre_bt_mem_alloc tre_mem_alloca
-#define tre_bt_mem_destroy(obj) do { } while (/*CONSTCOND*/0)
+#define tre_bt_mem_destroy(obj) do { } while (/*CONSTCOND*/(void)0,0)
#else /* !TRE_USE_ALLOCA */
#define tre_bt_mem_new tre_mem_new
#define tre_bt_mem_alloc tre_mem_alloc
@@ -156,7 +156,7 @@ typedef struct tre_backtrack_struct {
stack->item.tags[i] = (_tags)[i]; \
BT_STACK_MBSTATE_IN; \
} \
- while (/*CONSTCOND*/0)
+ while (/*CONSTCOND*/(void)0,0)
#define BT_STACK_POP() \
do \
@@ -169,13 +169,13 @@ typedef struct tre_backtrack_struct {
str_byte = stack->item.str_byte; \
BT_STACK_WIDE_OUT; \
state = stack->item.state; \
- next_c = stack->item.next_c; \
+ next_c = (tre_char_t) stack->item.next_c; \
for (i = 0; i < tnfa->num_tags; i++) \
tags[i] = stack->item.tags[i]; \
BT_STACK_MBSTATE_OUT; \
stack = stack->prev; \
} \
- while (/*CONSTCOND*/0)
+ while (/*CONSTCOND*/(void)0,0)
#undef MIN
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
@@ -355,7 +355,7 @@ tre_tnfa_run_backtrack(const tre_tnfa_t
if (state == NULL)
goto backtrack;
- while (/*CONSTCOND*/1)
+ while (/*CONSTCOND*/(void)1,1)
{
tre_tnfa_transition_t *next_state;
int empty_br_match;
@@ -617,7 +617,7 @@ tre_tnfa_run_backtrack(const tre_tnfa_t
}
}
DPRINT(("restarting from next start position\n"));
- next_c = next_c_start;
+ next_c = (tre_char_t) next_c_start;
#ifdef TRE_MBSTATE
mbstate = mbstate_start;
#endif /* TRE_MBSTATE */
Index: src/external/bsd/tre/dist/lib/tre.h
diff -u src/external/bsd/tre/dist/lib/tre.h:1.4 src/external/bsd/tre/dist/lib/tre.h:1.5
--- src/external/bsd/tre/dist/lib/tre.h:1.4 Sat Nov 5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre.h Fri Nov 17 16:14:30 2017
@@ -113,6 +113,8 @@ typedef enum {
#define REG_RIGHT_ASSOC (REG_LITERAL << 1)
#define REG_UNGREEDY (REG_RIGHT_ASSOC << 1)
+#define REG_USEBYTES (REG_UNGREEDY << 1)
+
/* POSIX tre_regexec() flags. */
#define REG_NOTBOL 1
#define REG_NOTEOL (REG_NOTBOL << 1)
@@ -142,6 +144,13 @@ extern int
tre_regexec(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags);
+extern int
+tre_regcompb(regex_t *preg, const char *regex, int cflags);
+
+extern int
+tre_regexecb(const regex_t *preg, const char *string, size_t nmatch,
+ regmatch_t pmatch[], int eflags);
+
extern size_t
tre_regerror(int errcode, const regex_t *preg, char *errbuf,
size_t errbuf_size);
@@ -172,6 +181,14 @@ extern int
tre_regnexec(const regex_t *preg, const char *string, size_t len,
size_t nmatch, regmatch_t pmatch[], int eflags);
+/* regn*b versions take byte literally as 8-bit values */
+extern int
+tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags);
+
+extern int
+tre_regnexecb(const regex_t *preg, const char *str, size_t len,
+ size_t nmatch, regmatch_t pmatch[], int eflags);
+
#ifdef TRE_WCHAR
extern int
tre_regwncomp(regex_t *preg, const wchar_t *regex, size_t len, int cflags);
@@ -215,6 +232,11 @@ tre_regaexec(const regex_t *preg, const
extern int
tre_reganexec(const regex_t *preg, const char *string, size_t len,
regamatch_t *match, regaparams_t params, int eflags);
+
+extern int
+tre_regaexecb(const regex_t *preg, const char *string,
+ regamatch_t *match, regaparams_t params, int eflags);
+
#ifdef TRE_WCHAR
/* Wide character approximate matching. */
extern int