diff options
author | David Mitchell <davem@iabyn.com> | 2013-07-13 21:18:50 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-07-28 10:33:38 +0100 |
commit | fe3974be45584ef82847c18e12a8eed80feb77e1 (patch) | |
tree | 466f18f6c9a3ce9e5708dbf9e722f89dc63e9449 /regexec.c | |
parent | dfa77d06f76732ca30c8606edc55c6fc01c9dbc7 (diff) | |
download | perl-fe3974be45584ef82847c18e12a8eed80feb77e1.tar.gz |
regexec(): fix ganch and till settings
Since startpos is now the \G-adjusted start position, use the real start
position instead (stringarg) when setting reginfo->till, and when setting
ganch in the non-pos case.
This stops this infinitely looping:
$_ = "x"; pos = 1; @a = /x\G/g
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -2329,7 +2329,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend, reginfo->poscache_maxiter = 0; /* not yet started a countdown */ reginfo->strend = strend; /* see how far we have to get to not match where we matched before */ - reginfo->till = startpos + minend; + reginfo->till = stringarg + minend; if (prog->extflags & RXf_EVAL_SEEN && SvPADTMP(sv) && !IS_PADGV(sv)) { /* SAVEFREESV, not sv_mortalcopy, as this SV must last until after @@ -2398,9 +2398,9 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend, if (prog->extflags & RXf_GPOS_SEEN) { /* Need to set reginfo->ganch */ MAGIC *mg; if (flags & REXEC_IGNOREPOS){ /* Means: check only at start */ - reginfo->ganch = startpos + prog->gofs; + reginfo->ganch = stringarg; DEBUG_GPOS_r(PerlIO_printf(Perl_debug_log, - "GPOS IGNOREPOS: reginfo->ganch = startpos + %"UVxf"\n",(UV)prog->gofs)); + "GPOS IGNOREPOS: reginfo->ganch = stringarg\n")); } else if (sv && (mg = mg_find_mglob(sv)) && mg->mg_len >= 0) { reginfo->ganch = strbeg + mg->mg_len; /* Defined pos() */ |