refactor macro to avoid compiler warning in regcomp.c
authorRobin Barker (via RT) <perlbug-followup@perl.org>
Thu, 1 Mar 2012 15:20:33 +0000 (07:20 -0800)
committerKarl Williamson <public@khwilliamson.com>
Tue, 22 May 2012 14:24:23 +0000 (08:24 -0600)
The compiler warning in regcomp.c (as noted in recent comment)
can be avoided by refactoring DO_POSIX_LATIN1_ONLY_KNOWN
to separate the case where sourcelist==l1_sourcelist

The committer changed the name of the new macro so he could understand
it better, and added a couple comments

regcomp.c

index 2c296fa..eefc2cc 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10210,6 +10210,14 @@ S_checkposixcc(pTHX_ RExC_state_t *pRExC_state)
  * time */
 #define DO_POSIX_LATIN1_ONLY_KNOWN(node, class, destlist, sourcelist,      \
                               l1_sourcelist, Xpropertyname, run_time_list) \
+       /* First, resolve whether to use the ASCII-only list or the L1     \
+        * list */                                                         \
+        DO_POSIX_LATIN1_ONLY_KNOWN_L1_RESOLVED(node, class, destlist,      \
+                ((AT_LEAST_ASCII_RESTRICTED) ? sourcelist : l1_sourcelist),\
+                Xpropertyname, run_time_list)
+
+#define DO_POSIX_LATIN1_ONLY_KNOWN_L1_RESOLVED(node, class, destlist, sourcelist, \
+                Xpropertyname, run_time_list)                              \
     /* If not /a matching, there are going to be code points we will have  \
      * to defer to runtime to look-up */                                   \
     if (! AT_LEAST_ASCII_RESTRICTED) {                                     \
@@ -10219,11 +10227,7 @@ S_checkposixcc(pTHX_ RExC_state_t *pRExC_state)
         ANYOF_CLASS_SET(node, class);                                      \
     }                                                                      \
     else {                                                                 \
-        _invlist_union(destlist,                                           \
-                       (AT_LEAST_ASCII_RESTRICTED)                         \
-                           ? sourcelist                                    \
-                           : l1_sourcelist,                                \
-                       &destlist);                                         \
+        _invlist_union(destlist, sourcelist, &destlist);                   \
     }
 
 /* Like DO_POSIX_LATIN1_ONLY_KNOWN, but for the complement.  A combination of
@@ -10942,10 +10946,11 @@ parseit:
                                             PL_PosixCntrl, PL_XPosixCntrl);
                    break;
                case ANYOF_DIGIT:
-                   /* Ignore the compiler warning for this macro, planned to
-                    * be eliminated later */
-                   DO_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, properties,
-                        PL_PosixDigit, PL_PosixDigit, "XPosixDigit", listsv);
+                   /* There are no digits in the Latin1 range outside of
+                    * ASCII, so call the macro that doesn't have to resolve
+                    * them */
+                   DO_POSIX_LATIN1_ONLY_KNOWN_L1_RESOLVED(ret, namedclass, properties,
+                        PL_PosixDigit, "XPosixDigit", listsv);
                    break;
                case ANYOF_NDIGIT:
                    DO_N_POSIX_LATIN1_ONLY_KNOWN(ret, namedclass, properties,