From fea7fb25afff9547ae810fad732c75518bb156a3 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 23 Oct 2013 15:12:18 +0100 Subject: [PATCH] Make B/Deparse handle unicode regexes [perl #120182] the precomp B::OP method was returning a non-UTF8 string even if the regex was utf8 --- ext/B/B.pm | 2 +- ext/B/B.xs | 2 ++ lib/B/Deparse.t | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/B/B.pm b/ext/B/B.pm index 4d0df90..7a63f62 100644 --- a/ext/B/B.pm +++ b/ext/B/B.pm @@ -15,7 +15,7 @@ require Exporter; # walkoptree comes from B.xs BEGIN { - $B::VERSION = '1.46'; + $B::VERSION = '1.47'; @B::EXPORT_OK = (); # Our BOOT code needs $VERSION set, and will append to @EXPORT_OK. diff --git a/ext/B/B.xs b/ext/B/B.xs index 7866aec..18857cb 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1143,6 +1143,8 @@ next(o) } else { sv_setpvn(ret, RX_PRECOMP(rx), RX_PRELEN(rx)); + if (RX_UTF8(rx)) + SvUTF8_on(ret); } } } diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index 5087485..bbd03da 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -13,7 +13,7 @@ use warnings; use strict; use Test::More; -my $tests = 19; # not counting those in the __DATA__ section +my $tests = 20; # not counting those in the __DATA__ section use B::Deparse; my $deparse = B::Deparse->new(); @@ -270,6 +270,13 @@ x(); z() . EOCODH +# literal big chars under 'use utf8' +is($deparse->coderef2text(sub{ use utf8; /€/; }), +'{ + /\x{20ac}/; +}', +"qr/euro/"); + done_testing($tests); -- 2.7.4