aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-08-29 23:52:07 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2023-08-29 23:57:40 -0700
commitcbb6dfec557e7c8ac2dd728e4a943beb6ccfd53c (patch)
tree39b8174e8997a53a62760c9e2eeb060e513303a7 /tests
parentmaint: post-release administrivia (diff)
downloadcoreutils-cbb6dfec557e7c8ac2dd728e4a943beb6ccfd53c.tar.gz
coreutils-cbb6dfec557e7c8ac2dd728e4a943beb6ccfd53c.zip
maint: remove need for mbsalign
This simplifies memory allocation a bit, and removes an arbitrary limitation from numfmt, which formerly limited cell output to 127 bytes. * bootstrap.conf (gnulib_modules): Remove mbsalign, strncat. Add strnlen (the code already used strnlen directly, and we were saved only because Gnulib used the module indirectly) * gl/lib/mbsalign.c, gl/lib/mbsalign.h, gl/modules/mbsalign: * gl/modules/mbsalign-tests, gl/tests/test-mbsalign.c: Remove. * src/df.c, src/ls.c: Do not include mbsalign.h. (MBSWIDTH_FLAGS): New constant, now used for all mbswidth calls. All callers changed to check for -1 return. * src/df.c (struct field_data_t): ‘width’ is now int not size_t, since mbswidth can’t do widths greater than INT_MAX anyway. Replace ‘align’ with ‘align_right’. All uses changed. (print_table): Redo to avoid the need for ambsalign. (get_header, get_dev): mbswidth returns int, not size_t. * src/ls.c (MAX_MON_WIDTH): Remove; no longer used. (abmon_init): Use strnlen to cheaply discard too-long month names. Align by hand instead of using mbsalign. * src/numfmt.c: Include stdckdint.h, mbswidth.h. Do not include mbsalign.h. (padding_buffer_size): Now idx_t. All uses changed. (padding_width): Now intmax_t, since it’s no longer an object size. Its sign now records alignment. All uses changed. (zero_padding_width): Now int, since it’s given to sprintf. All uses changed. (padding_alignment): Remove; it’s now taken from padding_width’s sign. (double_to_human): Return string length. BUF_SIZE arg is now idx_t. Include suffix in output. All callers changed. Simplify by not calling strncat or stpcpy. Calculate fmt size bound more carefully. (setup_padding_buffer): Remove. All uses removed. (parse_format_string): Use intmax_t, not long, for pad. On overflow, set widths to large values that cause later code to do the right thing, rather than separately checking for overflow here. (prepare_padded_number): Return bool, not int 0/1. New arg PADDING. All uses changed. Do not limit padded output to 127 bytes; instead, use xpalloc to expand the output buffer. (print_padded_number): New arg PADDING. All uses changed. (process_suffixed_number): Simplify. (main): Take extremum if xstrtoimax overflows, as this does the right thing. * tests/misc/numfmt.pl: New test suf-20 to test for truncation bug. Remove tests pad-3.2, fmt-err-7, as they’re no longer invalid but are quite expensive.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/numfmt.pl10
1 files changed, 3 insertions, 7 deletions
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl
index 86fb78f1e..86698dde5 100755
--- a/tests/misc/numfmt.pl
+++ b/tests/misc/numfmt.pl
@@ -159,6 +159,9 @@ my @Tests =
# space(s) between number and suffix. Note only field 1 is used
# by default so specify the NUL delimiter to consider the whole "line".
['suf-19', "-d '' --from=si '4.0 K'", {OUT => "4000"}],
+ ['suf-20',
+ '--suffix=Fooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy 0',
+ {OUT => "0Fooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy"}],
## GROUPING
@@ -178,9 +181,6 @@ my @Tests =
['pad-3.1', '--padding=0 5',
{ERR => "$prog: invalid padding value '0'\n"},
{EXIT => '1'}],
- ['pad-3.2', "--padding=$limits->{LONG_MIN} 0",
- {ERR => "$prog: invalid padding value '$limits->{LONG_MIN}'\n"},
- {EXIT => '1'}],
['pad-4', '--padding=10 --to=si 50000', {OUT=>' 50K'}],
['pad-5', '--padding=-10 --to=si 50000', {OUT=>'50K '}],
@@ -675,10 +675,6 @@ my @Tests =
['fmt-err-6', '--format "%f %f"',
{ERR=>"$prog: format '%f %f' has too many % directives\n"},
{EXIT=>1}],
- ['fmt-err-7', '--format "%'.$limits->{LONG_OFLOW}.'f"',
- {ERR=>"$prog: invalid format '%$limits->{LONG_OFLOW}f'".
- " (width overflow)\n"},
- {EXIT=>1}],
['fmt-err-9', '--format "%f" --grouping',
{ERR=>"$prog: --grouping cannot be combined with --format\n"},
{EXIT=>1}],