Make DD dump *{''} correctly under 5.6
authorFather Chrysostomos <sprout@cpan.org>
Mon, 26 Dec 2011 00:42:54 +0000 (16:42 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 26 Dec 2011 00:43:50 +0000 (16:43 -0800)
5.6 is strangely buggy, in that *{""} stringifies as "*main::\0".  And
then there are some other strange eval bugs that the tests have to
work around.

dist/Data-Dumper/Dumper.pm
dist/Data-Dumper/Dumper.xs
dist/Data-Dumper/t/bugs.t

index 8018bae..b4c6f7b 100644 (file)
@@ -504,7 +504,12 @@ sub _dump {
        $sname = $name;
       }
       else {
-       $sname = $s->_dump($name eq 'main::' ? '' : $name, "");
+       $sname = $s->_dump(
+         $name eq 'main::' || $] < 5.007 && $name eq "main::\0"
+           ? ''
+           : $name,
+         "",
+       );
        $sname = '{' . $sname . '}';
       }
       if ($s->{purity}) {
index 30a9b40..2ad53a1 100644 (file)
@@ -918,7 +918,12 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
            if(i) ++c, --i;                     /* just get the name */
            if (i >= 6 && strncmp(c, "main::", 6) == 0) {
                c += 4;
-               if (i == 6) i = 0; else i -= 4;
+#if PERL_VERSION < 7
+               if (i == 6 || (i == 7 && c[6] == '\0'))
+#else
+               if (i == 6)
+#endif
+                   i = 0; else i -= 4;
            }
            if (needs_quote(c,i)) {
 #ifdef GvNAMEUTF8
index 0533765..e8d2126 100644 (file)
@@ -109,8 +109,13 @@ SKIP: {
     no strict 'refs';
     is eval(Dumper \*{"foo::b\0ar"}), \*{"foo::b\0ar"},
       'GVs with nulls';
-    is eval Dumper(\*{chr 256}), \*{chr 256},
+    # There is a strange 5.6 bug that causes the eval to fail a supposed
+    # strict vars test (involving $VAR1).  Mentioning the glob beforehand
+    # somehow makes it go away.
+    () = \*{chr 256};
+    is eval Dumper(\*{chr 256})||die ($@), \*{chr 256},
       'GVs with UTF8 names (or not, depending on perl version)';
+    () = \*{"\0".chr 256}; # same bug
     is eval Dumper(\*{"\0".chr 256}), \*{"\0".chr 256},
       'GVs with UTF8 and nulls';
   };