Make B/Deparse handle unicode regexes
authorDavid Mitchell <davem@iabyn.com>
Wed, 23 Oct 2013 14:12:18 +0000 (15:12 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 23 Oct 2013 14:15:32 +0000 (15:15 +0100)
[perl #120182]
the precomp B::OP method was returning a non-UTF8 string even if the
regex was utf8

ext/B/B.pm
ext/B/B.xs
lib/B/Deparse.t

index 4d0df90..7a63f62 100644 (file)
@@ -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.
index 7866aec..18857cb 100644 (file)
@@ -1143,6 +1143,8 @@ next(o)
                        }
                        else {
                            sv_setpvn(ret, RX_PRECOMP(rx), RX_PRELEN(rx));
+                            if (RX_UTF8(rx))
+                                SvUTF8_on(ret);
                        }
                    }
                }
index 5087485..bbd03da 100644 (file)
@@ -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);