evalbytes should ignore outer utf8 declaration
authorFather Chrysostomos <sprout@cpan.org>
Fri, 25 Nov 2011 01:43:38 +0000 (17:43 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 25 Nov 2011 05:11:05 +0000 (21:11 -0800)
A slight mistake in the evalbytes.t test script caused a lot of tests
not be testing what they were supposed to be testing for.  I used
'qq(\x...)' instead of qq('\x...').  (I.e., I was trying to embed lit-
eral Unicode characters in the string, rather than pass escapes to
evalbytes.)

I had wondered at the time why it worked without my doing anything, so
I probably should have looked deeper.

op.c
t/op/evalbytes.t

diff --git a/op.c b/op.c
index 2fbf4bd..93a9678 100644 (file)
--- a/op.c
+++ b/op.c
@@ -7512,6 +7512,7 @@ Perl_ck_eval(pTHX_ OP *o)
        op_getmad(oldo,o,'O');
     }
     o->op_targ = (PADOFFSET)PL_hints;
+    if (o->op_private & OPpEVAL_BYTES) o->op_targ &= ~HINT_UTF8;
     if ((PL_hints & HINT_LOCALIZE_HH) != 0
      && !(o->op_private & OPpEVAL_COPHH) && GvHV(PL_hintgv)) {
        /* Store a copy of %^H that pp_entereval can pick up. */
index 4a60614..5a03e63 100644 (file)
@@ -19,7 +19,7 @@ use feature 'evalbytes', 'unicode_eval';
 
 is evalbytes("1+7"), 8, 'evalbytes basic sanity check';
 
-my $code = 'qq(\xff\xfe)';
+my $code = qq('\xff\xfe');
 is evalbytes($code), "\xff\xfe", 'evalbytes on extra-ASCII bytes';
 chop((my $upcode = $code) .= chr 256);
 is evalbytes($upcode), "\xff\xfe", 'evalbytes on upgraded extra-ASCII';