merge from glibc
git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-16
This commit is contained in:
1 parent
c27b981aba
commit
a525606abd
6 files changed
+92
-77
No files matched your search
+12
-10
@@ -18,13 +18,15 @@ html:
|
||||
cd doc && make html
|
||||
|
||||
update-regex:
|
||||
cd lib && \
|
||||
HOST=sources.redhat.com && \
|
||||
BASEURL="http://$$HOST/cgi-bin/cvsweb.cgi/~checkout~/libc/posix" && \
|
||||
QUERY='cvsroot=glibc&content-type=text/plain' && \
|
||||
wget -O regcomp.c "$$BASEURL/regcomp.c?$$QUERY" && \
|
||||
wget -O regexec.c "$$BASEURL/regexec.c?$$QUERY" && \
|
||||
wget -O regex.c "$$BASEURL/regex.c?$$QUERY" && \
|
||||
wget -O regex_.h "$$BASEURL/regex.h?$$QUERY" && \
|
||||
wget -O regex_internal.c "$$BASEURL/regex_internal.c?$$QUERY" && \
|
||||
wget -O regex_internal.h "$$BASEURL/regex_internal.h?$$QUERY"
|
||||
HOST=sources.redhat.com && \
|
||||
BASEURL="http://$$HOST/cgi-bin/cvsweb.cgi/~checkout~/libc/posix" && \
|
||||
QUERY='cvsroot=glibc&content-type=text/plain' && \
|
||||
wget -O lib/regcomp.c "$$BASEURL/regcomp.c?$$QUERY" && \
|
||||
wget -O lib/regexec.c "$$BASEURL/regexec.c?$$QUERY" && \
|
||||
wget -O lib/regex.c "$$BASEURL/regex.c?$$QUERY" && \
|
||||
wget -O lib/regex_.h "$$BASEURL/regex.h?$$QUERY" && \
|
||||
wget -O lib/regex_internal.c "$$BASEURL/regex_internal.c?$$QUERY" && \
|
||||
wget -O lib/regex_internal.h "$$BASEURL/regex_internal.h?$$QUERY" && \
|
||||
wget -O testsuite/BOOST.tests "$$BASEURL/BOOST.tests?$$QUERY" && \
|
||||
wget -O testsuite/PCRE.tests "$$BASEURL/PCRE.tests?$$QUERY" && \
|
||||
wget -O testsuite/SPENCER.tests "$$BASEURL/rxspencer/tests?$$QUERY"
|
||||
+61
-32
@@ -566,6 +566,23 @@ weak_alias (__regerror, regerror)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RE_ENABLE_I18N
|
||||
/* This static array is used for the map to single-byte characters when
|
||||
UTF-8 is used. Otherwise we would allocate memory just to initialize
|
||||
it the same all the time. UTF-8 is the preferred encoding so this is
|
||||
a worthwhile optimization. */
|
||||
static const bitset utf8_sb_map =
|
||||
{
|
||||
/* Set the first 128 bits. */
|
||||
# if UINT_MAX == 0xffffffff
|
||||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
|
||||
# else
|
||||
# error "Add case for new unsigned int size"
|
||||
# endif
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
free_dfa_content (re_dfa_t *dfa)
|
||||
{
|
||||
@@ -613,7 +630,8 @@ free_dfa_content (re_dfa_t *dfa)
|
||||
}
|
||||
re_free (dfa->state_table);
|
||||
#ifdef RE_ENABLE_I18N
|
||||
re_free (dfa->sb_char);
|
||||
if (dfa->sb_char != utf8_sb_map)
|
||||
re_free (dfa->sb_char);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
re_free (dfa->re_str);
|
||||
@@ -824,7 +842,9 @@ init_dfa (dfa, pat_len)
|
||||
int pat_len;
|
||||
{
|
||||
int table_size;
|
||||
#ifndef _LIBC
|
||||
char *codeset_name;
|
||||
#endif
|
||||
|
||||
memset (dfa, '\0', sizeof (re_dfa_t));
|
||||
|
||||
@@ -850,9 +870,14 @@ init_dfa (dfa, pat_len)
|
||||
dfa->mb_cur_max = MB_CUR_MAX;
|
||||
#if defined _LIBC
|
||||
codeset_name = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME);
|
||||
#elif defined HAVE_LANGINFO_CODESET
|
||||
codeset_name = nl_langinfo (CODESET);
|
||||
if (dfa->mb_cur_max == 6 && strcmp (codeset_name, "UTF-8") == 0)
|
||||
dfa->is_utf8 = 1;
|
||||
dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
|
||||
!= 0);
|
||||
#else
|
||||
# ifdef HAVE_LANGINFO_CODESET
|
||||
codeset_name = nl_langinfo (CODESET);
|
||||
# else
|
||||
codeset_name = getenv ("LC_ALL");
|
||||
if (codeset_name == NULL || codeset[0] == '\0')
|
||||
codeset_name = getenv ("LC_CTYPE");
|
||||
@@ -860,19 +885,14 @@ init_dfa (dfa, pat_len)
|
||||
codeset_name = getenv ("LANG");
|
||||
if (codeset_name == NULL)
|
||||
codeset_name = "";
|
||||
else if (strchr (codeset_name, '.')
|
||||
else if (strchr (codeset_name, '.') != NULL)
|
||||
codeset_name = strchr (codeset_name, '.') + 1;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (dfa->mb_cur_max == 6
|
||||
&& (strcasecmp (codeset_name, "UTF-8") == 0
|
||||
|| strcasecmp (codeset_name, "UTF8") == 0))
|
||||
if (strcasecmp (codeset_name, "UTF-8") == 0
|
||||
|| strcasecmp (codeset_name, "UTF8") == 0)
|
||||
dfa->is_utf8 = 1;
|
||||
|
||||
#ifdef _LIBC
|
||||
dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
|
||||
!= 0);
|
||||
#else
|
||||
/* We check exhaustively in the loop below if this charset is a
|
||||
superset of ASCII. */
|
||||
dfa->map_notascii = 0;
|
||||
@@ -881,28 +901,35 @@ init_dfa (dfa, pat_len)
|
||||
#ifdef RE_ENABLE_I18N
|
||||
if (dfa->mb_cur_max > 1)
|
||||
{
|
||||
int i, j, ch;
|
||||
|
||||
dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset), 1);
|
||||
if (BE (dfa->sb_char == NULL, 0))
|
||||
return REG_ESPACE;
|
||||
if (dfa->is_utf8)
|
||||
memset (dfa->sb_char, 255, sizeof (unsigned int) * BITSET_UINTS / 2);
|
||||
dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map;
|
||||
else
|
||||
for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
|
||||
for (j = 0; j < UINT_BITS; ++j, ++ch)
|
||||
{
|
||||
wchar_t wch = __btowc (ch);
|
||||
if (wch != WEOF)
|
||||
dfa->sb_char[i] |= 1 << j;
|
||||
#ifndef _LIBC
|
||||
if (ch <= 127 && wch != (wchar_t) ch)
|
||||
dfa->map_notascii = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
int i, j, ch;
|
||||
|
||||
dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset), 1);
|
||||
if (BE (dfa->sb_char == NULL, 0))
|
||||
return REG_ESPACE;
|
||||
|
||||
/* Clear all bits by, then set those corresponding to single
|
||||
byte chars. */
|
||||
bitset_empty (dfa->sb_char);
|
||||
|
||||
for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
|
||||
for (j = 0; j < UINT_BITS; ++j, ++ch)
|
||||
{
|
||||
wchar_t wch = __btowc (ch);
|
||||
if (wch != WEOF)
|
||||
dfa->sb_char[i] |= 1 << j;
|
||||
# ifndef _LIBC
|
||||
if (isascii (ch) && wch != (wchar_t) ch)
|
||||
dfa->map_notascii = 1;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (BE (dfa->nodes == NULL || dfa->state_table == NULL
|
||||
|| dfa->subexps == NULL, 0))
|
||||
return REG_ESPACE;
|
||||
@@ -1575,7 +1602,9 @@ calc_eclosure_iter (new_set, dfa, node, root)
|
||||
? dfa->nodes[node].opr.ctx_type : 0);
|
||||
/* If the current node has constraints, duplicate all nodes.
|
||||
Since they must inherit the constraints. */
|
||||
if (constraint && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
|
||||
if (constraint
|
||||
&& dfa->edests[node].nelem
|
||||
&& !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
|
||||
{
|
||||
int org_node, cur_node;
|
||||
org_node = cur_node = node;
|
||||
|
||||
@@ -293,8 +293,8 @@ build_wcs_upper_buffer (pstr)
|
||||
byte_idx = pstr->valid_len;
|
||||
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
|
||||
|
||||
/* The following optimization assumes that the wchar_t encoding is
|
||||
always ISO 10646. */
|
||||
/* The following optimization assumes that ASCII characters can be
|
||||
mapped to wide characters with a simple cast. */
|
||||
if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
|
||||
{
|
||||
while (byte_idx < end_idx)
|
||||
@@ -308,8 +308,7 @@ build_wcs_upper_buffer (pstr)
|
||||
pstr->mbs[byte_idx]
|
||||
= toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
|
||||
/* The next step uses the assumption that wchar_t is encoded
|
||||
with ISO 10646: all ASCII values can be converted like
|
||||
this. */
|
||||
ASCII-safe: all ASCII values can be converted like this. */
|
||||
pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
|
||||
++byte_idx;
|
||||
continue;
|
||||
@@ -371,7 +370,7 @@ build_wcs_upper_buffer (pstr)
|
||||
{
|
||||
wchar_t wc;
|
||||
const char *p;
|
||||
offsets_needed:
|
||||
offsets_needed:
|
||||
remain_len = end_idx - byte_idx;
|
||||
prev_st = pstr->cur_state;
|
||||
if (BE (pstr->trans != NULL, 0))
|
||||
@@ -682,6 +681,7 @@ re_string_reconstruct (pstr, idx, eflags)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wc == WEOF)
|
||||
pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
|
||||
if (BE (pstr->valid_len, 0))
|
||||
|
||||
@@ -547,7 +547,9 @@ struct re_backref_cache_entry
|
||||
int str_idx;
|
||||
int subexp_from;
|
||||
int subexp_to;
|
||||
char more;
|
||||
/* We need only one byte from the following field. If other small
|
||||
fields are added the type could be changed to 'char'. */
|
||||
int more;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
||||
+6
-8
@@ -54,7 +54,7 @@ static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
|
||||
int nregs, int regs_allocated) internal_function;
|
||||
static inline re_dfastate_t *acquire_init_state_context
|
||||
(reg_errcode_t *err, const re_match_context_t *mctx, int idx)
|
||||
internal_function;
|
||||
__attribute ((always_inline)) internal_function;
|
||||
static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
|
||||
internal_function;
|
||||
static int check_matching (re_match_context_t *mctx, int fl_longest_match,
|
||||
@@ -121,8 +121,8 @@ static reg_errcode_t check_subexp_limits (re_dfa_t *dfa,
|
||||
struct re_backref_cache_entry *bkref_ents,
|
||||
int str_idx) internal_function;
|
||||
static reg_errcode_t sift_states_bkref (re_match_context_t *mctx,
|
||||
re_sift_context_t *sctx, int str_idx,
|
||||
const re_node_set *candidates) internal_function;
|
||||
re_sift_context_t *sctx,
|
||||
int str_idx, const re_node_set *candidates) internal_function;
|
||||
static reg_errcode_t clean_state_log_if_needed (re_match_context_t *mctx,
|
||||
int next_state_log_idx) internal_function;
|
||||
static reg_errcode_t merge_state_array (re_dfa_t *dfa, re_dfastate_t **dst,
|
||||
@@ -1525,7 +1525,6 @@ sift_states_backward (mctx, sctx)
|
||||
re_match_context_t *mctx;
|
||||
re_sift_context_t *sctx;
|
||||
{
|
||||
re_dfa_t *const dfa = mctx->dfa;
|
||||
reg_errcode_t err;
|
||||
int null_cnt = 0;
|
||||
int str_idx = sctx->last_str_idx;
|
||||
@@ -1547,7 +1546,6 @@ sift_states_backward (mctx, sctx)
|
||||
/* Then check each states in the state_log. */
|
||||
while (str_idx > 0)
|
||||
{
|
||||
int ret;
|
||||
/* Update counters. */
|
||||
null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0;
|
||||
if (null_cnt > mctx->max_mb_elem_len)
|
||||
@@ -1590,7 +1588,7 @@ build_sifted_states (mctx, sctx, str_idx, cur_dest)
|
||||
{
|
||||
re_dfa_t *const dfa = mctx->dfa;
|
||||
re_node_set *cur_src = &mctx->state_log[str_idx]->nodes;
|
||||
int i, ret, err;
|
||||
int i;
|
||||
|
||||
/* Then build the next sifted state.
|
||||
We build the next sifted state on `cur_dest', and update
|
||||
@@ -1603,6 +1601,7 @@ build_sifted_states (mctx, sctx, str_idx, cur_dest)
|
||||
int prev_node = cur_src->elems[i];
|
||||
int naccepted = 0;
|
||||
re_token_type_t type = dfa->nodes[prev_node].type;
|
||||
int ret;
|
||||
|
||||
if (IS_EPSILON_NODE (type))
|
||||
continue;
|
||||
@@ -1721,7 +1720,7 @@ update_cur_sifted_state (mctx, sctx, str_idx, dest_nodes)
|
||||
err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
|
||||
if (BE (err != REG_NOERROR, 0))
|
||||
return err;
|
||||
|
||||
|
||||
/* Then, check the limitations in the current sift_context. */
|
||||
if (sctx->limits.nelem)
|
||||
{
|
||||
@@ -1939,7 +1938,6 @@ check_dst_limits_calc_pos (mctx, limit, subexp_idx, from_node, str_idx, bkref_id
|
||||
re_match_context_t *mctx;
|
||||
int limit, subexp_idx, from_node, str_idx, bkref_idx;
|
||||
{
|
||||
re_dfa_t *const dfa = mctx->dfa;
|
||||
struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
|
||||
int boundaries;
|
||||
|
||||
|
||||
+5
-21
@@ -1,24 +1,3 @@
|
||||
# Copyright 1992, 1993, 1994, 1997 Henry Spencer. All rights reserved.
|
||||
# This software is not subject to any license of the American Telephone
|
||||
# and Telegraph Company or of the Regents of the University of California.
|
||||
#
|
||||
# Permission is granted to anyone to use this software for any purpose on
|
||||
# any computer system, and to alter it and redistribute it, subject
|
||||
# to the following restrictions:
|
||||
#
|
||||
# 1. The author is not responsible for the consequences of use of this
|
||||
# software, no matter how awful, even if they arise from flaws in it.
|
||||
#
|
||||
# 2. The origin of this software must not be misrepresented, either by
|
||||
# explicit claim or by omission. Since few users ever read sources,
|
||||
# credits must appear in the documentation.
|
||||
#
|
||||
# 3. Altered versions must be plainly marked as such, and must not be
|
||||
# misrepresented as being the original software. Since few users
|
||||
# ever read sources, credits must appear in the documentation.
|
||||
#
|
||||
# 4. This notice may not be removed or altered.
|
||||
#
|
||||
# regular expression test set
|
||||
# Lines are at least three fields, separated by one or more tabs. "" stands
|
||||
# for an empty field. First field is an RE. Second field is flags. If
|
||||
@@ -526,3 +505,8 @@ Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz
|
||||
a?b - ab ab
|
||||
-\{0,1\}[0-9]*$ b -5 -5
|
||||
a*a*a*a*a*a*a* & aaaaaa aaaaaa
|
||||
(\b){0} - x @x -
|
||||
\(\b\)\{0,0\} b abc @abc -
|
||||
a(\b){0}c - ac ac -
|
||||
a(.*)b(\0){0}c - abc abc @bc,-
|
||||
a(.*)b(\0){0}c - axbc axbc x,-
|
||||
Reference in new issue
Block a user