mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
test-wrap-argv: split out rewrap_arg
Split out the code wrapping the single argument.
This commit is contained in:
parent
a615a2fa58
commit
5e6185eee6
@ -104,27 +104,8 @@ sub rewrap_line {
|
||||
print join(" \\\n", @env, $cmd), " \\\n";
|
||||
# We might have to split line argument values...
|
||||
for (my $i = 0; $i <= $#args; $i++) {
|
||||
my $arg = $args[$i];
|
||||
while (length($arg) > 80) {
|
||||
my $split = rindex $arg, ",", 80;
|
||||
if ($split == -1) {
|
||||
$split = rindex $arg, ":", 80;
|
||||
}
|
||||
if ($split == -1) {
|
||||
$split = rindex $arg, " ", 80;
|
||||
}
|
||||
if ($split == -1) {
|
||||
warn "cannot find nice place to split '$arg' below 80 chars\n";
|
||||
$split = 79;
|
||||
}
|
||||
$split++;
|
||||
&rewrap_arg($args[$i]);
|
||||
|
||||
my $head = substr $arg, 0, $split;
|
||||
$arg = substr $arg, $split;
|
||||
|
||||
print $head, "\\\n";
|
||||
}
|
||||
print $arg;
|
||||
if ($i != $#args) {
|
||||
print " \\\n";
|
||||
} else {
|
||||
@ -132,3 +113,28 @@ sub rewrap_line {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub rewrap_arg {
|
||||
my $arg = shift;
|
||||
|
||||
while (length($arg) > 80) {
|
||||
my $split = rindex $arg, ",", 80;
|
||||
if ($split == -1) {
|
||||
$split = rindex $arg, ":", 80;
|
||||
}
|
||||
if ($split == -1) {
|
||||
$split = rindex $arg, " ", 80;
|
||||
}
|
||||
if ($split == -1) {
|
||||
warn "cannot find nice place to split '$arg' below 80 chars\n";
|
||||
$split = 79;
|
||||
}
|
||||
$split++;
|
||||
|
||||
my $head = substr $arg, 0, $split;
|
||||
$arg = substr $arg, $split;
|
||||
|
||||
print $head, "\\\n";
|
||||
}
|
||||
print $arg;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user