From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 12 21:00:26 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B49781065672 for ; Fri, 12 Nov 2010 21:00:26 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7496E8FC2A for ; Fri, 12 Nov 2010 21:00:26 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oACL0Qbo091715 for ; Fri, 12 Nov 2010 21:00:26 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oACL0QBj091686; Fri, 12 Nov 2010 21:00:26 GMT (envelope-from gnats) Resent-Date: Fri, 12 Nov 2010 21:00:26 GMT Resent-Message-Id: <201011122100.oACL0QBj091686@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Pedro Giffuni Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30BBC1065673 for ; Fri, 12 Nov 2010 20:58:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 1D66F8FC1B for ; Fri, 12 Nov 2010 20:58:15 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oACKwEkk087334 for ; Fri, 12 Nov 2010 20:58:14 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id oACKwE4E087333; Fri, 12 Nov 2010 20:58:14 GMT (envelope-from nobody) Message-Id: <201011122058.oACKwE4E087333@www.freebsd.org> Date: Fri, 12 Nov 2010 20:58:14 GMT From: Pedro Giffuni To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: gnu/152178: Misc. updates to gnu/libregex X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2010 21:00:26 -0000 >Number: 152178 >Category: gnu >Synopsis: Misc. updates to gnu/libregex >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Fri Nov 12 21:00:26 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Pedro Giffuni >Release: 8.1-RELEASE >Organization: >Environment: FreeBSD mogwai.giffuni.net 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Tue Nov 9 10:31:43 UTC 2010 pedro@mogwai.giffuni.net:/usr/src/sys/i386/compile/GENERIC i386 >Description: FreeBSD carries a version of GNU regex that hasn't been updated in a while. This is used mostly for GNU grep but will also be used by BSD grep since it is not easy to find a library with the same incompatibilities. For the time being I took some updates from sourceware's CVS, mostly cleanups. I avoided introducing any form of locking since that likely to work exactly equal for FreeBSD. I have only tested this lightly by rebuilding gnuregex and grep. >How-To-Repeat: regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char): (optimize_subexps, lower_subexp): Don't assume 1<<31 has defined behavior on hosts with 32-bit int, since the signed shift might overflow. Use 1u<<31 instead. (optimize_subexps, lower_subexp): Use CHAR_BIT rather than 8, for clarity. (init_dfa): Make table_size unsigned, so that we don't have to worry about portability issues when shifting it left. Remove no-longer-needed test for table_size > 0. (parse_sub_exp): Do not shift more bits than there are in a word, as the resulting behavior is undefined. (init_dfa): Don't initialize unused members. (create_initial_state): Remove duplicate decl. (duplicate_node): Return new index, not an error code, and let the caller return REG_ESPACE if out of space. This removes an uninitialied-variable warning with GCC 4.0.1, and also avoids taking the address of a local variable. All callers changed. (init_dfa): Store __btowc value in wint_t, not wchar_t. Remove now-unnecessary cast. (build_range_exp): Likewise. regex.c Remove portability cruft for alloca. This no longer needs to be at the start of the file, and can be moved into regex_internal.h and simplified. Do not include , as POSIX no longer requires this. (The code never needed it.) Prevent using C++ compilers. regex_internal.c (re_string_realloc_buffers): (re_node_set_insert, re_node_set_insert_last, re_dfa_add_node): Rename local variables to avoid GCC shadowing warnings. Minor code rearrangements. 2005-07-05 Ulrich Drepper [BZ #1101] * posix/regex_internal.c (build_wcs_buffer): Use MB_LEN_MAX not MB_CUR_MAX. (build_wcs_upper_buffer): Likewise. 2005-03-05 Ulrich Drepper [BZ #1101] * posix/regex_internal.c [_LIBC] (build_wcs_buffer): Avoid using dynamically sized array. (build_wcs_upper_buffer): Likewise. (build_wcs_buffer): Use MB_LEN_MAX not MB_CUR_MAX. (build_wcs_upper_buffer): Likewise. Selected changes from the CVS log: regex_internal.h (struct re_dfa_t): Change type of nodes_alloc and nodes_len to size_t. (bitset_set, bitset_clear, bitset_contain): Don't assume 1<<31 has defined behavior on hosts with 32-bit int, since the signed shift might overflow. Use 1u<<31 instead. (BYTE_BITS): Remove. All uses changed to the standard name CHAR_BIT. >Fix: Patch attached. Patch attached with submission follows: =================================================================== RCS file: /cvs/glibc/libc/posix/regcomp.c,v retrieving revision 1.80.2.10 retrieving revision 1.102 diff -u -r1.80.2.10 -r1.102 --- libc/posix/regcomp.c 2005/07/21 08:25:49 1.80.2.10 +++ libc/posix/regcomp.c 2005/09/06 23:03:50 1.102 @@ -34,7 +34,6 @@ static void optimize_utf8 (re_dfa_t *dfa); #endif static reg_errcode_t analyze (regex_t *preg); -static reg_errcode_t create_initial_state (re_dfa_t *dfa); static reg_errcode_t preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), void *extra); @@ -51,8 +50,7 @@ static reg_errcode_t duplicate_node_closure (re_dfa_t *dfa, int top_org_node, int top_clone_node, int root_node, unsigned int constraint); -static reg_errcode_t duplicate_node (int *new_idx, re_dfa_t *dfa, int org_idx, - unsigned int constraint); +static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint); static int search_duplicated_node (re_dfa_t *dfa, int org_node, unsigned int constraint); static reg_errcode_t calc_eclosure (re_dfa_t *dfa); @@ -370,7 +368,7 @@ int i, j, ch; for (i = 0, ch = 0; i < BITSET_UINTS; ++i) for (j = 0; j < UINT_BITS; ++j, ++ch) - if (dfa->nodes[node].opr.sbcset[i] & (1 << j)) + if (dfa->nodes[node].opr.sbcset[i] & (1u << j)) re_set_fastmap (fastmap, icase, ch); } #ifdef RE_ENABLE_I18N @@ -536,8 +534,8 @@ size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; - const regex_t *preg; - char *errbuf; + const regex_t *__restrict preg; + char *__restrict errbuf; size_t errbuf_size; { const char *msg; @@ -844,7 +842,7 @@ re_dfa_t *dfa; int pat_len; { - int table_size; + unsigned int table_size; #ifndef _LIBC char *codeset_name; #endif @@ -857,10 +855,8 @@ dfa->nodes_alloc = pat_len + 1; dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); - dfa->states_alloc = pat_len + 1; - /* table_size = 2 ^ ceil(log pat_len) */ - for (table_size = 1; table_size > 0; table_size <<= 1) + for (table_size = 1; ; table_size <<= 1) if (table_size > pat_len) break; @@ -918,11 +914,11 @@ for (i = 0, ch = 0; i < BITSET_UINTS; ++i) for (j = 0; j < UINT_BITS; ++j, ++ch) { - wchar_t wch = __btowc (ch); + wint_t wch = __btowc (ch); if (wch != WEOF) - dfa->sb_char[i] |= 1 << j; + dfa->sb_char[i] |= 1u << j; # ifndef _LIBC - if (isascii (ch) && wch != (wchar_t) ch) + if (isascii (ch) && wch != ch) dfa->map_notascii = 1; # endif } @@ -948,7 +944,7 @@ for (i = 0, ch = 0; i < BITSET_UINTS; ++i) for (j = 0; j < UINT_BITS; ++j, ++ch) if (isalnum (ch) || ch == '_') - dfa->word_char[i] |= 1 << j; + dfa->word_char[i] |= 1u << j; } /* Free the work area which are only used while compiling. */ @@ -1281,8 +1277,8 @@ node->left->parent = node; dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; - if (other_idx < 8 * sizeof (dfa->used_bkref_map)) - dfa->used_bkref_map &= ~(1 << other_idx); + if (other_idx < CHAR_BIT * sizeof dfa->used_bkref_map) + dfa->used_bkref_map &= ~(1u << other_idx); } return REG_NOERROR; @@ -1330,8 +1326,8 @@ very common, so we do not lose much. An example that triggers this case is the sed "script" /\(\)/x. */ && node->left != NULL - && (node->token.opr.idx >= 8 * sizeof (dfa->used_bkref_map) - || !(dfa->used_bkref_map & (1 << node->token.opr.idx)))) + && (node->token.opr.idx >= CHAR_BIT * sizeof dfa->used_bkref_map + || !(dfa->used_bkref_map & (1u << node->token.opr.idx)))) return node->left; /* Convert the SUBEXP node to the concatenation of an @@ -1469,7 +1465,6 @@ int top_org_node, top_clone_node, root_node; unsigned int init_constraint; { - reg_errcode_t err; int org_node, clone_node, ret; unsigned int constraint = init_constraint; for (org_node = top_org_node, clone_node = top_clone_node;;) @@ -1483,9 +1478,9 @@ edests of the back reference. */ org_dest = dfa->nexts[org_node]; re_node_set_empty (dfa->edests + clone_node); - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; dfa->nexts[clone_node] = dfa->nexts[org_node]; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) @@ -1521,9 +1516,9 @@ } constraint |= dfa->nodes[org_node].opr.ctx_type; } - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) return REG_ESPACE; @@ -1539,9 +1534,10 @@ if (clone_dest == -1) { /* There are no such a duplicated node, create a new one. */ - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + reg_errcode_t err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) return REG_ESPACE; @@ -1560,9 +1556,9 @@ } org_dest = dfa->edests[org_node].elems[1]; - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) return REG_ESPACE; @@ -1593,27 +1589,27 @@ } /* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. - The new index will be stored in NEW_IDX and return REG_NOERROR if succeeded, - otherwise return the error code. */ + Return the index of the new node, or -1 if insufficient storage is + available. */ -static reg_errcode_t -duplicate_node (new_idx, dfa, org_idx, constraint) +static int +duplicate_node (dfa, org_idx, constraint) re_dfa_t *dfa; - int *new_idx, org_idx; + int org_idx; unsigned int constraint; { int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); - if (BE (dup_idx == -1, 0)) - return REG_ESPACE; - dfa->nodes[dup_idx].constraint = constraint; - if (dfa->nodes[org_idx].type == ANCHOR) - dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type; - dfa->nodes[dup_idx].duplicated = 1; - - /* Store the index of the original node. */ - dfa->org_indices[dup_idx] = org_idx; - *new_idx = dup_idx; - return REG_NOERROR; + if (BE (dup_idx != -1, 1)) + { + dfa->nodes[dup_idx].constraint = constraint; + if (dfa->nodes[org_idx].type == ANCHOR) + dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type; + dfa->nodes[dup_idx].duplicated = 1; + + /* Store the index of the original node. */ + dfa->org_indices[dup_idx] = org_idx; + } + return dup_idx; } static reg_errcode_t @@ -2496,7 +2492,9 @@ if (BE (*err != REG_NOERROR, 0)) return NULL; } - dfa->completed_bkref_map |= 1 << cur_nsub; + + if (cur_nsub <= '9' - '1') + dfa->completed_bkref_map |= 1 << cur_nsub; tree = create_tree (dfa, tree, NULL, SUBEXP); if (BE (tree == NULL, 0)) @@ -2683,7 +2681,9 @@ # ifdef RE_ENABLE_I18N { - wchar_t wc, start_wc, end_wc; + wchar_t wc; + wint_t start_wc; + wint_t end_wc; wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch =================================================================== RCS file: /cvs/glibc/libc/posix/regex.c,v retrieving revision 1.126 retrieving revision 1.129 diff -u -r1.126 -r1.129 --- libc/posix/regex.c 2004/01/30 05:19:58 1.126 +++ libc/posix/regex.c 2005/09/06 20:49:44 1.129 @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -22,28 +22,9 @@ #include "config.h" #endif -#ifdef _AIX -#pragma alloca -#else -# ifndef allocax /* predefined by HP cc +Olibcalls */ -# ifdef __GNUC__ -# define alloca(size) __builtin_alloca (size) -# else -# if HAVE_ALLOCA_H -# include -# else -# ifdef __hpux - void *alloca (); -# else -# if !defined __OS2__ && !defined WIN32 - char *alloca (); -# else -# include /* OS/2 defines alloca in here */ -# endif -# endif -# endif -# endif -# endif +/* Make sure noone compiles this code with a C++ compiler. */ +#ifdef __cplusplus +# error "This is C code, use a C compiler" #endif #ifdef _LIBC @@ -71,10 +52,6 @@ # include "../locale/localeinfo.h" #endif -/* POSIX says that must be included (by the caller) before - . */ -#include - /* On some systems, limits.h sets RE_DUP_MAX to a lower value than GNU regex allows. Include it before , which correctly #undefs RE_DUP_MAX and sets it to the right value. */ =================================================================== RCS file: /cvs/glibc/libc/include/regex.h,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -r1.2 -r1.2.6.1 --- libc/include/regex.h 1998/12/08 13:10:59 1.2 +++ libc/include/regex.h 2005/09/12 07:10:32 1.2.6.1 @@ -2,45 +2,42 @@ #include /* Document internal interfaces. */ -extern reg_syntax_t __re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); +extern reg_syntax_t __re_set_syntax (reg_syntax_t syntax); -extern const char *__re_compile_pattern - _RE_ARGS ((const char *pattern, size_t length, - struct re_pattern_buffer *buffer)); +extern const char *__re_compile_pattern (const char *pattern, size_t length, + struct re_pattern_buffer *buffer); -extern int __re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); +extern int __re_compile_fastmap (struct re_pattern_buffer *buffer); -extern int __re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); +extern int __re_search (struct re_pattern_buffer *buffer, const char *string, + int length, int start, int range, + struct re_registers *regs); extern int __re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); + (struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, int range, struct re_registers *regs, int stop); extern int __re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); + (struct re_pattern_buffer *buffer, const char *string, + int length, int start, struct re_registers *regs); extern int __re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); + (struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, struct re_registers *regs, int stop); extern void __re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); + (struct re_pattern_buffer *buffer, struct re_registers *regs, + unsigned num_regs, regoff_t *starts, regoff_t *ends); -extern int __regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern, - int __cflags)); +extern int __regcomp (regex_t *__preg, const char *__pattern, int __cflags); -extern int __regexec _RE_ARGS ((const regex_t *__preg, - const char *__string, size_t __nmatch, - regmatch_t __pmatch[], int __eflags)); +extern int __regexec (const regex_t *__preg, const char *__string, + size_t __nmatch, regmatch_t __pmatch[], int __eflags); -extern size_t __regerror _RE_ARGS ((int __errcode, const regex_t *__preg, - char *__errbuf, size_t __errbuf_size)); +extern size_t __regerror (int __errcode, const regex_t *__preg, + char *__errbuf, size_t __errbuf_size); -extern void __regfree _RE_ARGS ((regex_t *__preg)); +extern void __regfree (regex_t *__preg); #endif =================================================================== RCS file: /cvs/glibc/libc/posix/regex_internal.c,v retrieving revision 1.41.2.7 retrieving revision 1.54 diff -u -r1.41.2.7 -r1.54 --- libc/posix/regex_internal.c 2005/03/19 20:18:07 1.41.2.7 +++ libc/posix/regex_internal.c 2005/09/06 17:29:29 1.54 @@ -148,26 +148,26 @@ #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { - wint_t *new_array = re_realloc (pstr->wcs, wint_t, new_buf_len); - if (BE (new_array == NULL, 0)) + wint_t *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); + if (BE (new_wcs == NULL, 0)) return REG_ESPACE; - pstr->wcs = new_array; + pstr->wcs = new_wcs; if (pstr->offsets != NULL) { - int *new_array = re_realloc (pstr->offsets, int, new_buf_len); - if (BE (new_array == NULL, 0)) + int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len); + if (BE (new_offsets == NULL, 0)) return REG_ESPACE; - pstr->offsets = new_array; + pstr->offsets = new_offsets; } } #endif /* RE_ENABLE_I18N */ if (pstr->mbs_allocated) { - unsigned char *new_array = re_realloc (pstr->mbs, unsigned char, - new_buf_len); - if (BE (new_array == NULL, 0)) + unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, + new_buf_len); + if (BE (new_mbs == NULL, 0)) return REG_ESPACE; - pstr->mbs = new_array; + pstr->mbs = new_mbs; } pstr->bufs_len = new_buf_len; return REG_NOERROR; @@ -214,8 +214,8 @@ re_string_t *pstr; { #ifdef _LIBC - unsigned char buf[MB_CUR_MAX]; - assert (MB_CUR_MAX >= pstr->mb_cur_max); + unsigned char buf[MB_LEN_MAX]; + assert (MB_LEN_MAX >= pstr->mb_cur_max); #else unsigned char buf[64]; #endif @@ -285,8 +285,8 @@ int src_idx, byte_idx, end_idx, remain_len; size_t mbclen; #ifdef _LIBC - char buf[MB_CUR_MAX]; - assert (MB_CUR_MAX >= pstr->mb_cur_max); + char buf[MB_LEN_MAX]; + assert (MB_LEN_MAX >= pstr->mb_cur_max); #else char buf[64]; #endif @@ -1227,12 +1227,12 @@ /* Realloc if we need. */ if (set->alloc == set->nelem) { - int *new_array; + int *new_elems; set->alloc = set->alloc * 2; - new_array = re_realloc (set->elems, int, set->alloc); - if (BE (new_array == NULL, 0)) + new_elems = re_realloc (set->elems, int, set->alloc); + if (BE (new_elems == NULL, 0)) return -1; - set->elems = new_array; + set->elems = new_elems; } /* Move the elements which follows the new element. Test the @@ -1267,12 +1267,12 @@ /* Realloc if we need. */ if (set->alloc == set->nelem) { - int *new_array; + int *new_elems; set->alloc = (set->alloc + 1) * 2; - new_array = re_realloc (set->elems, int, set->alloc); - if (BE (new_array == NULL, 0)) + new_elems = re_realloc (set->elems, int, set->alloc); + if (BE (new_elems == NULL, 0)) return -1; - set->elems = new_array; + set->elems = new_elems; } /* Insert the new element. */ @@ -1349,11 +1349,11 @@ int *new_nexts, *new_indices; re_node_set *new_edests, *new_eclosures; - re_token_t *new_array = re_realloc (dfa->nodes, re_token_t, + re_token_t *new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); - if (BE (new_array == NULL, 0)) + if (BE (new_nodes == NULL, 0)) return -1; - dfa->nodes = new_array; + dfa->nodes = new_nodes; new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc); new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc); new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); @@ -1429,13 +1429,10 @@ /* There are no appropriate state in the dfa, create the new one. */ new_state = create_ci_newstate (dfa, nodes, hash); - if (BE (new_state != NULL, 1)) - return new_state; - else - { - *err = REG_ESPACE; - return NULL; - } + if (BE (new_state == NULL, 0)) + *err = REG_ESPACE; + + return new_state; } /* Search for the state whose node_set is equivalent to NODES and @@ -1477,13 +1474,10 @@ } /* There are no appropriate state in `dfa', create the new one. */ new_state = create_cd_newstate (dfa, nodes, context, hash); - if (BE (new_state != NULL, 1)) - return new_state; - else - { - *err = REG_ESPACE; - return NULL; - } + if (BE (new_state == NULL, 0)) + *err = REG_ESPACE; + + return new_state; } /* Finish initialization of the new state NEWSTATE, and using its hash value =================================================================== RCS file: /cvs/glibc/libc/posix/regex_internal.h,v retrieving revision 1.64 retrieving revision 1.66 diff -u -r1.64 -r1.66 --- libc/posix/regex_internal.h 2005/09/06 21:04:31 1.64 +++ libc/posix/regex_internal.h 2005/09/06 23:27:40 1.66 @@ -91,8 +91,6 @@ # define inline #endif -/* Number of bits in a byte. */ -#define BYTE_BITS 8 /* Number of single byte character. */ #define SBC_MAX 256 @@ -123,16 +121,16 @@ extern const size_t __re_error_msgid_idx[] attribute_hidden; /* Number of bits in an unsinged int. */ -#define UINT_BITS (sizeof (unsigned int) * BYTE_BITS) +#define UINT_BITS (sizeof (unsigned int) * CHAR_BIT) /* Number of unsigned int in an bit_set. */ #define BITSET_UINTS ((SBC_MAX + UINT_BITS - 1) / UINT_BITS) typedef unsigned int bitset[BITSET_UINTS]; typedef unsigned int *re_bitset_ptr_t; typedef const unsigned int *re_const_bitset_ptr_t; -#define bitset_set(set,i) (set[i / UINT_BITS] |= 1 << i % UINT_BITS) -#define bitset_clear(set,i) (set[i / UINT_BITS] &= ~(1 << i % UINT_BITS)) -#define bitset_contain(set,i) (set[i / UINT_BITS] & (1 << i % UINT_BITS)) +#define bitset_set(set,i) (set[i / UINT_BITS] |= 1u << i % UINT_BITS) +#define bitset_clear(set,i) (set[i / UINT_BITS] &= ~(1u << i % UINT_BITS)) +#define bitset_contain(set,i) (set[i / UINT_BITS] & (1u << i % UINT_BITS)) #define bitset_empty(set) memset (set, 0, sizeof (unsigned int) * BITSET_UINTS) #define bitset_set_all(set) \ memset (set, 255, sizeof (unsigned int) * BITSET_UINTS) @@ -627,8 +625,8 @@ struct re_dfa_t { re_token_t *nodes; - int nodes_alloc; - int nodes_len; + size_t nodes_alloc; + size_t nodes_len; int *nexts; int *org_indices; re_node_set *edests; =================================================================== RCS file: /cvs/glibc/libc/posix/regexec.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- libc/posix/regexec.c 2005/09/07 05:40:53 1.87 +++ libc/posix/regexec.c 2005/09/07 07:15:25 1.88 @@ -2405,7 +2405,7 @@ reg_errcode_t *err; re_match_context_t *mctx; { - re_dfastate_t *cur_state = NULL; + re_dfastate_t *cur_state; do { int max = mctx->state_log_top; >Release-Note: >Audit-Trail: >Unformatted: