test-wrap-argv: split out rewrap_line

Shorten the rewrap subroutine by splitting out the code
dealing with a single line.

Also remove $file from the warning.
This commit is contained in:
Ján Tomko 2016-05-30 17:20:23 +02:00
parent 8ebf780e08
commit a615a2fa58

View File

@ -59,6 +59,13 @@ sub rewrap {
# Now each @lines represents a single command, we
# can process them
foreach my $line (@lines) {
&rewrap_line ($line);
}
}
sub rewrap_line {
my $line = shift;
my @bits = split / /, join('', $line);
# @bits contains env vars, then the command line
@ -107,7 +114,7 @@ sub rewrap {
$split = rindex $arg, " ", 80;
}
if ($split == -1) {
warn "$file: cannot find nice place to split '$arg' below 80 chars\n";
warn "cannot find nice place to split '$arg' below 80 chars\n";
$split = 79;
}
$split++;
@ -124,5 +131,4 @@ sub rewrap {
print "\n";
}
}
}
}