From: Paul Eggert Date: Thu, 13 Apr 2006 22:14:12 +0000 (+0000) Subject: * regcomp.c (init_dfa): Don't use wchar_t or wctype_t if RE_ENABLE_I18N X-Git-Tag: cvs-readonly~2453 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=4a2097ae176af2830d5ad53bdefbe59f8a250d00;p=gnulib.git * regcomp.c (init_dfa): Don't use wchar_t or wctype_t if RE_ENABLE_I18N is not defined. Problem reported by Mark D. Baushke via Derek R. Price. * regex.h (RE_DUP_MAX): Update comment to match current implementation. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index cf3476796..a8c3fe069 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-04-13 Paul Eggert + + * regcomp.c (init_dfa): Don't use wchar_t or wctype_t if RE_ENABLE_I18N + is not defined. Problem reported by Mark D. Baushke via Derek R. Price. + * regex.h (RE_DUP_MAX): Update comment to match current implementation. + 2006-04-09 Paul Eggert Merge regex changes from libc, removing some of our diff --git a/lib/regcomp.c b/lib/regcomp.c index 84512d00c..6e317f513 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -836,15 +836,17 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) #ifndef _LIBC char *codeset_name; #endif +#ifdef RE_ENABLE_I18N + size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); +#else + size_t max_i18n_object_size = 0; +#endif size_t max_object_size = MAX (sizeof (struct re_state_table_entry), MAX (sizeof (re_token_t), MAX (sizeof (re_node_set), MAX (sizeof (regmatch_t), - MAX (sizeof (regoff_t), - MAX (sizeof (wchar_t), - MAX (sizeof (wctype_t), - sizeof (Idx)))))))); + max_i18n_object_size)))); memset (dfa, '\0', sizeof (re_dfa_t)); diff --git a/lib/regex.h b/lib/regex.h index b1ae24906..51857e559 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -322,7 +322,14 @@ extern reg_syntax_t re_syntax_options; # ifdef RE_DUP_MAX # undef RE_DUP_MAX # endif -/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ + +/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored + the counter as a 2-byte signed integer. This is no longer true, so + RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to + ((SIZE_MAX - 2) / 10 - 1) if _REGEX_LARGE_OFFSETS is defined. + However, there would be a huge performance problem if someone + actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains + its historical value. */ # define RE_DUP_MAX (0x7fff) #endif /* defined __USE_GNU_REGEX */