Index: backend/utils/adt/pg_locale.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v retrieving revision 1.28 diff -c -r1.28 pg_locale.c *** backend/utils/adt/pg_locale.c 29 Aug 2004 05:06:49 -0000 1.28 --- backend/utils/adt/pg_locale.c 17 Oct 2004 15:28:57 -0000 *************** *** 77,82 **** --- 77,89 ---- { char *save; + #if defined(WIN32) && defined(LC_MESSAGES) + /* On WIN32 there is no way to determine if a value set for + * LC_MESSAGES is actually valid */ + if (category == LC_MESSAGES) + return value; + #endif + save = setlocale(category, NULL); if (!save) return NULL; /* won't happen, we hope */ *************** *** 123,128 **** --- 130,136 ---- const char * locale_messages_assign(const char *value, bool doit, GucSource source) { + #ifndef WIN32 /* * LC_MESSAGES category does not exist everywhere, but accept it * anyway *************** *** 131,155 **** if (doit) { if (!setlocale(LC_MESSAGES, value)) - { - #ifdef WIN32 - - /* - * Win32 returns NULL when you set LC_MESSAGES to "". So - * don't complain unless we're trying to set it to something - * else. - */ - if (value[0]) - return NULL; - #else return NULL; - #endif - } } else value = locale_xxx_assign(LC_MESSAGES, value, false, source); #endif /* LC_MESSAGES */ return value; } --- 139,179 ---- if (doit) { if (!setlocale(LC_MESSAGES, value)) return NULL; } else value = locale_xxx_assign(LC_MESSAGES, value, false, source); #endif /* LC_MESSAGES */ return value; + + #else + /* Win32 does not have setlocale() for LC_MESSAGES. We can only + * use environment variables to change it... (per gettext FAQ) + */ + char env[128]; + + if (!doit) + /* There is no way to determine if specified language is available, + * so we assume it is. */ + return value; + + if (!value[0]) + /* "" means set to what's in the environment, and that's already + * what is used. So just pretend we changed it. */ + return value; + + /* We need to modify both the process environment and the cached + * version in msvcrt */ + if (!SetEnvironmentVariable("LC_MESSAGES",value)) + return NULL; + + ZeroMemory(env,sizeof(env)); + snprintf(env,sizeof(env)-1,"LC_MESSAGES=%s",value); + if (_putenv(env)) + return NULL; + + return value; + #endif }