Mercurial > hg > octave-nkf > gnulib-hg
diff lib/regcomp.c @ 6119:c3bf2ea44695
Make regex safe for g++. This fixes one real bug (an "err"
that should have been "*err").
* config/srclist.txt: Add glibc bug 1241.
* lib/regex_internal.h (re_calloc): New macro, consistent with
re_malloc etc. All callers of calloc changed to use re_calloc.
* lib/regex_internal.c (build_wcs_upper_buffer): Return reg_errcode_t,
not int. All callers changed.
* lib/regcomp.c (re_compile_fastmap_iter): Don't use alloca
(mb_cur_max); just use an array of size MB_LEN_MAX.
* lib/regexec.c (push_fail_stack): Use re_realloc, not realloc.
(find_recover_state): Change "err" to "*err"; this fixes what
appears to be a real bug.
(check_arrival_expand_ecl_sub): Be consistent about reg_errcode_t
versus int.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 25 Aug 2005 20:39:57 +0000 |
parents | 1e308ce32c4c |
children | a10e4460ad4c |
line wrap: on
line diff
--- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -311,7 +311,8 @@ #ifdef RE_ENABLE_I18N if ((bufp->re_syntax & REG_IGNORE_CASE) && dfa->mb_cur_max > 1) { - unsigned char *buf = alloca (dfa->mb_cur_max), *p; + unsigned char buf[MB_LEN_MAX]; + unsigned char *p; wchar_t wc; mbstate_t state; @@ -817,7 +818,7 @@ if (table_size > pat_len) break; - dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); + dfa->state_table = re_calloc (struct re_state_table_entry, table_size); dfa->state_hash_mask = table_size - 1; dfa->mb_cur_max = MB_CUR_MAX; @@ -860,7 +861,7 @@ { int i, j, ch; - dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset), 1); + dfa->sb_char = re_calloc (unsigned int, BITSET_UINTS); if (BE (dfa->sb_char == NULL, 0)) return REG_ESPACE; @@ -2963,9 +2964,9 @@ _NL_COLLATE_SYMB_EXTRAMB); } #endif - sbcset = (re_bitset_ptr_t) calloc (sizeof (unsigned int), BITSET_UINTS); + sbcset = re_calloc (unsigned int, BITSET_UINTS); #ifdef RE_ENABLE_I18N - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); + mbcset = re_calloc (re_charset_t, 1); #endif /* RE_ENABLE_I18N */ #ifdef RE_ENABLE_I18N if (BE (sbcset == NULL || mbcset == NULL, 0)) @@ -3492,9 +3493,9 @@ re_token_t br_token; bin_tree_t *tree; - sbcset = (re_bitset_ptr_t) calloc (sizeof (unsigned int), BITSET_UINTS); + sbcset = re_calloc (unsigned int, BITSET_UINTS); #ifdef RE_ENABLE_I18N - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); + mbcset = re_calloc (re_charset_t, 1); #endif /* RE_ENABLE_I18N */ #ifdef RE_ENABLE_I18N