summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-03-15 16:14:26 +0000
committerBruce Momjian <bruce@momjian.us>2004-03-15 16:14:26 +0000
commitdea47eee0619f5260fe7f0f44e58cf79251f0229 (patch)
tree1829e091b1c8901690a65d7f3cc9f8fc8885d4a0
parent221c0adaa83cda831c8f5add16ada6e8f1083e2a (diff)
Windows uses codepages rather than the environment, so we work around
that by querying the environment explicitly first for LC_COLLATE and LC_CTYPE. We have to do this because initdb passes those values in the environment. If there is nothing there we fall back on the codepage. Andrew Dunstan
-rw-r--r--src/backend/main/main.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index fe368f591ae..b2557572184 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.75 2004/03/05 01:11:04 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,6 +74,10 @@ main(int argc, char *argv[])
#endif /* NOPRINTADE */
#endif /* __alpha */
+#ifdef WIN32
+ char *env_locale;
+#endif
+
#if defined(NOFIXADE) || defined(NOPRINTADE)
#if defined(ultrix4)
@@ -143,8 +147,30 @@ main(int argc, char *argv[])
* set later during GUC option processing, but we set it here to allow
* startup error messages to be localized.
*/
+
+#ifdef WIN32
+ /*
+ * Windows uses codepages rather than the environment, so we work around
+ * that by querying the environment explicitly first for LC_COLLATE
+ * and LC_CTYPE. We have to do this because initdb passes those values
+ * in the environment. If there is nothing there we fall back on the
+ * codepage.
+ */
+
+ if ((env_locale = getenv("LC_COLLATE")) != NULL)
+ setlocale(LC_COLLATE,env_locale);
+ else
+ setlocale(LC_COLLATE, "");
+
+ if ((env_locale = getenv("LC_CTYPE")) != NULL)
+ setlocale(LC_CTYPE,env_locale);
+ else
+ setlocale(LC_CTYPE, "");
+#else
setlocale(LC_COLLATE, "");
setlocale(LC_CTYPE, "");
+#endif
+
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
#endif