Fix [perl #36102] Data::Dumper Doesn't Stringify Numeric Labels
Rafael Garcia-Suarez [Tue, 21 Jun 2005 09:40:46 +0000 (09:40 +0000)]
p4raw-id: //depot/perl@24917

ext/Data/Dumper/Dumper.pm
ext/Data/Dumper/Dumper.xs
ext/Data/Dumper/t/dumper.t

index 3d297c3..ef4da8a 100644 (file)
@@ -9,7 +9,7 @@
 
 package Data::Dumper;
 
-$VERSION = '2.121_06';
+$VERSION = '2.121_07';
 
 #$| = 1;
 
index 9fec64d..3db74ae 100644 (file)
@@ -1041,12 +1041,15 @@ Data_Dumper_Dumpxs(href, ...)
                        val = *svp;
                    else
                        val = &PL_sv_undef;
-                   if ((svp = av_fetch(namesav, i, TRUE)))
+                   if ((svp = av_fetch(namesav, i, TRUE))) {
                        sv_setsv(name, *svp);
+                       if (SvOK(*svp) && !SvPOK(*svp))
+                           (void)SvPV_nolen_const(name);
+                   }
                    else
                        (void)SvOK_off(name);
                
-                   if (SvOK(name)) {
+                   if (SvPOK(name)) {
                        if ((SvPVX_const(name))[0] == '*') {
                            if (SvROK(val)) {
                                switch (SvTYPE(SvRV(val))) {
index 35b97b2..8ab5f1d 100755 (executable)
@@ -115,11 +115,11 @@ $WANT = <<'EOT';
 #       $a->[1]{'c'}
 #     ];
 #$b = $a->[1];
-#$c = $a->[1]{'c'};
+#$6 = $a->[1]{'c'};
 EOT
 
-TEST q(Data::Dumper->Dump([$a,$b,$c], [qw(a b c)]));
-TEST q(Data::Dumper->Dumpxs([$a,$b,$c], [qw(a b c)])) if $XS;
+TEST q(Data::Dumper->Dump([$a,$b,$c], [qw(a b), 6]));
+TEST q(Data::Dumper->Dumpxs([$a,$b,$c], [qw(a b), 6])) if $XS;
 
 
 ############# 7