1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 03:12:48 +02:00

numfmt: support multi-byte --delimiter

* bootstrap.conf: Depend on mbsstr() to robustly search for a
multi-byte delimiter character (string) within a multi-byte string.
* src/numfmt.c (main): Accept a valid multi-byte delimiter character.
(next_field): Adjust delimiter search from single byte
to multi-byte aware.  Use mbsstr to find the first match.
* tests/misc/numfmt.pl: Add test case.
* NEWS: Mention the improvement.
This commit is contained in:
Pádraig Brady
2025-10-18 17:44:49 +01:00
parent e5d7764386
commit 09af58f4f9
4 changed files with 34 additions and 23 deletions

View File

@@ -283,6 +283,9 @@ my @Tests =
['delim-4', '--delimiter=: --from=auto 40M:60M', {OUT=>'40000000:60M'}],
['delim-5', '-d: --field=2 --from=auto :40M:60M', {OUT=>':40000000:60M'}],
['delim-6', '-d: --field 3 --from=auto 40M:60M', {OUT=>"40M:60M"}],
# Ensure we don't hit https://sourceware.org/PR29511
['delim-7', "-d '\xc2' --field=2 --invalid=ignore '1\xc2\xb72K'",
{OUT => "1\xc2\xb72K"}],
['delim-err-1', '-d,, --to=si 1', {EXIT=>1},
{ERR => "$prog: the delimiter must be a single character\n"}],
@@ -1187,6 +1190,10 @@ my @Locale_Tests =
['lcl-suf-11', "--field=2 '1 \xe2\x80\x832'",
{OUT => "1 2"}, {ENV=>"LC_ALL=$locale"}],
# Support multi-byte delimiter
['lcl-delim-1', "-d '\xc2\xb7' --field=2 --from=auto '1\xc2\xb72K'",
{OUT => "1\xc2\xb72000"}, {ENV=>"LC_ALL=$locale"}],
);
if ($locale ne 'C')
{