In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/d34e9bd940817db5ea805b524c18753a4f24a180?hp=5dec12c4fe365d1f431b0a1b786bfae24693e847>

- Log -----------------------------------------------------------------
commit d34e9bd940817db5ea805b524c18753a4f24a180
Author: Michael G. Schwern <[email protected]>
Date:   Thu Apr 15 21:29:43 2010 +0200

    Fix Data::Dumper's Fix Terse(1) + Indent(2)
    
    RT #73604: When $Data::Dumper::Terse is true, the indentation is thrown
    off. It appears to be acting as if the $VAR1 = is still there.
-----------------------------------------------------------------------

Summary of changes:
 dist/Data-Dumper/Dumper.pm |    2 +-
 dist/Data-Dumper/Dumper.xs |    4 ++--
 dist/Data-Dumper/t/terse.t |   22 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 dist/Data-Dumper/t/terse.t

diff --git a/dist/Data-Dumper/Dumper.pm b/dist/Data-Dumper/Dumper.pm
index 0eb8bf7..91b335b 100644
--- a/dist/Data-Dumper/Dumper.pm
+++ b/dist/Data-Dumper/Dumper.pm
@@ -234,7 +234,7 @@ sub Dumpperl {
     my $valstr;
     {
       local($s->{apad}) = $s->{apad};
-      $s->{apad} .= ' ' x (length($name) + 3) if $s->{indent} >= 2;
+      $s->{apad} .= ' ' x (length($name) + 3) if $s->{indent} >= 2 and 
!$s->{terse};
       $valstr = $s->_dump($val, $name);
     }
 
diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs
index e3867a1..f2c1821 100644
--- a/dist/Data-Dumper/Dumper.xs
+++ b/dist/Data-Dumper/Dumper.xs
@@ -1179,7 +1179,7 @@ Data_Dumper_Dumpxs(href, ...)
                        sv_catpvn(name, tmpbuf, nchars);
                    }
                
-                   if (indent >= 2) {
+                   if (indent >= 2 && !terse) {
                        SV * const tmpsv = sv_x(aTHX_ NULL, " ", 1, 
SvCUR(name)+3);
                        newapad = newSVsv(apad);
                        sv_catsv(newapad, tmpsv);
@@ -1193,7 +1193,7 @@ Data_Dumper_Dumpxs(href, ...)
                            freezer, toaster, purity, deepcopy, quotekeys,
                            bless, maxdepth, sortkeys);
                
-                   if (indent >= 2)
+                   if (indent >= 2 && !terse)
                        SvREFCNT_dec(newapad);
 
                    postlen = av_len(postav);
diff --git a/dist/Data-Dumper/t/terse.t b/dist/Data-Dumper/t/terse.t
new file mode 100644
index 0000000..8d3ad48
--- /dev/null
+++ b/dist/Data-Dumper/t/terse.t
@@ -0,0 +1,22 @@
+#!perl
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Data::Dumper;
+
+my $hash = { foo => 42 };
+
+for my $useperl (0..1) {
+    my $dumper = Data::Dumper->new([$hash]);
+    $dumper->Terse(1);
+    $dumper->Indent(2);
+    $dumper->Useperl($useperl);
+
+    is $dumper->Dump, <<'WANT', "Terse(1), Indent(2), Useperl($useperl)";
+{
+  'foo' => 42
+}
+WANT
+}

--
Perl5 Master Repository

Reply via email to