Deparse the /d flag with implicit features
authorFather Chrysostomos <sprout@cpan.org>
Sun, 25 Dec 2011 02:07:33 +0000 (18:07 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 25 Dec 2011 03:14:25 +0000 (19:14 -0800)
Before the recent feature revamp (2fc860ee1e0), loading the
unicode_strings feature would always set the feature_unicode %^H ele-
ment, even though the core did not actually use it.  Now it is some-
times not set.  So we have to check the hint bits as well.  Since
feature.pm has it hardcoded, load feature.pm to get the right bit.

The stuff with $feature_bundle_mask is redundant, but it avoids load-
ing feature.pm unnecessarily.

dist/B-Deparse/Deparse.pm
dist/B-Deparse/t/deparse.t

index 648a17c..27c6773 100644 (file)
@@ -4537,7 +4537,15 @@ sub re_flags {
     # The /d flag is indicated by 0; only show it if necessary.
     elsif ($self->{hinthash} and
             $self->{hinthash}{reflags_charset}
-           || $self->{hinthash}{feature_unicode}) {
+           || $self->{hinthash}{feature_unicode}
+       or $self->{hints} & $feature_bundle_mask
+         && ($self->{hints} & $feature_bundle_mask)
+              != $feature_bundle_mask
+         && do {
+               require feature;
+               $self->{hints} & $feature::hint_uni8bit;
+            }
+  ) {
        $flags .= 'd';
     }
     $flags;
index a7aaa31..b56978b 100644 (file)
@@ -801,6 +801,10 @@ print /a/u, s/b/c/u;
     use re "/u";
     print /a/d, s/b/c/d;
 }
+{
+    use 5.012;
+    print /a/d, s/b/c/d;
+}
 >>>>
 print /a/a, s/b/c/a;
 print /a/aa, s/b/c/aa;
@@ -816,6 +820,11 @@ print /a/u, s/b/c/u;
            $^H{'reflags_charset'} = '2'; }
     print /a/d, s/b/c/d;
 }
+{
+    no feature;
+    use feature ':5.12';
+    print /a/d, s/b/c/d;
+}
 ####
 # Test @threadsv_names under 5005threads
 foreach $' (1, 2) {