Skip to content

Commit dea47ee

Browse files
committed
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
1 parent 221c0ad commit dea47ee

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/backend/main/main.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.75 2004/03/05 01:11:04 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -74,6 +74,10 @@ main(int argc, char *argv[])
7474
#endif /* NOPRINTADE */
7575
#endif /* __alpha */
7676

77+
#ifdef WIN32
78+
char *env_locale;
79+
#endif
80+
7781
#if defined(NOFIXADE) || defined(NOPRINTADE)
7882

7983
#if defined(ultrix4)
@@ -143,8 +147,30 @@ main(int argc, char *argv[])
143147
* set later during GUC option processing, but we set it here to allow
144148
* startup error messages to be localized.
145149
*/
150+
151+
#ifdef WIN32
152+
/*
153+
* Windows uses codepages rather than the environment, so we work around
154+
* that by querying the environment explicitly first for LC_COLLATE
155+
* and LC_CTYPE. We have to do this because initdb passes those values
156+
* in the environment. If there is nothing there we fall back on the
157+
* codepage.
158+
*/
159+
160+
if ((env_locale = getenv("LC_COLLATE")) != NULL)
161+
setlocale(LC_COLLATE,env_locale);
162+
else
163+
setlocale(LC_COLLATE, "");
164+
165+
if ((env_locale = getenv("LC_CTYPE")) != NULL)
166+
setlocale(LC_CTYPE,env_locale);
167+
else
168+
setlocale(LC_CTYPE, "");
169+
#else
146170
setlocale(LC_COLLATE, "");
147171
setlocale(LC_CTYPE, "");
172+
#endif
173+
148174
#ifdef LC_MESSAGES
149175
setlocale(LC_MESSAGES, "");
150176
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy