diff options
| author | Pádraig Brady <P@draigBrady.com> | 2025-10-17 19:14:21 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2025-10-18 18:37:10 +0100 |
| commit | 770078e315232b49c0e113152a469df4df1e5f4d (patch) | |
| tree | 0ffe185e150fa6c535be468d614b5c6448b9c44b /tests | |
| parent | numfmt: add --unit-separator (diff) | |
| download | coreutils-770078e315232b49c0e113152a469df4df1e5f4d.tar.gz coreutils-770078e315232b49c0e113152a469df4df1e5f4d.zip | |
numfmt: fix issues with multi-byte blanks
* src/numfmt.c (process_line): Restore byte overwritten with NUL,
as it may be part of a multi-byte blank.
(process_suffixed_number): Skip multi-byte blanks,
and correctly determine width with mbswidth().
(parse_format_string): Use c_isblank() to explicitly
indicate that's all the format spec supports.
* tests/misc/numfmt.pl: Add test cases.
* NEWS: Mention the bug fix.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/misc/numfmt.pl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl index ff22c7303..2f03efd1c 100755 --- a/tests/misc/numfmt.pl +++ b/tests/misc/numfmt.pl @@ -1172,6 +1172,20 @@ my @Locale_Tests = {ENV=>"LC_ALL=$locale"}], ['lcl-suf-6', "--from=auto '2\xe2\x81\xa0Ki'", {OUT => "2048"}, {ENV=>"LC_ALL=$locale"}], + # multi-byte blank char (em space, \u2003) + # Ensure trailing multi-byte blanks skipped + ['lcl-suf-7', "'2\xe2\x80\x83 '", {OUT => "2 "}, + {ENV=>"LC_ALL=$locale"}], + ['lcl-suf-8', "-d '' --from=auto '2Ki\xe2\x80\x83 '", {OUT => "2048"}, + {ENV=>"LC_ALL=$locale"}], + # Ensure multi-byte blank field separators not corrupted + ['lcl-suf-9', "--field=1 '1\xe2\x80\x832'", {OUT => "1 2"}, + {ENV=>"LC_ALL=$locale"}], + ['lcl-suf-10', "--field=2 '1\xe2\x80\x832'", {OUT => "1 2"}, + {ENV=>"LC_ALL=$locale"}], + # Ensure multi-byte blank field separators width determined correctly + ['lcl-suf-11', "--field=2 '1 \xe2\x80\x832'", + {OUT => "1 2"}, {ENV=>"LC_ALL=$locale"}], ); if ($locale ne 'C') |
