This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop B from crashing on y/å/ø/
authorFather Chrysostomos <sprout@cpan.org>
Thu, 4 Nov 2010 17:08:27 +0000 (10:08 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 4 Nov 2010 18:25:40 +0000 (11:25 -0700)
ext/B/B.xs
ext/B/t/b.t

index 4651e46..2c1ebbf 100644 (file)
@@ -169,11 +169,17 @@ cc_opclass(pTHX_ const OP *o)
          * Character translations (tr///) are usually a PVOP, keeping a 
          * pointer to a table of shorts used to look up translations.
          * Under utf8, however, a simple table isn't practical; instead,
-         * the OP is an SVOP, and the SV is a reference to a swash
+         * the OP is an SVOP (or, under threads, a PADOP),
+         * and the SV is a reference to a swash
          * (i.e., an RV pointing to an HV).
          */
        return (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))
+#if  defined(USE_ITHREADS) \
+  && (PERL_VERSION > 8 || (PERL_VERSION == 8 && PERL_SUBVERSION >= 9))
+               ? OPc_PADOP : OPc_PVOP;
+#else
                ? OPc_SVOP : OPc_PVOP;
+#endif
 
     case OA_LOOP:
        return OPc_LOOP;
index d53ebc7..5bfd3f1 100644 (file)
@@ -291,4 +291,8 @@ is(B::opnumber("chop"), 38, "Testing opnumber with opname (chop)");
 is(B::svref_2object(sub {})->ROOT->ppaddr, 'PL_ppaddr[OP_LEAVESUB]',
    'OP->ppaddr');
 
+# This one crashes from perl 5.8.9 to B 1.24 (perl 5.13.6):
+B::svref_2object(sub{y/\x{100}//})->ROOT->first->first->sibling->sv;
+ok 1, 'B knows that UTF trans is a padop in 5.8.9, not an svop';
+
 done_testing();