diff options
author | David Mitchell <davem@iabyn.com> | 2013-07-21 11:31:21 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-07-28 10:33:40 +0100 |
commit | fef7148b7be4215ac55d92d11249b95cf4f08d5d (patch) | |
tree | 97d4a608696680f9d90266fe9ba54738d3624169 /regexec.c | |
parent | 5411a0e56ca69f51e1eeaf89ee0a73dcbcf05fb9 (diff) | |
download | perl-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.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -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; |