Skip to content

Commit ab87267

Browse files
committed
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.
1 parent 47f5936 commit ab87267

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

regcomp.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -13710,13 +13710,14 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist,
1371013710
/* If the top entry on the stack is an operator, it had
1371113711
* better be a '!', otherwise the entry below the top
1371213712
* operand should be an operator */
13713-
if ( ! (top_ptr = av_fetch(stack, top_index, FALSE))
13713+
if ( ! (top_ptr = av_fetch(stack, top_index, FALSE))
1371413714
|| (IS_OPERATOR(*top_ptr) && SvUV(*top_ptr) != '!')
13715-
|| top_index - fence < 1
13716-
|| ! (stacked_ptr = av_fetch(stack,
13717-
top_index - 1,
13718-
FALSE))
13719-
|| ! IS_OPERATOR(*stacked_ptr))
13715+
|| ( IS_OPERAND(*top_ptr)
13716+
&& ( top_index - fence < 1
13717+
|| ! (stacked_ptr = av_fetch(stack,
13718+
top_index - 1,
13719+
FALSE))
13720+
|| ! IS_OPERATOR(*stacked_ptr))))
1372013721
{
1372113722
RExC_parse++;
1372213723
vFAIL("Unexpected '(' with no preceding operator");

t/re/regex_sets.t

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ like("k", $still_fold, "/i on interpolated (?[ ]) is retained in outer without /
9797
eval 'my $x = qr/(?[ [a] ])/; qr/(?[ $x ])/';
9898
is($@, "", 'qr/(?[ [a] ])/ can be interpolated');
9999

100+
like("B", qr/(?[ [B] | ! ( [^B] ) ])/, "[perl #125892]");
101+
100102
if (! is_miniperl() && locales_enabled('LC_CTYPE')) {
101103
my $utf8_locale = find_utf8_ctype_locale;
102104
SKIP: {

0 commit comments

Comments
 (0)