From 512ba29bc79201987654d262fe5b47f177b26c77 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 4 Nov 2010 10:08:27 -0700 Subject: [PATCH] =?utf8?q?Stop=20B=20from=20crashing=20on=20y/=C3=A5/?= =?utf8?q?=C3=B8/?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ext/B/B.xs | 8 +++++++- ext/B/t/b.t | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/B/B.xs b/ext/B/B.xs index 4651e46..2c1ebbf 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -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; diff --git a/ext/B/t/b.t b/ext/B/t/b.t index d53ebc7..5bfd3f1 100644 --- a/ext/B/t/b.t +++ b/ext/B/t/b.t @@ -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(); -- 2.7.4