[Perl/perl5] 9715a3: regexec.c - make find_byclass() work with (*SKIP) ...

2023-09-30 Thread Yves Orton via perl5-changes
  Branch: refs/heads/yves/fix_21534_skip_with_find_byclass_in_match
  Home:   https://github.com/Perl/perl5
  Commit: 9715a3bac67ea2cc00929e81b436ae441ef1dcde
  
https://github.com/Perl/perl5/commit/9715a3bac67ea2cc00929e81b436ae441ef1dcde
  Author: Yves Orton 
  Date:   2023-09-30 (Sat, 30 Sep 2023)

  Changed paths:
M regexec.c
M t/re/pat_advanced.t

  Log Message:
  ---
  regexec.c - make find_byclass() work with (*SKIP) and friends

This fixes https://github.com/Perl/perl5/issues/21534

We have an optimisation that applies to patterns starting with a PLUS
style pattern, so that things like /A+B/ do not try to match at every A
when B does not match after the the first attempt. Eg,
"AAC"=~/[Aa]+[CD]/ should not try to match at every 'A' in
the first sequence of 'A's. This optimisation is signalled by the
presence of an PREGf_SKIP flag.

The PLUS optimisation did not play nicely with patterns which were doing
a similar task using the (*SKIP) operator. Essentially we need to
disable the former when the latter has been used, or it can get
confused. Consider the case of

"AABBBAC"=~/[Aa]+(?:[Bb]+(*SKIP)(*FAIL)|[CD])/.

The idea is to signal to the regex engine that once "AB" is
matched it can continue from after the final 'B'. Because of the way the
PLUS optimizatin is implemented, this advancing of the pointer to the
last B confused things, and it failed to match the final C sequence.
This patch is somewhat of a bodge, it shouldnt be necessary to inspect
inside of reginfo() after a call to regtry() and it is a bit
counter-intuitive to do so. This patch wraps the check in a macro so
that at least it is somewhat self documenting what it is doing.




[Perl/perl5] ea7c81: regexec.c - make find_byclass() work with (*SKIP) ...

2023-09-30 Thread Yves Orton via perl5-changes
  Branch: refs/heads/yves/fix_21534_skip_with_find_byclass_in_match
  Home:   https://github.com/Perl/perl5
  Commit: ea7c81dfea22db6024a999fc133c449671345295
  
https://github.com/Perl/perl5/commit/ea7c81dfea22db6024a999fc133c449671345295
  Author: Yves Orton 
  Date:   2023-09-30 (Sat, 30 Sep 2023)

  Changed paths:
M regexec.c
M t/re/pat_advanced.t

  Log Message:
  ---
  regexec.c - make find_byclass() work with (*SKIP) and friends

This fixes https://github.com/Perl/perl5/issues/21534

When the previous_occurence_end logic was added it did not account for
patterns where "s" is updated by regtry(). See 21d1ed5 which introduced
this logic. That patch seemed to assume that regtry() would not alter s,
but it does. This fix seems to work around the problem for the verb's,
but it feels like a bodge instead of a proper fix, which I think would
involve reworking the previous_occurrence_end logic to take into account
that regtry() can modify s. But for now this should work.