Branch: refs/heads/yves/24944_MBOL_BOUND
  Home:   https://github.com/Perl/perl5
  Commit: 9be927102b3103306d8a2b786c98e8d921096c39
      
https://github.com/Perl/perl5/commit/9be927102b3103306d8a2b786c98e8d921096c39
  Author: Richard Leach <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

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

  Log Message:
  -----------
  Perl_re_intuit_start: don't shrink strend for anchored MBOL matches

For a while, anchored matches have used the following to determine the
offset argument to pass to `HOP3clim` (or predecessors):

    (prog->minlen ? cl_l : 0)

The return value is assigned to `endpos`, which is passed in the place
of `strend` (thought it could actually _be_ `strend`) to `S_find_byclass`.

Exactly what that logic is - or was - supposed to do has long been
unclear. Long-standing comments were opaque and fresher comments
stated as much, along with noting that nothing in the test harness
exercised the `prog->minlen` case.

GH #24944 provided an example in the form of a test case that should
match but failed to do so:

    "a" =~ /\A^\ba*\z/m

Specifically:
* `MBOL` (`^`)`made that an anchored substring
* The pattern can successfully match with zero characters
* The ternary in question resulted in `endpos` matching `rx_origin`
* Within `S_find_byclass`, the `REXEC_FBC_NON_UTF8_SCAN` loop used
  by the `BOUND` case was only only entered if `endpos` > `rx_origin`.
* Not entering that loop caused the match to fail.

This commit replaces the ternary with just `cl_l`, making the test case
pass and not breaking anything in the test harness.

Because of the historical uncertainty around the logic in the first
place, including no test coverage, it is unclear whether there could
be any assumption or code in the wild that depended on the old
behaviour.


  Commit: 80d6b8fa38122a1c51c42f68a37724c83c5b35ad
      
https://github.com/Perl/perl5/commit/80d6b8fa38122a1c51c42f68a37724c83c5b35ad
  Author: Yves Orton <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

  Changed paths:
    M regexec.c

  Log Message:
  -----------
  rework comment

I did a bit of research into this and this is what i came up with.


  Commit: 4f3fef086d388fd89f0c4b6475196da4fe1946a1
      
https://github.com/Perl/perl5/commit/4f3fef086d388fd89f0c4b6475196da4fe1946a1
  Author: Yves Orton <[email protected]>
  Date:   2026-10-15 (Thu, 15 Oct 2026)

  Changed paths:
    M regexec.c

  Log Message:
  -----------
  regexec.c - rework diagnostict to be less misleading

The diagnostic was arguably backwards.


Compare: https://github.com/Perl/perl5/compare/9be927102b31%5E...4f3fef086d38

To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to