When setting default thousands separator when locale has "", use logic

so new thousands separator doesn't match decimal symbol.
This commit is contained in:
Bruce Momjian 2007-11-21 22:28:18 +00:00
parent 6f3149e464
commit 3894e7cc55
2 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.133 2007/11/21 21:49:22 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.134 2007/11/21 22:28:18 momjian Exp $
* *
* *
* Portions Copyright (c) 1999-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1999-2007, PostgreSQL Global Development Group
@ -3915,7 +3915,6 @@ NUM_prepare_locale(NUMProc *Np)
*/ */
if (lconv->decimal_point && *lconv->decimal_point) if (lconv->decimal_point && *lconv->decimal_point)
Np->decimal = lconv->decimal_point; Np->decimal = lconv->decimal_point;
else else
Np->decimal = "."; Np->decimal = ".";
@ -3926,13 +3925,14 @@ NUM_prepare_locale(NUMProc *Np)
* Number thousands separator * Number thousands separator
* *
* Some locales (e.g. broken glibc pt_BR), have a comma for decimal, * Some locales (e.g. broken glibc pt_BR), have a comma for decimal,
* but "" for thousands_sep, so we make the thousands_sep comma * but "" for thousands_sep, so we set the thousands_sep too. 2007-02-12
* too. 2007-02-12
*/ */
if (lconv->thousands_sep && *lconv->thousands_sep) if (lconv->thousands_sep && *lconv->thousands_sep)
Np->L_thousands_sep = lconv->thousands_sep; Np->L_thousands_sep = lconv->thousands_sep;
else else if (strcmp(Np->decimal, ",") != 0)
Np->L_thousands_sep = ","; Np->L_thousands_sep = ",";
else
Np->L_thousands_sep = ".";
/* /*
* Currency symbol * Currency symbol

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.91 2007/01/05 22:19:49 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.92 2007/11/21 22:28:18 momjian Exp $
* *
* Note: we include postgres.h not postgres_fe.h so that we can include * Note: we include postgres.h not postgres_fe.h so that we can include
* catalog/pg_type.h, and thereby have access to INT4OID and similar macros. * catalog/pg_type.h, and thereby have access to INT4OID and similar macros.
@ -2039,7 +2039,7 @@ setDecimalLocale(void)
grouping = "3"; /* most common */ grouping = "3"; /* most common */
if (*extlconv->thousands_sep) if (*extlconv->thousands_sep)
thousands_sep = strdup(extlconv->thousands_sep); thousands_sep = strdup(extlconv->thousands_sep);
else if (*decimal_point != ',') else if (strcmp(decimal_point, ",") != 0)
thousands_sep = ","; thousands_sep = ",";
else else
thousands_sep = "."; thousands_sep = ".";