From fd304f1e0e121f7ff61fd2dc578b92e63ea4ccc5 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 15 Mar 2005 18:09:05 +0000 Subject: Both `pr -0' and e.g., `pr -03' would evoke `column count too large'. `pr -0' should give a better diagnostic and `pr -03' should be equivalent to `pr -3'. (parse_column_count): Change return type to void. Call error (EXIT_FAILURE, ... for an invalid string. (main): Allocate space for column_count_string using malloc. Accumulate all old-style column-count digits before converting. When the number of columns is specified via both old-style, (e.g., -3), and a long option (--columns=5), ensure that only the last one specified takes effect. Add tests for the above. --- tests/pr/Test.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/pr') diff --git a/tests/pr/Test.pm b/tests/pr/Test.pm index 8512bbf70..066212d44 100644 --- a/tests/pr/Test.pm +++ b/tests/pr/Test.pm @@ -346,6 +346,15 @@ my @tv = ( # This test would fail with textutils-2.1 and earlier. ['col-last', '-W3 -t2', "a\nb\nc\n", "a c\nb\n", 0], +# Make sure that -02 is treated just like -2. +['col-02', '-W3 -t -02', "a\nb\nc\n", "a c\nb\n", 0], +# The -2 must override preceding column-count-specifying options. +['col-2', '-W3 -t -4 --columns=1 -2', "a\nb\nc\n", "a c\nb\n", 0], +# The --columns=2 must override preceding column-count-specifying options. +['col-long', '-W3 -t -1 --columns=2', "a\nb\nc\n", "a c\nb\n", 0], +# Make sure these fail. +['col-0', '-0', '', '', 1], +['col-inval', '-'.'9'x100, '', '', 1], ); #']]); @@ -364,6 +373,7 @@ sub test_vector $flags = "$common_option_prefix$sep$flags"; push (@new_tv, [$test_name, $flags, $in, $exp, $ret]); + # For any use of -N, create an identical test with --columns=N. (my $new_flags = $flags) =~ s/(^| )-(\d+)( |$)/$1--columns=$2$3/g; $new_flags ne $flags and push (@new_tv, ["$test_name.C", $new_flags, $in, $exp, $ret]); -- cgit v1.2.3-70-g09d2