From e13188e7ef7bbd609c1586332a335b4194b881aa Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 25 Sep 2008 20:01:24 +0200 Subject: seq -0.1 0.1 2: print final number when locale's decimal point is "," MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/seq.c (print_numbers): Use strtold, not c_strtold to convert from just-formatted-using-asprintf string back to double, since asprintf may have used something other than "." as the decimal point. Reported by lsof@nodata.co.uk as . Thanks to Ondřej Vašík for discovering that the bug was locale-related. $ LC_ALL=cs_CZ.UTF-8 seq -0.1 0.1 2|grep 2.0 [Exit 1] $ seq -0.1 0.1 2|grep 2.0 2.0 * tests/check.mk (TESTS_ENVIRONMENT): Add LOCALE_FR_UTF8, for... * tests/misc/seq [locale-dec-pt]: New test for the above. * NEWS (bug fix): Mention it. --- src/seq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/seq.c b/src/seq.c index 55518dfab..b5f0651d1 100644 --- a/src/seq.c +++ b/src/seq.c @@ -306,7 +306,7 @@ print_numbers (char const *fmt, struct layout layout, xalloc_die (); x_str[x_strlen - layout.suffix_len] = '\0'; - if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold) + if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, strtold) && abs_rel_diff (x_val, last) < DBL_EPSILON) { char *x0_str = NULL; -- cgit v1.2.3-54-g00ecf