summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-01-06 10:18:53 -0700
committerKarl Williamson <public@khwilliamson.com>2012-01-13 09:58:39 -0700
commita9746a27a5180d49f9208789465ec399c6dd804c (patch)
treea0c3444973cbd3240881eca19d019eff641386de /regcomp.c
parent210e6c474f5ee0999067e3bcc136cd8bffc22f25 (diff)
downloadperl-a9746a27a5180d49f9208789465ec399c6dd804c.tar.gz
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.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/regcomp.c b/regcomp.c
index 1bcfc68558..1b738b6598 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;
}
}