b8c914
From 8121278aa8fe72e9e8aca8651c7f1d4fa204ac1d Mon Sep 17 00:00:00 2001
b8c914
From: Karl Williamson <khw@cpan.org>
b8c914
Date: Mon, 2 Apr 2018 21:54:59 -0600
b8c914
Subject: [PATCH] PATCH: [perl #132167] Parse error in regex_sets
b8c914
MIME-Version: 1.0
b8c914
Content-Type: text/plain; charset=UTF-8
b8c914
Content-Transfer-Encoding: 8bit
b8c914
b8c914
When popping the stack, the code inappropriately also subtracted one
b8c914
from the result.  This is probably left over from an earlier change in
b8c914
the implementation.  The top of the stack contained the correct value;
b8c914
subtracting was a mistake.
b8c914
b8c914
Signed-off-by: Petr Písař <ppisar@redhat.com>
b8c914
---
b8c914
 regcomp.c         |  2 +-
b8c914
 t/re/regex_sets.t | 11 +++++++++++
b8c914
 2 files changed, 12 insertions(+), 1 deletion(-)
b8c914
b8c914
diff --git a/regcomp.c b/regcomp.c
b8c914
index 018d5646fc..39ab260efa 100644
b8c914
--- a/regcomp.c
b8c914
+++ b/regcomp.c
b8c914
@@ -15689,7 +15689,7 @@ redo_curchar:
b8c914
                  * fence.  Get rid of it */
b8c914
                 fence_ptr = av_pop(fence_stack);
b8c914
                 assert(fence_ptr);
b8c914
-                fence = SvIV(fence_ptr) - 1;
b8c914
+                fence = SvIV(fence_ptr);
b8c914
                 SvREFCNT_dec_NN(fence_ptr);
b8c914
                 fence_ptr = NULL;
b8c914
 
b8c914
diff --git a/t/re/regex_sets.t b/t/re/regex_sets.t
b8c914
index e9644bd4e6..e70df81254 100644
b8c914
--- a/t/re/regex_sets.t
b8c914
+++ b/t/re/regex_sets.t
b8c914
@@ -204,6 +204,17 @@ for my $char ("٠", "٥", "٩") {
b8c914
     like("a", qr/$pat/, "/$pat/ compiles and matches 'a'");
b8c914
 }
b8c914
 
b8c914
+{   # [perl #132167]
b8c914
+    fresh_perl_is('no warnings "experimental::regex_sets";
b8c914
+        print "c" =~ qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b]))  ])/;',
b8c914
+        1, {},
b8c914
+        'qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b]))  ]) compiles and properly matches');
b8c914
+    fresh_perl_is('no warnings "experimental::regex_sets";
b8c914
+        print "b" =~ qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b]))  ])/;',
b8c914
+        "", {},
b8c914
+        'qr/(?[ ( \p{Uppercase} ) + (\p{Lowercase} - ([a] + [b]))  ]) compiles and properly matches');
b8c914
+}
b8c914
+
b8c914
 done_testing();
b8c914
 
b8c914
 1;
b8c914
-- 
b8c914
2.14.3
b8c914