summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-07-21 11:31:21 +0100
committerDavid Mitchell <davem@iabyn.com>2013-07-28 10:33:40 +0100
commitfef7148b7be4215ac55d92d11249b95cf4f08d5d (patch)
tree97d4a608696680f9d90266fe9ba54738d3624169
parent5411a0e56ca69f51e1eeaf89ee0a73dcbcf05fb9 (diff)
downloadperl-fef7148b7be4215ac55d92d11249b95cf4f08d5d.tar.gz
regexec: swap ganch setting and gofs offsetting
These two block of code are currently independent of each other, but swap them round so that the calculated ganch value will be available for more more clever gofs offset processing.
-rw-r--r--regexec.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/regexec.c b/regexec.c
index 9015f7d38a..cf23fefe5c 100644
--- a/regexec.c
+++ b/regexec.c
@@ -2250,6 +2250,18 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
if (prog->extflags & RXf_GPOS_SEEN) {
MAGIC *mg;
+ /* set reginfo->ganch, the position where \G can match */
+
+ reginfo->ganch =
+ (flags & REXEC_IGNOREPOS)
+ ? stringarg /* use start pos rather than pos() */
+ : (sv && (mg = mg_find_mglob(sv)) && mg->mg_len >= 0)
+ ? strbeg + mg->mg_len /* Defined pos() */
+ : strbeg; /* pos() not defined; use start of string */
+
+ DEBUG_GPOS_r(PerlIO_printf(Perl_debug_log,
+ "GPOS ganch set to strbeg[%"IVdf"]\n", reginfo->ganch - strbeg));
+
/* in the presence of \G, we may need to start looking earlier in
* the string than the suggested start point of stringarg:
* if gofs->prog is set, then that's a known, fixed minimum
@@ -2267,18 +2279,6 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
}
else if (prog->extflags & RXf_GPOS_FLOAT)
startpos = strbeg;
-
- /* set reginfo->ganch, the position where \G can match */
-
- reginfo->ganch =
- (flags & REXEC_IGNOREPOS)
- ? stringarg /* use start pos rather than pos() */
- : (sv && (mg = mg_find_mglob(sv)) && mg->mg_len >= 0)
- ? strbeg + mg->mg_len /* Defined pos() */
- : strbeg; /* pos() not defined; use start of string */
-
- DEBUG_GPOS_r(PerlIO_printf(Perl_debug_log,
- "GPOS ganch set to strbeg[%"IVdf"]\n", reginfo->ganch - strbeg));
}
minlen = prog->minlen;