-
Notifications
You must be signed in to change notification settings - Fork 574
Unexpected behavior with a regular expression #15666
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
Comments
From @jormalaaksonenCreated by @jormalaaksonen#! /usr/bin/perl use strict; my @a = "riiaan" =~ /.*?(xs|p)*(a(a)|i(i))n/; Running it shows me: 0 0 6 [riiaan] so the last regexp group (i) seems to have been matched as "ri(i)aan" 0 0 6 [riiaan] Any hint if I'm doing something wrong or not doing something I should Yours, Jorma Perl Info
|
From zefram@fysh.orgJorma Laaksonen wrote:
No, that's all supported usage. You're quite right about the behaviour -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From @demerphqOn 17 October 2016 at 04:50, Zefram <zefram@fysh.org> wrote:
Agreed. It seems to be a bug about unwinding .*? although it also interacts Nevertheless I can fix the bug (while possibly introducing new bugs) I would prefer that Dave have a look into this, as I dont entirely The key point is that when we fail a .*? match we should unwind and I have to admit that this bug is quite surprising. I would have Of course, it may have to do with the fact that the form of this bug So it may simply be that most times we dont trigger this bug, but I Yves commit c09f087 provisional patch to fix [perl #129897] Inline Patchdiff --git a/regexec.c b/regexec.c
index e9e23f2..0cde487 100644
--- a/regexec.c
+++ b/regexec.c
@@ -7868,6 +7868,8 @@ NULL
case STAR: /* /A*B/ where A is width 1 char */
ST.paren = 0;
+ ST.lastparen = rex->lastparen;
+ ST.lastcloseparen = rex->lastcloseparen;
ST.min = 0;
ST.max = REG_INFTY;
scan = NEXTOPER(scan);
@@ -7875,6 +7877,8 @@ NULL
case PLUS: /* /A+B/ where A is width 1 char */
ST.paren = 0;
+ ST.lastparen = rex->lastparen;
+ ST.lastcloseparen = rex->lastcloseparen;
ST.min = 1;
ST.max = REG_INFTY;
scan = NEXTOPER(scan);
@@ -7900,6 +7904,8 @@ NULL
ST.paren = 0;
ST.min = ARG1(scan); /* min to match */
ST.max = ARG2(scan); /* max to match */
+ ST.lastparen = rex->lastparen;
+ ST.lastcloseparen = rex->lastcloseparen;
scan = NEXTOPER(scan) + NODE_STEP_REGNODE;
repeat:
/*
@@ -8013,7 +8019,7 @@ NULL
/* failed to find B in a non-greedy match where c1,c2 valid */
REGCP_UNWIND(ST.cp);
- if (ST.paren) {
+ if ( 1 || ST.paren ) {
UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
}
/* Couldn't or didn't -- move forward. */
@@ -8086,7 +8092,7 @@ NULL
/* failed to find B in a non-greedy match where c1,c2 invalid */
REGCP_UNWIND(ST.cp);
- if (ST.paren) {
+ if ( 1 || ST.paren ) {
UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
}
/* failed -- move forward one */
@@ -8147,7 +8153,7 @@ NULL
/* failed to find B in a greedy match */
REGCP_UNWIND(ST.cp);
- if (ST.paren) {
+ if ( 1 || ST.paren ) {
UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
}
/* back up. */
-- perl -Mre=debug -e "/just|another|perl|hacker/" |
From @demerphqOn 17 October 2016 at 18:37, demerphq <demerphq@gmail.com> wrote:
Cause my analysis was wrong... Dave, forget it, nothing you need to poke into. Put simply, the "short-circuit" logic in the TRIE code should not I have a patch ready, but i am having issues talking to the master Yves |
From @jormalaaksonenOn Mon Oct 17 14:40:47 2016, demerphq wrote:
Thank you for your rapid responses and the patch. I'm happy to confirm that the fix has removed all problems I had associated to this behavior or perl. Thanks, Jorma |
From @hvdsOn Mon, 17 Oct 2016 14:40:47 -0700, demerphq wrote:
It appears this did eventually go in as cfe04db: .. with a followup to fix the test in ac2365f. I'm setting it to 'pending release' - Yves, please correct it if that was inappropriate. Hugo |
@hvds - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.26.0, this and 210 other issues have been Perl 5.26.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#129897 (status was 'resolved')
Searchable as RT129897$
The text was updated successfully, but these errors were encountered: