Reinstate "regcomp.c: Change, variable, fcn name"
authorKarl Williamson <public@khwilliamson.com>
Sat, 6 Jul 2013 20:29:35 +0000 (14:29 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 16 Jul 2013 19:58:07 +0000 (13:58 -0600)
This reverts commit 0b58015e05b2ab93b080b7c49a70bf82435363c0, which
reverted 875c4e2c5193b5245da578b222e9c93aad31d93b, thus reinstating the
latter commit.  It turns out that the error being chased down was not
due to this commit.

Its original message was (slightly revised for clarity):

These have always been slightly misnamed, but a recent commit made them
more so.  The old name contained "zero", but now there is a new element
which always has zero.  The renamed element indicates whether the
inversion list is offset, that is if the beginning is the zero element,
or if the beginning is the next element beyond the zero element.

embed.fnc
embed.h
inline_invlist.c
proto.h
regcomp.c

index 32e99fe..a4c1e3d 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1434,7 +1434,7 @@ EsM       |void   |_append_range_to_invlist   |NN SV* const invlist|const UV start|const
 EiMR   |UV*    |_invlist_array_init    |NN SV* const invlist|const bool will_have_0
 EiMR   |UV*    |invlist_array  |NN SV* const invlist
 EsM    |void   |invlist_extend    |NN SV* const invlist|const UV len
-EiMR   |UV*    |get_invlist_zero_addr  |NN SV* invlist
+EiMR   |UV*|get_invlist_offset_addr|NN SV* invlist
 EiMR   |UV     |invlist_max    |NN SV* const invlist
 EiM    |void   |invlist_set_len|NN SV* const invlist|const UV len
 EiMR   |IV*    |get_invlist_previous_index_addr|NN SV* invlist
diff --git a/embed.h b/embed.h
index 965d74a..4870648 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define compute_EXACTish(a)    S_compute_EXACTish(aTHX_ a)
 #define could_it_be_a_POSIX_class(a)   S_could_it_be_a_POSIX_class(aTHX_ a)
 #define get_invlist_iter_addr(a)       S_get_invlist_iter_addr(aTHX_ a)
+#define get_invlist_offset_addr(a)     S_get_invlist_offset_addr(aTHX_ a)
 #define get_invlist_previous_index_addr(a)     S_get_invlist_previous_index_addr(aTHX_ a)
-#define get_invlist_zero_addr(a)       S_get_invlist_zero_addr(aTHX_ a)
 #define grok_bslash_N(a,b,c,d,e,f,g)   S_grok_bslash_N(aTHX_ a,b,c,d,e,f,g)
 #define handle_regex_sets(a,b,c,d,e)   S_handle_regex_sets(aTHX_ a,b,c,d,e)
 #define invlist_array(a)       S_invlist_array(aTHX_ a)
index 5d239bd..21d6282 100644 (file)
@@ -18,8 +18,8 @@
 #define INVLIST_VERSION_ID_OFFSET 1
 #define INVLIST_VERSION_ID 1511554547
 
-#define INVLIST_ZERO_OFFSET 2  /* 0 or 1 */
-/* The UV at position ZERO contains either 0 or 1.  If 0, the inversion list
+#define INVLIST_OFFSET_OFFSET 2        /* 0 or 1 */
+/* The UV at this position contains either 0 or 1.  If 0, the inversion list
  * contains the code point U+00000, and begins at element [0] in the array,
  * which always contains 0.  If 1, the inversion list doesn't contain U+0000,
  * and it begins at element [1].  Inverting an inversion list consists of
@@ -29,7 +29,7 @@
 /* For safety, when adding new elements, remember to #undef them at the end of
  * the inversion list code section */
 
-#define HEADER_LENGTH (INVLIST_ZERO_OFFSET + 2) /* includes 1 for the constant
+#define HEADER_LENGTH (INVLIST_OFFSET_OFFSET + 2) /* includes 1 for the constant
                                                    0 element */
 
 /* An element is in an inversion list iff its index is even numbered: 0, 2, 4,
diff --git a/proto.h b/proto.h
index 37fc6b0..4dceb0a 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6509,16 +6509,16 @@ PERL_STATIC_INLINE STRLEN*      S_get_invlist_iter_addr(pTHX_ SV* invlist)
 #define PERL_ARGS_ASSERT_GET_INVLIST_ITER_ADDR \
        assert(invlist)
 
-PERL_STATIC_INLINE IV* S_get_invlist_previous_index_addr(pTHX_ SV* invlist)
+PERL_STATIC_INLINE UV* S_get_invlist_offset_addr(pTHX_ SV* invlist)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT_GET_INVLIST_PREVIOUS_INDEX_ADDR       \
+#define PERL_ARGS_ASSERT_GET_INVLIST_OFFSET_ADDR       \
        assert(invlist)
 
-PERL_STATIC_INLINE UV* S_get_invlist_zero_addr(pTHX_ SV* invlist)
+PERL_STATIC_INLINE IV* S_get_invlist_previous_index_addr(pTHX_ SV* invlist)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT_GET_INVLIST_ZERO_ADDR \
+#define PERL_ARGS_ASSERT_GET_INVLIST_PREVIOUS_INDEX_ADDR       \
        assert(invlist)
 
 STATIC bool    S_grok_bslash_N(pTHX_ struct RExC_state_t *pRExC_state, regnode** nodep, UV *valuep, I32 *flagp, U32 depth, bool in_char_class, const bool strict)
index 64aacf0..cc456ee 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7084,7 +7084,7 @@ S__invlist_array_init(pTHX_ SV* const invlist, const bool will_have_0)
      * element is either the final part of the header reserved for 0, if TRUE,
      * or the first element of the non-heading part, if FALSE */
 
-    UV* zero = get_invlist_zero_addr(invlist);
+    UV* offset = get_invlist_offset_addr(invlist);
 
     PERL_ARGS_ASSERT__INVLIST_ARRAY_INIT;
 
@@ -7092,9 +7092,9 @@ S__invlist_array_init(pTHX_ SV* const invlist, const bool will_have_0)
     assert(! *_get_invlist_len_addr(invlist));
 
     /* 1^1 = 0; 1^0 = 1 */
-    *zero = 1 ^ will_have_0;
-    *(zero + 1) = 0;
-    return 1 + zero + *zero;
+    *offset = 1 ^ will_have_0;
+    *(offset + 1) = 0;
+    return (UV *) (1 + offset + *offset);
 }
 
 PERL_STATIC_INLINE UV*
@@ -7109,16 +7109,16 @@ S_invlist_array(pTHX_ SV* const invlist)
     /* Must not be empty.  If these fail, you probably didn't check for <len>
      * being non-zero before trying to get the array */
     assert(*_get_invlist_len_addr(invlist));
-    assert(*get_invlist_zero_addr(invlist) == 0
-          || *get_invlist_zero_addr(invlist) == 1);
+    assert(*get_invlist_offset_addr(invlist) == 0
+          || *get_invlist_offset_addr(invlist) == 1);
 
     /* The array begins either at the header element reserved for zero or the
-     * element after that.  The reserved element is 1 past the zero_addr
+     * element after that.  The reserved element is 1 past the offset_addr
      * element; the latter contains 0 or 1 to indicate how much additionally to
      * add */
-    assert(0 == *(1 + get_invlist_zero_addr(invlist)));
-    return (UV *) (1 + get_invlist_zero_addr(invlist)
-                  + *get_invlist_zero_addr(invlist));
+    assert(0 == *(1 + get_invlist_offset_addr(invlist)));
+    return (UV *) (1 + get_invlist_offset_addr(invlist)
+                  + *get_invlist_offset_addr(invlist));
 }
 
 PERL_STATIC_INLINE void
@@ -7183,14 +7183,14 @@ S_invlist_max(pTHX_ SV* const invlist)
 }
 
 PERL_STATIC_INLINE UV*
-S_get_invlist_zero_addr(pTHX_ SV* invlist)
+S_get_invlist_offset_addr(pTHX_ SV* invlist)
 {
     /* Return the address of the UV that says whether the inversion list is
      * offset (it contains 1) or not (contains 0) */
 
-    PERL_ARGS_ASSERT_GET_INVLIST_ZERO_ADDR;
+    PERL_ARGS_ASSERT_GET_INVLIST_OFFSET_ADDR;
 
-    return (UV *) (SvPVX(invlist) + (INVLIST_ZERO_OFFSET * sizeof (UV)));
+    return (UV *) (SvPVX(invlist) + (INVLIST_OFFSET_OFFSET * sizeof (UV)));
 }
 
 #ifndef PERL_IN_XSUB_RE
@@ -7203,7 +7203,7 @@ Perl__new_invlist(pTHX_ IV initial_size)
      * system default is used instead */
 
     SV* new_list;
-    UV* zero_addr;
+    UV* offset_addr;
 
     if (initial_size < 0) {
        initial_size = INVLIST_INITIAL_LEN;
@@ -7220,9 +7220,9 @@ Perl__new_invlist(pTHX_ IV initial_size)
 
     /* This should force a segfault if a method doesn't initialize this
      * properly */
-    zero_addr = get_invlist_zero_addr(new_list);
-    *zero_addr = UV_MAX;
-    *(zero_addr + 1) = 0;
+    offset_addr = get_invlist_offset_addr(new_list);
+    *offset_addr = (unsigned) UV_MAX;
+    *(offset_addr + 1) = 0;
 
     *get_invlist_previous_index_addr(new_list) = 0;
 #if HEADER_LENGTH != 4
@@ -8060,7 +8060,7 @@ Perl__invlist_invert(pTHX_ SV* const invlist)
     /* The exclusive or complents 0 to 1; and 1 to 0.  If the result is 1, the
      * zero element was a 0, so it is being removed, so the length decrements
      * by 1; and vice-versa.  SvCUR is unaffected */
-    if (*get_invlist_zero_addr(invlist) ^= 1) {
+    if (*get_invlist_offset_addr(invlist) ^= 1) {
        (*len_pos)--;
     }
     else {
@@ -8372,7 +8372,7 @@ S__invlistEQ(pTHX_ SV* const a, SV* const b, const bool complement_b)
 #undef TO_INTERNAL_SIZE
 #undef FROM_INTERNAL_SIZE
 #undef INVLIST_LEN_OFFSET
-#undef INVLIST_ZERO_OFFSET
+#undef INVLIST_OFFSET_OFFSET
 #undef INVLIST_VERSION_ID
 
 /* End of inversion list object */