diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-11-12 17:47:46 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-11-12 17:47:46 +0000 |
commit | 3c0fb5745f66c8920ed4cfa8d3ead55216b15ec1 (patch) | |
tree | d993d46e33582e130e8324c5bd7fb7817d2a7f54 /posix/regcomp.c | |
parent | e432c0378ecfa545948d4be68190ab470446554b (diff) | |
download | glibc-3c0fb5745f66c8920ed4cfa8d3ead55216b15ec1.zip glibc-3c0fb5745f66c8920ed4cfa8d3ead55216b15ec1.tar.gz glibc-3c0fb5745f66c8920ed4cfa8d3ead55216b15ec1.tar.bz2 |
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
Diffstat (limited to 'posix/regcomp.c')
-rw-r--r-- | posix/regcomp.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/posix/regcomp.c b/posix/regcomp.c index 2b85037..82d4bb1 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -312,7 +312,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap) { re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; int node_cnt; - int icase = (MB_CUR_MAX == 1 && (bufp->syntax & RE_ICASE)); + int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) { int node = init_state->nodes.elems[node_cnt]; @@ -324,7 +324,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap) #ifdef RE_ENABLE_I18N if ((bufp->syntax & RE_ICASE) && !icase) { - unsigned char *buf = alloca (MB_CUR_MAX), *p; + unsigned char *buf = alloca (dfa->mb_cur_max), *p; wchar_t wc; mbstate_t state; @@ -376,7 +376,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap) re_set_fastmap (fastmap, icase, ch); } # else - if (MB_CUR_MAX > 1) + if (dfa->mb_cur_max > 1) for (i = 0; i < SBC_MAX; ++i) if (__btowc (i) == WEOF) re_set_fastmap (fastmap, icase, i); @@ -744,7 +744,8 @@ re_compile_internal (preg, pattern, length, syntax) #endif err = re_string_construct (®exp, pattern, length, preg->translate, - syntax & RE_ICASE); + syntax & RE_ICASE, dfa->mb_cur_max, + dfa->is_utf8); if (BE (err != REG_NOERROR, 0)) { re_free (dfa); @@ -812,6 +813,13 @@ init_dfa (dfa, pat_len) dfa->subexps = re_malloc (re_subexp_t, dfa->subexps_alloc); dfa->word_char = NULL; + dfa->mb_cur_max = MB_CUR_MAX; +#ifdef _LIBC + if (dfa->mb_cur_max > 1 + && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0) + dfa->is_utf8 = 1; +#endif + if (BE (dfa->nodes == NULL || dfa->state_table == NULL || dfa->subexps == NULL, 0)) { @@ -1522,7 +1530,7 @@ peek_token (token, input, syntax) #ifdef RE_ENABLE_I18N token->mb_partial = 0; - if (MB_CUR_MAX > 1 && + if (input->mb_cur_max > 1 && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; @@ -1738,7 +1746,7 @@ peek_token_bracket (token, input, syntax) token->opr.c = c; #ifdef RE_ENABLE_I18N - if (MB_CUR_MAX > 1 && + if (input->mb_cur_max > 1 && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; @@ -1976,7 +1984,7 @@ parse_expression (regexp, preg, token, syntax, nest, err) return NULL; } #ifdef RE_ENABLE_I18N - if (MB_CUR_MAX > 1) + if (dfa->mb_cur_max > 1) { while (!re_string_eoi (regexp) && !re_string_first_byte (regexp, re_string_cur_idx (regexp))) @@ -2111,7 +2119,7 @@ parse_expression (regexp, preg, token, syntax, nest, err) *err = REG_ESPACE; return NULL; } - if (MB_CUR_MAX > 1) + if (dfa->mb_cur_max > 1) dfa->has_mb_node = 1; break; case OP_WORD: @@ -2883,7 +2891,7 @@ parse_bracket_exp (regexp, dfa, token, syntax, err) goto parse_bracket_exp_free_return; } #ifdef RE_ENABLE_I18N - if (MB_CUR_MAX > 1) + if (dfa->mb_cur_max > 1) for (i = 0; i < SBC_MAX; ++i) if (__btowc (i) == WEOF) bitset_set (sbcset, i); @@ -3042,8 +3050,8 @@ parse_bracket_exp (regexp, dfa, token, syntax, err) #ifdef RE_ENABLE_I18N if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes - || mbcset->nranges || (MB_CUR_MAX > 1 && (mbcset->nchar_classes - || mbcset->non_match))) + || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes + || mbcset->non_match))) { re_token_t alt_token; bin_tree_t *mbc_tree; @@ -3377,7 +3385,7 @@ build_charclass_op (dfa, trans, class_name, extra, not, err) bitset_set(cset->sbcset, '\0'); */ mbcset->non_match = 1; - if (MB_CUR_MAX > 1) + if (dfa->mb_cur_max > 1) for (i = 0; i < SBC_MAX; ++i) if (__btowc (i) == WEOF) bitset_set (sbcset, i); @@ -3423,7 +3431,7 @@ build_charclass_op (dfa, trans, class_name, extra, not, err) goto build_word_op_espace; #ifdef RE_ENABLE_I18N - if (MB_CUR_MAX > 1) + if (dfa->mb_cur_max > 1) { re_token_t alt_token; bin_tree_t *mbc_tree; |