Skip to content

Commit

Permalink
Also set RXf_RTRIM if the pattern is /[[:space:]]+$/u
Browse files Browse the repository at this point in the history
The current code can handle $ just as easily as \z because the optional
newline can also be matched by [[:space:]]. This wouldn't be guaranteed
by a more general "match backwards from the end" approach.
  • Loading branch information
nwc10 authored and khwilliamson committed Jun 6, 2021
1 parent 6e855fb commit f47501b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions regcomp.c
Expand Up @@ -8491,9 +8491,11 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
else if (fop == PLUS
&& nop == POSIXU && FLAGS(next) == _CC_SPACE) {
regnode *second = regnext(first);
regnode *third = OP(second) == EOS ? regnext(second) : NULL;
regnode *third = (OP(second) == EOS || OP(second) == SEOL)
? regnext(second) : NULL;
if (third && OP(third) == END) {
/* /[[:space:]]+\z/u */
/* /[[:space:]]+\z/u
* /[[:space:]]+$/u */
RExC_rx->extflags |= RXf_RTRIM | RXf_CHECK_ALL;
}
}
Expand Down

0 comments on commit f47501b

Please sign in to comment.