Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bf3401f

Browse files
committed
Harmonize MinGW CODESET lookup with MSVC.
Historically, MinGW environments lacked some Windows API calls, so we took a different code path in win32_langinfo(). Somehow, the code change in commit 35eeea6 (removing setlocale() calls) caused one particular 001_initdb.pl test to fail on MinGW + ICU builds, because pg_import_system_collations() found no collations. It might take a MinGW user to discover the exact reason. Updating that function to use the same code as MSVC seems to fix that test, so lets do that. (There are plenty more places that test for MSVC unnecessarily, to be investigated later.) While here, also rename the helper function win32_langinfo() to win32_get_codeset(), to explain what it does less confusingly; it's not really a general langinfo() substitute. Noticed by triggering the optional MinGW CI task; no build farm animals failed. Discussion: https://postgr.es/m/CA%2BhUKGKBWfhXQ3J%2B2Lj5PhKvQnGD%3DsywA0XQcb7boTCf%3DerVLg%40mail.gmail.com
1 parent 4c1b4cd commit bf3401f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/port/chklocale.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static const struct encoding_match encoding_match_list[] = {
193193

194194
#ifdef WIN32
195195
/*
196-
* On Windows, use CP<code page number> instead of the nl_langinfo() result
196+
* On Windows, use CP<code page number> instead of CODESET.
197197
*
198198
* This routine uses GetLocaleInfoEx() to parse short locale names like
199199
* "de-DE", "fr-FR", etc. If those cannot be parsed correctly process falls
@@ -203,12 +203,10 @@ static const struct encoding_match encoding_match_list[] = {
203203
* Returns a malloc()'d string for the caller to free.
204204
*/
205205
static char *
206-
win32_langinfo(const char *ctype)
206+
win32_get_codeset(const char *ctype)
207207
{
208208
char *r = NULL;
209209
char *codepage;
210-
211-
#if defined(_MSC_VER)
212210
uint32 cp;
213211
WCHAR wctype[LOCALE_NAME_MAX_LENGTH];
214212

@@ -233,7 +231,6 @@ win32_langinfo(const char *ctype)
233231
}
234232
}
235233
else
236-
#endif
237234
{
238235
/*
239236
* Locale format on Win32 is <Language>_<Country>.<CodePage>. For
@@ -336,7 +333,7 @@ pg_get_encoding_from_locale(const char *ctype, bool write_message)
336333

337334
freelocale(loc);
338335
#else
339-
sys = win32_langinfo(ctype);
336+
sys = win32_get_codeset(ctype);
340337
#endif
341338

342339
if (!sys)

0 commit comments

Comments
 (0)