From: Jim Meyering Date: Sat, 21 Dec 1996 22:16:03 +0000 (+0000) Subject: (wrap): New function. X-Git-Tag: FILEUTILS-3_14a~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a611c6cbf61a21148875a18bd52784a972fd33bd;p=platform%2Fupstream%2Fcoreutils.git (wrap): New function. Use it. --- diff --git a/tests/cut/mk-script.pl b/tests/cut/mk-script.pl index 5f9c9af..a7b396b 100644 --- a/tests/cut/mk-script.pl +++ b/tests/cut/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; } diff --git a/tests/head/mk-script.pl b/tests/head/mk-script.pl index 5f9c9af..a7b396b 100644 --- a/tests/head/mk-script.pl +++ b/tests/head/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; } diff --git a/tests/join/mk-script.pl b/tests/join/mk-script.pl index 5f9c9af..a7b396b 100644 --- a/tests/join/mk-script.pl +++ b/tests/join/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; } diff --git a/tests/ls/mk-script.pl b/tests/ls/mk-script.pl index 5f9c9af..a7b396b 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; }