From a9746a27a5180d49f9208789465ec399c6dd804c Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 6 Jan 2012 10:18:53 -0700 Subject: [PATCH] regcomp.c: Change loop variable name, associated changes The variable 'value' is already used for something else. Using it as a loop variable corrupts the other use. This commit changes to a different name, and adds code to keep 'value', and 'prevvalue' in sync with their other meanings. --- regcomp.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/regcomp.c b/regcomp.c index 1bcfc68..1b738b6 100644 --- a/regcomp.c +++ b/regcomp.c @@ -10940,9 +10940,18 @@ parseit: || (ANYOF_FLAGS(ret) & ANYOF_NONBITMAP_NON_UTF8)) && SvCUR(listsv) == initial_listsv_len) { + int i; if (! nonbitmap) { - for (value = 0; value < ANYOF_BITMAP_SIZE; ++value) - ANYOF_BITMAP(ret)[value] ^= 0xFF; + for (i = 0; i < 256; ++i) { + if (ANYOF_BITMAP_TEST(ret, i)) { + ANYOF_BITMAP_CLEAR(ret, i); + } + else { + ANYOF_BITMAP_SET(ret, i); + prevvalue = value; + value = i; + } + } /* The inversion means that everything above 255 is matched */ ANYOF_FLAGS(ret) |= ANYOF_UNICODE_ALL; } @@ -10951,14 +10960,19 @@ parseit: * individually and add it to the list to get rid of from those * things not in the bitmap */ SV *remove_list = _new_invlist(2); + + /* Now invert both the bitmap and the nonbitmap. Anything in the + * bitmap has to also be removed from the non-bitmap */ _invlist_invert(nonbitmap); - for (value = 0; value < 256; ++value) { - if (ANYOF_BITMAP_TEST(ret, value)) { - ANYOF_BITMAP_CLEAR(ret, value); - remove_list = add_cp_to_invlist(remove_list, value); + for (i = 0; i < 256; ++i) { + if (ANYOF_BITMAP_TEST(ret, i)) { + ANYOF_BITMAP_CLEAR(ret, i); + remove_list = add_cp_to_invlist(remove_list, i); } else { - ANYOF_BITMAP_SET(ret, value); + ANYOF_BITMAP_SET(ret, i); + prevvalue = value; + value = i; } } -- 1.8.3.1