summaryrefslogtreecommitdiff
path: root/regexp.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-06-23 13:30:59 +0100
committerDavid Mitchell <davem@iabyn.com>2013-07-28 10:33:36 +0100
commit03c83e260b8bf6c564b49840536ccd6f47a794ac (patch)
tree330552035f00d63622becfc5766a0c2cac9839bd /regexp.h
parent8fe3c67a9d33417c317107b8f5a56ca88d4153a9 (diff)
downloadperl-03c83e260b8bf6c564b49840536ccd6f47a794ac.tar.gz
regexec: handle \G ourself, rather than in callers
Normally a /g match starts its processing at the previous pos() (or at char 0 if pos is not set); however in the case of something like /abc\G/ we actually need to start 3 characters before pos. This has been handled by the *callers* of regexec() subtracting prog->gofs from the stringarg arg before calling it, or by setting stringarg to strbeg for floating, such as /\w+\G/. This is clearly wrong: the callers of regexec() shouldn't need to worry about the details of getting \G right: move this code into regexec() itself. (Note that although this commit passes all tests, it quite possibly isn't logically correct. It will get fixed up further during the next few commits)
Diffstat (limited to 'regexp.h')
-rw-r--r--regexp.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/regexp.h b/regexp.h
index a86963c020..5fb85ec684 100644
--- a/regexp.h
+++ b/regexp.h
@@ -501,6 +501,9 @@ get_regex_charset_name(const U32 flags, STRLEN* const lenp)
#define RX_LASTPAREN(prog) (ReANY(prog)->lastparen)
#define RX_LASTCLOSEPAREN(prog) (ReANY(prog)->lastcloseparen)
#define RX_SAVED_COPY(prog) (ReANY(prog)->saved_copy)
+/* last match was zero-length */
+#define RX_ZERO_LEN(prog) \
+ (RX_OFFS(prog)[0].start + RX_GOFS(prog) == (UV)RX_OFFS(prog)[0].end)
#endif /* PLUGGABLE_RE_EXTENSION */