New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(^|something) to left of \G breaks zero-length-match rule, causing looping #11640
Comments
From @jimavThis is a bug report for perl from james_avera@yahoo.com, A compound expression like (^|.) before \G seems to break Perl's As stated in the perlre man page, 'contents to the left of "\G" is not $_ = 'ABC'; which prints 'A' and then terminates because it considers the match However, if the "." is replaced by "(.|^)" then the example loops forever. In summary: /(.)\G/g fails on the second try (won't match zero-width twice) Flags: Site configuration information for perl 5.10.1: Configured by Debian Project at Fri Apr 22 19:20:15 UTC 2011. Summary of my perl5 (revision 5 version 10 subversion 1) configuration: Platform: Locally applied patches: @INC for perl 5.10.1: Environment for perl 5.10.1: |
From @jkeenanOn Thu, 08 Sep 2011 16:57:01 GMT, jimav wrote:
Still present in 5.24.0. -- |
The RT System itself - Status changed from 'new' to 'open' |
The example in perlre now loops forever |
Thus this is a 5.36 blocker |
I can take a look tomorrow maybe. |
Did I do this wrong?
That isn't the right output, but it doesnt loop forever. |
Oh, wait that is the right output, but the |
@khwilliamson when I execute the example from perlre.pod at line 1119 (modified to add a newline when it prints) I do not see an infinite loop:
Also, the docs in perlop.pod at line 2131 say this:
so I do not think this ticket should be a blocker. Note most of the docs for /g and \G are actually in perlop.pod. It is a bit weird that perlre.pod has an example that is specifically NOT supported by the docs in perlop.pod. I am not sure why so much of the documentation of the /g mode lives in perlop.pod and not in perlre.pod. It seems to me that if we don't expect \G at anywhere other than the start of a pattern to work properly then maybe we should forbid it being used at any other position and remove this example. (Probably not a good idea for 5.36) Also I did find the cause of this fwiw, regcomp.c line 6549:
Basically it treats any variable length prefix to \G to be equivalent to an infinitely long prefix like |
Migrated from rt.perl.org#98716 (status was 'open')
Searchable as RT98716$
The text was updated successfully, but these errors were encountered: