Skip to content

Commit

Permalink
Set RXf_RTRIM if the pattern *is* /[[:space:]]+\z/u
Browse files Browse the repository at this point in the history
We can be more flexible in our selection of patterns soon, but for now,
start with a minimal testcase.

We don't actually *do* anything yet, so we must "fail" in re_intuit_start.
  • Loading branch information
nwc10 authored and khwilliamson committed Jun 6, 2021
1 parent 5f9070e commit fcaa368
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions regcomp.c
Expand Up @@ -8488,6 +8488,15 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
&& *(STRING(first)) == ' '
&& OP(regnext(first)) == END )
RExC_rx->extflags |= (RXf_SKIPWHITE|RXf_WHITE);
else if (fop == PLUS
&& nop == POSIXU && FLAGS(next) == _CC_SPACE) {
regnode *second = regnext(first);
regnode *third = OP(second) == EOS ? regnext(second) : NULL;
if (third && OP(third) == END) {
/* /[[:space:]]+\z/u */
RExC_rx->extflags |= RXf_RTRIM;
}
}

}

Expand Down
6 changes: 6 additions & 0 deletions regexec.c
Expand Up @@ -921,6 +921,12 @@ Perl_re_intuit_start(pTHX_
/* not actually used within intuit, but zero for safety anyway */
reginfo->poscache_maxiter = 0;

if(prog->extflags & RXf_RTRIM) {
DEBUG_EXECUTE_r(Perl_re_printf( aTHX_
" rtrim intuit not yet implemented...\n"));
return rx_origin;
}

if (utf8_target) {
if ((!prog->anchored_utf8 && prog->anchored_substr)
|| (!prog->float_utf8 && prog->float_substr))
Expand Down

0 comments on commit fcaa368

Please sign in to comment.