summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-07-13 21:18:50 +0100
committerDavid Mitchell <davem@iabyn.com>2013-07-28 10:33:38 +0100
commitfe3974be45584ef82847c18e12a8eed80feb77e1 (patch)
tree466f18f6c9a3ce9e5708dbf9e722f89dc63e9449 /regexec.c
parentdfa77d06f76732ca30c8606edc55c6fc01c9dbc7 (diff)
downloadperl-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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/regexec.c b/regexec.c
index 6b6e7c932e..48b21e7a03 100644
--- a/regexec.c
+++ b/regexec.c
@@ -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() */