From ce85933261d37a0cd5345687acc948fe5bfdabd0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 23 Sep 2003 05:33:43 +0000 Subject: Upate. 2003-09-20 Paolo Bonzini * posix/regcomp.c (peek_token): Don't look back for ( or | to check whether to treat a caret as special. It fails for the (extended) regex \(^. (parse, parse_reg_exp): Pass RE_CARET_ANCHORS_HERE to fetch_token. * posix/regex.h: Define RE_CARET_ANCHORS_HERE. * posix/regexec.c: Check out of bounds value before shifting. * posix/regex_internal.h: Define __attribute for non-gcc. --- posix/regcomp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'posix/regcomp.c') diff --git a/posix/regcomp.c b/posix/regcomp.c index d9212de3b9..4682ca6c1b 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -1650,12 +1650,11 @@ peek_token (token, input, syntax) token->type = OP_PERIOD; break; case '^': - if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && + if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && re_string_cur_idx (input) != 0) { char prev = re_string_peek_byte (input, -1); - if (prev != '|' && prev != '(' && - (!(syntax & RE_NEWLINE_ALT) || prev != '\n')) + if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') break; } token->type = ANCHOR; @@ -1790,7 +1789,7 @@ parse (regexp, preg, syntax, err) bin_tree_t *tree, *eor, *root; re_token_t current_token; int new_idx; - current_token = fetch_token (regexp, syntax); + current_token = fetch_token (regexp, syntax | RE_CARET_ANCHORS_HERE); tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; @@ -1837,7 +1836,7 @@ parse_reg_exp (regexp, preg, token, syntax, nest, err) { re_token_t alt_token = *token; new_idx = re_dfa_add_node (dfa, alt_token, 0); - *token = fetch_token (regexp, syntax); + *token = fetch_token (regexp, syntax | RE_CARET_ANCHORS_HERE); if (token->type != OP_ALT && token->type != END_OF_RE && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) { -- cgit v1.2.3