mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-07-25 18:19:00 +02:00
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.
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user