autotest: de-duplicate: use print*() in show*()

this actually adds some (minimal) transformation overhead, but it makes
the relationship clearer.
This commit is contained in:
Oswald Buddenhagen 2017-03-31 13:16:54 +02:00
parent 8aed94420f
commit b4d1a05365

View File

@ -339,17 +339,11 @@ sub showbox($)
my ($bn) = @_; my ($bn) = @_;
my ($mu, %ms) = readbox($bn); my ($mu, %ms) = readbox($bn);
print " [ $mu,\n "; my @MS = ($mu);
my $frst = 1;
for my $num (sort { $a <=> $b } keys %ms) { for my $num (sort { $a <=> $b } keys %ms) {
if ($frst) { push @MS, $num, $ms{$num}[0], $ms{$num}[1];
$frst = 0;
} else {
print ", ";
}
print "$num, $ms{$num}[0], \"$ms{$num}[1]\"";
} }
print " ],\n"; printbox($bn, @MS);
} }
# $filename # $filename
@ -382,22 +376,14 @@ sub showstate($)
close FILE; close FILE;
return; return;
} }
print " [ ".($hdr{'MaxPulledUid'} // "missing").", ". my @T = ($hdr{'MaxPulledUid'} // "missing",
($hdr{'MaxExpiredSlaveUid'} // "0").", ".($hdr{'MaxPushedUid'} // "missing").",\n "; $hdr{'MaxExpiredSlaveUid'} // "0",
my $frst = 1; $hdr{'MaxPushedUid'} // "missing");
for (@ls) { for (@ls) {
if ($frst) { /^(-?\d+) (-?\d+) (.*)$/;
$frst = 0; push @T, $1, $2, $3;
} else {
print ", ";
}
if (!/^(-?\d+) (-?\d+) (.*)$/) {
print "??, ??, \"??\"";
} else {
print "$1, $2, \"$3\"";
}
} }
print " ],\n"; printstate(@T);
} }
# $filename # $filename
@ -604,7 +590,7 @@ sub printstate(@)
} else { } else {
print ", "; print ", ";
} }
print shift(@t).", ".shift(@t).", \"".shift(@t)."\""; print((shift(@t) // "??").", ".(shift(@t) // "??").", \"".(shift(@t) // "??")."\"");
} }
print " ],\n"; print " ],\n";
} }