regcomp.c: Can't do optimization if inverting
authorKarl Williamson <khw@cpan.org>
Fri, 19 Feb 2016 18:11:40 +0000 (11:11 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 19 Feb 2016 18:27:10 +0000 (11:27 -0700)
Something like /[^\W_0-9]/ was getting optimized into something it
shouldn't have been.  Although, the way the execution code is
structured, I couldn't find a case where it actually made a difference.
So skip the optimization if inverting.

regcomp.c

index cec854a..4c60a6a 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -17051,6 +17051,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
     if (   has_upper_latin1_only_utf8_matches
         || MATCHES_ALL_NON_UTF8_NON_ASCII(ret))
     {
+        /* But not if we are inverting, as that screws it up */
+        if (! invert) {
         if (has_upper_latin1_only_utf8_matches) {
             if (MATCHES_ALL_NON_UTF8_NON_ASCII(ret)) {
 
@@ -17097,6 +17099,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
             SvREFCNT_dec_NN(only_non_utf8_list);
             only_non_utf8_list = NULL;;
         }
+        }
 
         /* If we haven't gotten rid of all conditional matching, we change the
          * regnode type to indicate that */