diff options
author | David Mitchell <davem@iabyn.com> | 2013-05-18 15:05:57 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-06-02 22:28:50 +0100 |
commit | 52a21eb36148cc4f249f436a989e2cfe5c6bab1f (patch) | |
tree | e85cc834c1b706d4f5245c6aef489970a0e6621a /ext/re | |
parent | f9176b44e50593d8f3446da63d3989558f6d4c20 (diff) | |
download | perl-52a21eb36148cc4f249f436a989e2cfe5c6bab1f.tar.gz |
add strbeg argument to Perl_re_intuit_start()
(note that this is a change both to the perl API and the regex engine
plugin API).
Currently, Perl_re_intuit_start() is passed an SV, plus pointers to:
where in the string to start matching (strpos); and to the end of the
string (strend).
Unlike Perl_regexec_flags(), it doesn't also have a strbeg arg.
Because of this this, it guesses strbeg: based on the passed SV (if its
svPOK()); or just set to strpos otherwise. This latter can happen if for
example the SV is overloaded. Note also that this latter guess is wrong,
and could in theory make /\b.../ fail.
But just to confuse matters, although Perl_re_intuit_start() itself uses
its guesstimate strbeg var, some of the functions it calls use the global
value of PL_bostr instead. To make this work, the *callers* of
Perl_re_intuit_start() currently set PL_bostr first. This is why \b
doesn't actually break.
The fix to this unholy mess is to simply add a strbeg arg to
Perl_re_intuit_start(). It's also the first step to eliminating PL_bostr
altogether.
Diffstat (limited to 'ext/re')
-rw-r--r-- | ext/re/re.pm | 2 | ||||
-rw-r--r-- | ext/re/re.xs | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/ext/re/re.pm b/ext/re/re.pm index 6e9e9b0f29..ebad00a66a 100644 --- a/ext/re/re.pm +++ b/ext/re/re.pm @@ -4,7 +4,7 @@ package re; use strict; use warnings; -our $VERSION = "0.24"; +our $VERSION = "0.25"; our @ISA = qw(Exporter); our @EXPORT_OK = ('regmust', qw(is_regexp regexp_pattern diff --git a/ext/re/re.xs b/ext/re/re.xs index 1da68f12ee..93a3b9cac1 100644 --- a/ext/re/re.xs +++ b/ext/re/re.xs @@ -20,9 +20,15 @@ extern I32 my_regexec (pTHX_ REGEXP * const prog, char* stringarg, char* strend, char* strbeg, I32 minend, SV* screamer, void* data, U32 flags); -extern char* my_re_intuit_start (pTHX_ REGEXP * const prog, SV *sv, char *strpos, - char *strend, const U32 flags, - struct re_scream_pos_data_s *data); +extern char* my_re_intuit_start(pTHX_ + REGEXP * const rx, + SV *sv, + const char * const strbeg, + char *strpos, + char *strend, + const U32 flags, + re_scream_pos_data *data); + extern SV* my_re_intuit_string (pTHX_ REGEXP * const prog); extern void my_regfree (pTHX_ REGEXP * const r); |