summaryrefslogtreecommitdiff
path: root/tests/ls
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-12-21 22:16:03 +0000
committerJim Meyering <jim@meyering.net>1996-12-21 22:16:03 +0000
commita611c6cbf61a21148875a18bd52784a972fd33bd (patch)
tree7d24daa0a5b49fa2064f391e0620e68d7fb8c4c7 /tests/ls
parent68c33eea038246bb2846fc243d5cfed0ab60fdb6 (diff)
downloadcoreutils-a611c6cbf61a21148875a18bd52784a972fd33bd.tar.xz
(wrap): New function.
Use it.
Diffstat (limited to 'tests/ls')
-rw-r--r--tests/ls/mk-script.pl30
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/ls/mk-script.pl b/tests/ls/mk-script.pl
index 5f9c9af6a..a7b396b17 100644
--- a/tests/ls/mk-script.pl
+++ b/tests/ls/mk-script.pl
@@ -109,6 +109,28 @@ sub spec_to_list ($$$)
return \%h;
}
+sub wrap
+{
+ my ($preferred_line_len, @tok) = @_;
+ assert ($preferred_line_len > 0);
+ my @lines;
+ my $line = '';
+ my $word;
+ foreach $word (@tok)
+ {
+ if ($line && length ($line) + 1 + length ($word) > $preferred_line_len)
+ {
+ push (@lines, $line);
+ $line = $word;
+ next;
+ }
+ my $sp = ($line ? ' ' : '');
+ $line .= "$sp$word";
+ }
+ push (@lines, $line);
+ return @lines;
+}
+
# ~~~~~~~ main ~~~~~~~~
{
$| = 1;
@@ -120,7 +142,6 @@ sub spec_to_list ($$$)
if ($xx eq '--list')
{
validate ();
- # FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Output three lists of files:
# EXPLICIT -- file names specified in Test.pm
# MAINT_GEN -- maintainer-generated files
@@ -145,9 +166,10 @@ sub spec_to_list ($$$)
push (@maint, @{$e->{MAINT_GEN}});
}
- print 'explicit: ', join (' ', @exp), "\n";
- print 'maint-gen: ', join (' ', @maint), "\n";
- print 'run-gen: ', join (' ', @run), "\n";
+ my $len = 78;
+ print join (" \\\n", wrap ($len, 'explicit =', @exp)), "\n";
+ print join (" \\\n", wrap ($len, 'maint-gen =', @maint)), "\n";
+ print join (" \\\n", wrap ($len, 'run-gen =', @run)), "\n";
exit 0;
}