diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-10-30 14:33:06 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-06 01:13:48 -0700 |
commit | 7d7892821ccfd0b84576fc06764ec467e8ca7678 (patch) | |
tree | 8a14db3fc316b83374c8d171175537ad6e6c306e /pp_ctl.c | |
parent | 17e00314cad49c11dda5b621497c7010537844ea (diff) | |
download | perl-7d7892821ccfd0b84576fc06764ec467e8ca7678.tar.gz |
Add evalbytes function
This function evaluates its argument as a byte string, regardless of
the internal encoding. It croaks if the string contains characters
outside the byte range. Hence evalbytes(" use utf8; '\xc4\x80' ")
will return "\x{100}", even if the original string had the UTF8 flag
on, and evalbytes(" '\xc4\x80' ") will return "\xc4\x80".
This has the side effect of fixing the deparsing of CORE::break under
‘use feature’ when there is an override.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -4131,6 +4131,11 @@ PP(pp_entereval) if (PL_op->op_private & OPpEVAL_HAS_HH) { saved_hh = MUTABLE_HV(SvREFCNT_inc(POPs)); } + else if (PL_op->op_private & OPpEVAL_COPHH + && PL_curcop->cop_hints & HINT_LOCALIZE_HH) { + saved_hh = cop_hints_2hv(PL_curcop, 0); + hv_magic(saved_hh, NULL, PERL_MAGIC_hints); + } sv = POPs; if (!SvPOK(sv)) { /* make sure we've got a plain PV (no overload etc) before testing @@ -4140,6 +4145,15 @@ PP(pp_entereval) const char * const p = SvPV_const(sv, len); sv = newSVpvn_flags(p, len, SVs_TEMP | SvUTF8(sv)); + + if (PL_op->op_private & OPpEVAL_BYTES && SvUTF8(sv)) + SvPVbyte_force(sv, len); + } + else if (PL_op->op_private & OPpEVAL_BYTES && SvUTF8(sv)) { + /* Don’t modify someone else’s scalar */ + STRLEN len; + sv = newSVsv(sv); + SvPVbyte_force(sv,len); } TAINT_IF(SvTAINTED(sv)); @@ -4173,7 +4187,8 @@ PP(pp_entereval) ensues, we always turn GvMULTI_on for any globals that were introduced within evals. See force_ident(). GSAR 96-10-12 */ SAVEHINTS(); - PL_hints = PL_op->op_targ; + PL_hints = PL_op->op_private & OPpEVAL_COPHH + ? PL_curcop->cop_hints : PL_op->op_targ; if (saved_hh) { /* SAVEHINTS created a new HV in PL_hintgv, which we need to GC */ SvREFCNT_dec(GvHV(PL_hintgv)); |