From: Gurusamy Sarathy Date: Mon, 20 Mar 2000 21:03:14 +0000 (+0000) Subject: make dumpvar.pl recognize emptyness in arrays (from Matthias Urlichs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d918263624f69db4f9575643879bfa5b4453117e;p=p5sagit%2Fp5-mst-13.2.git make dumpvar.pl recognize emptyness in arrays (from Matthias Urlichs ); fix up duplicate code in Dumpvalue.pm p4raw-id: //depot/perl@5839 --- diff --git a/lib/Dumpvalue.pm b/lib/Dumpvalue.pm index 5d3a9da..617494a 100644 --- a/lib/Dumpvalue.pm +++ b/lib/Dumpvalue.pm @@ -227,9 +227,9 @@ sub unwrap { if ($self->{compactDump} && !grep(ref $_, @{$v})) { if ($#$v >= 0) { $short = $sp . "0..$#{$v} " . - join(" ", - map {$self->stringify($_)} @{$v}[0..$tArrayDepth]) - . "$shortmore"; + join(" ", + map {exists $v->[$_] ? $self->stringify $v->[$_] : "empty"} ($[..$tArrayDepth) + ) . "$shortmore"; } else { $short = $sp . "empty array"; } @@ -238,7 +238,11 @@ sub unwrap { for my $num ($[ .. $tArrayDepth) { return if $DB::signal and $self->{stopDbSignal}; print "$sp$num "; - $self->DumpElem($v->[$num], $s); + if (exists $v->[$num]) { + $self->DumpElem($v->[$num], $s); + } else { + print "empty slot\n"; + } } print "$sp empty array\n" unless @$v; print "$sp$more" if defined $more ; diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl index 4a3041a..51e9c88 100644 --- a/lib/dumpvar.pl +++ b/lib/dumpvar.pl @@ -195,8 +195,8 @@ sub unwrap { if ($#$v >= 0) { $short = $sp . "0..$#{$v} " . join(" ", - map {stringify $_} @{$v}[0..$tArrayDepth]) - . "$shortmore"; + map {exists $v->[$_] ? stringify $v->[$_] : "empty"} ($[..$tArrayDepth) + ) . "$shortmore"; } else { $short = $sp . "empty array"; } @@ -209,7 +209,11 @@ sub unwrap { for $num ($[ .. $tArrayDepth) { return if $DB::signal; print "$sp$num "; - DumpElem $v->[$num], $s; + if (exists $v->[$num]) { + DumpElem $v->[$num], $s; + } else { + print "empty slot\n"; + } } print "$sp empty array\n" unless @$v; print "$sp$more" if defined $more ;