Skip to content

Commit 8539a0e

Browse files
committed
Check for C/POSIX before assuming that nl_langinfo or win32_langinfo
will work. Per buildfarm results.
1 parent 8f8a5df commit 8539a0e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/port/chklocale.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/chklocale.c,v 1.12 2009/11/12 02:46:16 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/chklocale.c,v 1.13 2009/11/12 03:37:15 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -237,6 +237,11 @@ pg_get_encoding_from_locale(const char *ctype)
237237
char *save;
238238
char *name;
239239

240+
/* If locale is C or POSIX, we can allow all encodings */
241+
if (pg_strcasecmp(ctype, "C") == 0 ||
242+
pg_strcasecmp(ctype, "POSIX") == 0)
243+
return PG_SQL_ASCII;
244+
240245
save = setlocale(LC_CTYPE, NULL);
241246
if (!save)
242247
return -1; /* setlocale() broken? */
@@ -269,6 +274,12 @@ pg_get_encoding_from_locale(const char *ctype)
269274
ctype = setlocale(LC_CTYPE, NULL);
270275
if (!ctype)
271276
return -1; /* setlocale() broken? */
277+
278+
/* If locale is C or POSIX, we can allow all encodings */
279+
if (pg_strcasecmp(ctype, "C") == 0 ||
280+
pg_strcasecmp(ctype, "POSIX") == 0)
281+
return PG_SQL_ASCII;
282+
272283
#ifndef WIN32
273284
sys = nl_langinfo(CODESET);
274285
if (sys)
@@ -281,13 +292,6 @@ pg_get_encoding_from_locale(const char *ctype)
281292
if (!sys)
282293
return -1; /* out of memory; unlikely */
283294

284-
/* If locale is C or POSIX, we can allow all encodings */
285-
if (pg_strcasecmp(ctype, "C") == 0 || pg_strcasecmp(ctype, "POSIX") == 0)
286-
{
287-
free(sys);
288-
return PG_SQL_ASCII;
289-
}
290-
291295
/* Check the table */
292296
for (i = 0; encoding_match_list[i].system_enc_name; i++)
293297
{

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