From: Paul Eggert Date: Thu, 2 Dec 2004 06:55:08 +0000 (+0000) Subject: (decimal_point): Treat like sort. Now char. X-Git-Tag: v5.3.0~237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d153646bbc71dc81fb88a5b671b4d98aa37d1423;p=thirdparty%2Fcoreutils.git (decimal_point): Treat like sort. Now char. All uses changed. --- diff --git a/src/seq.c b/src/seq.c index 76235ea03a..1118fe7627 100644 --- a/src/seq.c +++ b/src/seq.c @@ -49,9 +49,8 @@ static char *separator; /* FIXME: make this an option. */ static char *terminator = "\n"; -/* The representation of the decimal point in the current locale. - Always "." if the localeconv function is not supported. */ -static char *decimal_point = "."; +/* The representation of the decimal point in the current locale. */ +static char decimal_point; /* The starting number. */ static double first; @@ -251,9 +250,7 @@ get_width_format () else { if (buffer[0] != '1' - /* FIXME: assumes that decimal_point is a single character - string. */ - || buffer[1] != decimal_point[0] + || buffer[1] != decimal_point || buffer[2 + strspn (&buffer[2], "0123456789")] != '\0') return "%g"; width1 -= 2; @@ -266,9 +263,7 @@ get_width_format () else { if (buffer[0] != '1' - /* FIXME: assumes that decimal_point is a single character - string. */ - || buffer[1] != decimal_point[0] + || buffer[1] != decimal_point || buffer[2 + strspn (&buffer[2], "0123456789")] != '\0') return "%g"; width2 -= 2; @@ -315,17 +310,17 @@ main (int argc, char **argv) separator = "\n"; first = 1.0; - /* Figure out the locale's idea of a decimal point. */ -#if HAVE_LOCALECONV + /* Get locale's representation of the decimal point. */ { - struct lconv *locale; - - locale = localeconv (); - /* Paranoia. */ - if (locale && locale->decimal_point && locale->decimal_point[0] != '\0') - decimal_point = locale->decimal_point; + struct lconv const *locale = localeconv (); + + /* If the locale doesn't define a decimal point, or if the decimal + point is multibyte, use the C locale's decimal point. FIXME: + add support for multibyte decimal points. */ + decimal_point = locale->decimal_point[0]; + if (! decimal_point || locale->decimal_point[1]) + decimal_point = '.'; } -#endif /* We have to handle negative numbers in the command line but this conflicts with the command line arguments. So explicitly check first @@ -333,7 +328,7 @@ main (int argc, char **argv) while (optind < argc) { if (argv[optind][0] == '-' - && ((optc = argv[optind][1]) == decimal_point[0] + && ((optc = argv[optind][1]) == decimal_point || ISDIGIT (optc))) { /* means negative number */