summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-04-09 17:17:16 +0100
committerDavid Mitchell <davem@iabyn.com>2013-04-12 11:29:55 +0100
commit3a54fd60e3d777bf86f4eec331b79a61c23d8393 (patch)
tree09ca42e0a07d6bff9f76154f28fc911503959ffb
parentc1789b9f89e17b99d728910cb490561f334c2033 (diff)
downloadperl-3a54fd60e3d777bf86f4eec331b79a61c23d8393.tar.gz
add lex_re_reparsing boolean to yy_parser struct
When re-parsing a pattern for run-time (?{}) code blocks, we end up with the EVAL_RE_REPARSING flag set in PL_in_eval. Currently we clear this flag as soon as scan_str() returns, to ensure that it's not set if we happen to parse further patterns (e.g. within the (?{ ... }) code itself. However, a soon-to-be-applied bugfix requires us to know the reparsing state beyond this point. To solve this, we add a new boolean flag to the parser struct, which is set from PL_in_eval in S_sublex_push() (with the old value being saved). This allows us to have the flag around for the entire pattern string parsing phase, without it affecting nested pattern compilation.
-rw-r--r--parser.h2
-rw-r--r--regcomp.c3
-rw-r--r--regexec.c2
-rw-r--r--toke.c7
4 files changed, 6 insertions, 8 deletions
diff --git a/parser.h b/parser.h
index 05735bfe76..e7b887ec3b 100644
--- a/parser.h
+++ b/parser.h
@@ -71,7 +71,7 @@ typedef struct yy_parser {
char multi_open; /* delimiter of said string */
char multi_close; /* delimiter of said string */
bool preambled;
- /*** 8-bit hole ***/
+ bool lex_re_reparsing; /* we're doing G_RE_REPARSING */
I32 lex_allbrackets;/* (), [], {}, ?: bracket count */
SUBLEXINFO sublex_info;
LEXSHARED *lex_shared;
diff --git a/regcomp.c b/regcomp.c
index 0849a9716e..0853815a58 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5652,8 +5652,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
else if ((pm_flags & PMf_USE_RE_EVAL)
/* this second condition covers the non-regex literal case,
* i.e. $foo =~ '(?{})'. */
- || ( !(PL_in_eval & EVAL_RE_REPARSING) && IN_PERL_COMPILETIME
- && (PL_hints & HINT_RE_EVAL))
+ || (IN_PERL_COMPILETIME && (PL_hints & HINT_RE_EVAL))
)
runtime_code = S_has_runtime_code(aTHX_ pRExC_state, expr, pm_flags,
exp, plen);
diff --git a/regexec.c b/regexec.c
index bb6c958f7a..45bd09ede3 100644
--- a/regexec.c
+++ b/regexec.c
@@ -4878,8 +4878,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
*/
Copy(&PL_reg_state, &saved_state, 1, struct re_save_state);
- PL_in_eval &= ~EVAL_RE_REPARSING;
-
if (!caller_cv)
caller_cv = find_runcv(NULL);
diff --git a/toke.c b/toke.c
index 4581bfdc1a..e97f3fa774 100644
--- a/toke.c
+++ b/toke.c
@@ -2525,6 +2525,7 @@ S_sublex_push(pTHX)
SAVEGENERICPV(PL_lex_brackstack);
SAVEGENERICPV(PL_lex_casestack);
SAVEGENERICPV(PL_parser->lex_shared);
+ SAVEBOOL(PL_parser->lex_re_reparsing);
/* The here-doc parser needs to be able to peek into outer lexing
scopes to find the body of the here-doc. So we put PL_linestr and
@@ -2568,6 +2569,9 @@ S_sublex_push(pTHX)
else
PL_lex_inpat = NULL;
+ PL_parser->lex_re_reparsing = cBOOL(PL_in_eval & EVAL_RE_REPARSING);
+ PL_in_eval &= ~EVAL_RE_REPARSING;
+
return '(';
}
@@ -9517,9 +9521,6 @@ S_scan_pat(pTHX_ char *start, I32 type)
s = scan_str(start,!!PL_madskills,FALSE, (PL_in_eval & EVAL_RE_REPARSING),
TRUE /* look for escaped bracketed metas */ );
- /* this was only needed for the initial scan_str; set it to false
- * so that any (?{}) code blocks etc are parsed normally */
- PL_in_eval &= ~EVAL_RE_REPARSING;
if (!s) {
const char * const delimiter = skipspace(start);
Perl_croak(aTHX_