When setting default thousands separator when locale has "", use logic
authorBruce Momjian <bruce@momjian.us>
Wed, 21 Nov 2007 22:28:18 +0000 (22:28 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 21 Nov 2007 22:28:18 +0000 (22:28 +0000)
so new thousands separator doesn't match decimal symbol.

src/backend/utils/adt/formatting.c
src/bin/psql/print.c

index d976d8932ea923f115551488bbb0fdd7ef996419..555187277b513eafabc2bbb3e1b748b1ba900978 100644 (file)
@@ -3915,7 +3915,6 @@ NUM_prepare_locale(NUMProc *Np)
                 */
                if (lconv->decimal_point && *lconv->decimal_point)
                        Np->decimal = lconv->decimal_point;
-
                else
                        Np->decimal = ".";
 
@@ -3926,13 +3925,14 @@ NUM_prepare_locale(NUMProc *Np)
                 * Number thousands separator
                 *
                 * Some locales (e.g. broken glibc pt_BR), have a comma for decimal,
-                * but "" for thousands_sep, so we make the thousands_sep comma
-                * too.  2007-02-12
+                * but "" for thousands_sep, so we set the thousands_sep too. 2007-02-12
                 */
                if (lconv->thousands_sep && *lconv->thousands_sep)
                        Np->L_thousands_sep = lconv->thousands_sep;
-               else
+               else if (strcmp(Np->decimal, ",") != 0)
                        Np->L_thousands_sep = ",";
+               else
+                       Np->L_thousands_sep = ".";
 
                /*
                 * Currency symbol
index c04263b7c759c1b5ffb2a9bcf01ba131f3ce0742..b2cbe74a96416c1f274284b58b449a3ae2c78dd5 100644 (file)
@@ -2039,7 +2039,7 @@ setDecimalLocale(void)
                grouping = "3";                 /* most common */
        if (*extlconv->thousands_sep)
                thousands_sep = strdup(extlconv->thousands_sep);
-       else if (*decimal_point != ',')
+       else if (strcmp(decimal_point, ",") != 0)
                thousands_sep = ",";
        else
                thousands_sep = ".";