summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2005-01-28 09:09:05 +0000
committerPaolo Bonzini <bonzini@gnu.org>2008-01-09 16:11:44 +0100
commit5b8a41362041bb4c950488745694f1242f611e66 (patch)
tree2ff743a3817069e56227f82587cc3978cef5516f /lib
parentf6330a3c93c9d893e338e5b2225c8df298b6baf0 (diff)
downloadsed-5b8a41362041bb4c950488745694f1242f611e66.tar.gz
finally resync with glibc
git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-38
Diffstat (limited to 'lib')
-rw-r--r--lib/regcomp.c38
-rw-r--r--lib/regex.c2
-rw-r--r--lib/regex_internal.c2
-rw-r--r--lib/regex_internal.h9
-rw-r--r--lib/regexec.c17
5 files changed, 37 insertions, 31 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 93a6d76..1a5f795 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -43,7 +43,7 @@ static reg_errcode_t postorder (bin_tree_t *root,
void *extra);
static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node);
static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node);
-static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
+static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
bin_tree_t *node);
static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
@@ -1168,7 +1168,7 @@ analyze (preg)
return ret;
/* We only need this during the prune_impossible_nodes pass in regexec.c;
- do not compute it otherwise since it can become quadratic. */
+ skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */
if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
|| dfa->nbackref)
{
@@ -1259,7 +1259,6 @@ optimize_subexps (extra, node)
bin_tree_t *node;
{
re_dfa_t *dfa = (re_dfa_t *) extra;
- int successful = 0;
if (node->token.type == OP_BACK_REF && dfa->subexp_map)
{
@@ -1372,8 +1371,6 @@ calc_next (extra, node)
void *extra;
bin_tree_t *node;
{
- re_dfa_t *dfa = (re_dfa_t *) extra;
-
switch (node->token.type)
{
case OP_DUP_ASTERISK:
@@ -1407,11 +1404,11 @@ link_nfa_nodes (extra, node)
{
case CONCAT:
break;
-
+
case END_OF_RE:
assert (node->next == NULL);
break;
-
+
case OP_DUP_ASTERISK:
case OP_ALT:
{
@@ -1430,25 +1427,25 @@ link_nfa_nodes (extra, node)
err = re_node_set_init_2 (dfa->edests + idx, left, right);
}
break;
-
+
case ANCHOR:
case OP_OPEN_SUBEXP:
case OP_CLOSE_SUBEXP:
err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx);
break;
-
+
case OP_BACK_REF:
dfa->nexts[idx] = node->next->node_idx;
if (node->token.type == OP_BACK_REF)
re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
break;
-
+
default:
assert (!IS_EPSILON_NODE (node->token.type));
dfa->nexts[idx] = node->next->node_idx;
break;
}
-
+
return err;
}
@@ -2355,13 +2352,22 @@ parse_expression (regexp, preg, token, syntax, nest, err)
& (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
&& dfa->word_ops_used == 0)
init_word_char (dfa);
- if (token->opr.ctx_type >= DUMMY_CONSTRAINT)
+ if (token->opr.ctx_type == WORD_DELIM
+ || token->opr.ctx_type == NOT_WORD_DELIM)
{
- int delim = (token->opr.ctx_type == WORD_DELIM);
bin_tree_t *tree_first, *tree_last;
- token->opr.ctx_type = delim ? WORD_FIRST : INSIDE_WORD;
- tree_first = create_token_tree (dfa, NULL, NULL, token);
- token->opr.ctx_type = delim ? WORD_LAST : OUTSIDE_WORD;
+ if (token->opr.ctx_type == WORD_DELIM)
+ {
+ token->opr.ctx_type = WORD_FIRST;
+ tree_first = create_token_tree (dfa, NULL, NULL, token);
+ token->opr.ctx_type = WORD_LAST;
+ }
+ else
+ {
+ token->opr.ctx_type = INSIDE_WORD;
+ tree_first = create_token_tree (dfa, NULL, NULL, token);
+ token->opr.ctx_type = INSIDE_NOTWORD;
+ }
tree_last = create_token_tree (dfa, NULL, NULL, token);
tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0))
diff --git a/lib/regex.c b/lib/regex.c
index 1e24fcf..7a4f304 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 7284ed3..c3295a8 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 02bdec7..f065cf4 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -143,20 +143,21 @@ static inline void bitset_mask (bitset dest, const bitset src);
#define NEXT_NEWLINE_CONSTRAINT 0x0020
#define PREV_BEGBUF_CONSTRAINT 0x0040
#define NEXT_ENDBUF_CONSTRAINT 0x0080
-#define DUMMY_CONSTRAINT 0x0100
+#define WORD_DELIM_CONSTRAINT 0x0100
+#define NOT_WORD_DELIM_CONSTRAINT 0x0200
typedef enum
{
INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
- OUTSIDE_WORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+ INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
- WORD_DELIM = DUMMY_CONSTRAINT,
- NOT_WORD_DELIM = DUMMY_CONSTRAINT << 1,
+ WORD_DELIM = WORD_DELIM_CONSTRAINT,
+ NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
} re_context_type;
typedef struct
diff --git a/lib/regexec.c b/lib/regexec.c
index 3089983..636396e 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -3301,12 +3301,12 @@ build_trtable (dfa, state)
#ifdef _LIBC
if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX))
dests_node = (re_node_set *)
- alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX);
+ alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX);
else
#endif
{
dests_node = (re_node_set *)
- malloc ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX);
+ malloc ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX);
if (BE (dests_node == NULL, 0))
return 0;
dests_node_malloced = 1;
@@ -3314,7 +3314,7 @@ build_trtable (dfa, state)
dests_ch = (bitset *) (dests_node + SBC_MAX);
/* Initialize transiton table. */
- state->word_trtable = state->trtable = 0;
+ state->word_trtable = state->trtable = NULL;
/* At first, group all nodes belonging to `state' into several
destinations. */
@@ -3327,7 +3327,7 @@ build_trtable (dfa, state)
if (ndests == 0)
{
state->trtable = (re_dfastate_t **)
- calloc (sizeof (re_dfastate_t *), SBC_MAX);;
+ calloc (sizeof (re_dfastate_t *), SBC_MAX);
return 1;
}
return 0;
@@ -3341,12 +3341,12 @@ build_trtable (dfa, state)
if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX
+ ndests * 3 * sizeof (re_dfastate_t *)))
dest_states = (re_dfastate_t **)
- alloca (ndests * 3 * sizeof (re_dfastate_t *));
+ alloca (ndests * 3 * sizeof (re_dfastate_t *));
else
#endif
{
dest_states = (re_dfastate_t **)
- malloc (ndests * 3 * sizeof (re_dfastate_t *));
+ malloc (ndests * 3 * sizeof (re_dfastate_t *));
if (BE (dest_states == NULL, 0))
{
out_free:
@@ -3393,8 +3393,7 @@ out_free:
if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0))
goto out_free;
- if (dest_states[i] != dest_states_word[i]
- && dfa->mb_cur_max > 1)
+ if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
need_word_trtable = 1;
dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,