** Improvements
- numfmt now parses numbers with a non-breaking space character before a unit.
+ numfmt now parses numbers with a non-breaking space character before a unit,
+ and numbers containing grouping characters from the current locale.
wc -l now operates 10% faster on hosts that support AVX512 instructions.
/* will be set according to the current locale. */
static char const *decimal_point;
static int decimal_point_length;
+static char const *thousands_sep;
+static int thousands_sep_length;
/* debugging for developers. Enables devmsg(). */
static bool dev_debug = false;
val += digit;
++(*endptr);
+
+ if (thousands_sep_length > 0
+ && STREQ_LEN (*endptr, thousands_sep, thousands_sep_length)
+ && c_isdigit ((*endptr)[thousands_sep_length]))
+ (*endptr) += thousands_sep_length;
}
if (! found_digit
&& ! STREQ_LEN (*endptr, decimal_point, decimal_point_length))
decimal_point = ".";
decimal_point_length = strlen (decimal_point);
+ thousands_sep = nl_langinfo (THOUSEP);
+ if (thousands_sep == nullptr)
+ thousands_sep = "";
+ thousands_sep_length = strlen (thousands_sep);
+
atexit (close_stdout);
while (true)
{
if (scale_to != scale_none)
error (EXIT_FAILURE, 0, _("grouping cannot be combined with --to"));
- if (debug && (strlen (nl_langinfo (THOUSEP)) == 0))
+ if (debug && thousands_sep_length == 0)
error (0, 0, _("grouping has no effect in this locale"));
}
{OUT=>"7${lg}000${lg}000"},
{ENV=>"LC_ALL=$locale"}],
- # Input with locale'd decimal-point
- ['lcl-stdtod-1', '--from=si 12,2K', {OUT=>"12200"},
+ # Input with locale's grouping
+ ['lcl-strtod-1', '--from=si 1${lg}234K', {OUT=>"1234000"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Input with locale's grouping. Note position not validated.
+ ['lcl-strtod-2', '--from=si 12${lg}34K', {OUT=>"1234000"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Input with locale's decimal-point
+ ['lcl-strtod-3', '--from=si 12,2K', {OUT=>"12200"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Input with locale's grouping and decimal-point
+ ['lcl-strtod-4', '--from=si 1${lg}23,4K', {OUT=>"123400"},
{ENV=>"LC_ALL=$locale"}],
['lcl-dbl-to-human-1', '--to=si 1100', {OUT=>"1,1k"},