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:
@@ -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')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user