This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #125892] qr/(?[ ]) regression with '!'
authorKarl Williamson <khw@cpan.org>
Tue, 25 Aug 2015 03:09:02 +0000 (21:09 -0600)
committerKarl Williamson <khw@cpan.org>
Sun, 13 Sep 2015 02:50:16 +0000 (20:50 -0600)
This regression was introduced in 5.22.  It stems from a logic error I
made in a complicated 'if' statement.

regcomp.c
t/re/regex_sets.t

index 81c67e3..3aa4bfb 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13710,13 +13710,14 @@ redo_curchar:
                     /* If the top entry on the stack is an operator, it had
                      * better be a '!', otherwise the entry below the top
                      * operand should be an operator */
-                    if ( ! (top_ptr = av_fetch(stack, top_index, FALSE))
+                    if (   ! (top_ptr = av_fetch(stack, top_index, FALSE))
                         || (IS_OPERATOR(*top_ptr) && SvUV(*top_ptr) != '!')
-                        || top_index - fence < 1
-                        || ! (stacked_ptr = av_fetch(stack,
-                                                     top_index - 1,
-                                                     FALSE))
-                        || ! IS_OPERATOR(*stacked_ptr))
+                        || (   IS_OPERAND(*top_ptr)
+                            && (   top_index - fence < 1
+                                || ! (stacked_ptr = av_fetch(stack,
+                                                             top_index - 1,
+                                                             FALSE))
+                                || ! IS_OPERATOR(*stacked_ptr))))
                     {
                         RExC_parse++;
                         vFAIL("Unexpected '(' with no preceding operator");
index a10bcea..ee161b2 100644 (file)
@@ -97,6 +97,8 @@ like("k", $still_fold, "/i on interpolated (?[ ]) is retained in outer without /
 eval 'my $x = qr/(?[ [a] ])/; qr/(?[ $x ])/';
 is($@, "", 'qr/(?[ [a] ])/ can be interpolated');
 
+like("B", qr/(?[ [B] | ! ( [^B] ) ])/, "[perl #125892]");
+
 if (! is_miniperl() && locales_enabled('LC_CTYPE')) {
     my $utf8_locale = find_utf8_ctype_locale;
     SKIP: {