|
From: | Pádraig Brady |
Subject: | bug#51011: [PATCH] sort: --debug: add warnings about radix and grouping chars |
Date: | Sun, 31 Oct 2021 22:01:12 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 |
On 11/10/2021 02:54, Pádraig Brady wrote:
On 11/10/2021 00:34, Paul Eggert wrote:The warnings look good, except that this one:$ printf '1.0\n0.9\n' | sort -s -k1,1g --debug sort: numbers use ‘.’ as a decimal point in this locale 0.9 ___ 1.0 ___seems overkill if we're in the C locale. Also, shouldn't similar diagnostics be generated if the field separator is '-', or '+', or a digit in the current locale?Yes this is more informational than a warning. As Bernhard mentioned it may be useful to tag --debug messages as informational or warnings. In this case it would be info: but would change to warn: if (tab == decimal_point). The reason for the info message is that it may not be obvious to users that numeric comparison depends on locale just like text, and we already provide the informational text comparison message indicating the current locale. We would only show this info: message if doing numeric sorting.
Addressing your '+' and '-' comment. Yes they may also be used as field separators and so are worth explicitly warning about. Re warning about using digits in --field-separator, that would be extremely edge case, and anyway the --debug key marking should make it apparent the extent of the numbers being compared. The same argument can be made for other characters possible in numbers like; 1E+4 nan, Infinity, 0xabcde.fp-3, etc. As a related issue, I also thought it appropriate to warn when we're ignoring multi-byte grouping chars in the locale. The new warnings in this update are: $ LC_ALL=fr_FR.utf8 sort -n --debug /dev/null sort: the multi-byte number group separator in this locale is not supported $ sort --debug -t- -k1n /dev/null sort: key 1 is numeric and spans multiple fields sort: field separator ‘-’ is treated as a minus sign in numbers $ sort --debug -t+ -k1g /dev/null sort: key 1 is numeric and spans multiple fields sort: field separator ‘+’ is treated as a plus sign in numbers I'll apply this later. cheers, Pádraig
sort--debug-number-span.patch
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |