diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-02-25 12:48:22 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-02-25 12:48:22 +0000 |
commit | c427f4d2d4575fbc8a5190932fe321136c7597b3 (patch) | |
tree | ba8cce560c51bedf1307426fbc8a73ea64a491f6 /op.c | |
parent | 553e7bb0c885d7b666ab73f45e41f7e6dab46330 (diff) | |
download | perl-c427f4d2d4575fbc8a5190932fe321136c7597b3.tar.gz |
Ensure that constant folding runs with IN_PERL_RUNTIME true, by copying
the current compiling cop to a different address. This ensures that
lexical hints are correctly honoured, and allows us to fold sprintf.
p4raw-id: //depot/perl@33369
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -2428,6 +2428,7 @@ Perl_fold_constants(pTHX_ register OP *o) OP *old_next; SV * const oldwarnhook = PL_warnhook; SV * const olddiehook = PL_diehook; + COP not_compiling; dJMPENV; PERL_ARGS_ASSERT_FOLD_CONSTANTS; @@ -2492,6 +2493,13 @@ Perl_fold_constants(pTHX_ register OP *o) oldscope = PL_scopestack_ix; create_eval_scope(G_FAKINGEVAL); + /* Verify that we don't need to save it: */ + assert(PL_curcop == &PL_compiling); + StructCopy(&PL_compiling, ¬_compiling, COP); + PL_curcop = ¬_compiling; + /* The above ensures that we run with all the correct hints of the + currently compiling COP, but that IN_PERL_RUNTIME is not true. */ + assert(IN_PERL_RUNTIME); PL_warnhook = PERL_WARNHOOK_FATAL; PL_diehook = NULL; JMPENV_PUSH(ret); @@ -2525,6 +2533,7 @@ Perl_fold_constants(pTHX_ register OP *o) JMPENV_POP; PL_warnhook = oldwarnhook; PL_diehook = olddiehook; + PL_curcop = &PL_compiling; if (PL_scopestack_ix > oldscope) delete_eval_scope(); |