summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-08-24 21:09:02 -0600
committerKarl Williamson <khw@cpan.org>2015-09-12 20:50:16 -0600
commitab87267cc6ac3b1ea950ee4e45bd80dea25b8f79 (patch)
treefc23927dea808ae76152be6fe4a25a096d245cea
parent47f5936b63e4d8d8534d6dd332de6fe8a8510626 (diff)
downloadperl-ab87267cc6ac3b1ea950ee4e45bd80dea25b8f79.tar.gz
PATCH: [perl #125892] qr/(?[ ]) regression with '!'
This regression was introduced in 5.22. It stems from a logic error I made in a complicated 'if' statement.
-rw-r--r--regcomp.c13
-rw-r--r--t/re/regex_sets.t2
2 files changed, 9 insertions, 6 deletions
diff --git a/regcomp.c b/regcomp.c
index 81c67e355e..3aa4bfbcdb 100644
--- 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");
diff --git a/t/re/regex_sets.t b/t/re/regex_sets.t
index a10bceaa47..ee161b2eeb 100644
--- a/t/re/regex_sets.t
+++ b/t/re/regex_sets.t
@@ -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: {