mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Check for C/POSIX before assuming that nl_langinfo or win32_langinfo
will work. Per buildfarm results.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/port/chklocale.c,v 1.12 2009/11/12 02:46:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/port/chklocale.c,v 1.13 2009/11/12 03:37:15 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -237,6 +237,11 @@ pg_get_encoding_from_locale(const char *ctype)
|
|||||||
char *save;
|
char *save;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
/* If locale is C or POSIX, we can allow all encodings */
|
||||||
|
if (pg_strcasecmp(ctype, "C") == 0 ||
|
||||||
|
pg_strcasecmp(ctype, "POSIX") == 0)
|
||||||
|
return PG_SQL_ASCII;
|
||||||
|
|
||||||
save = setlocale(LC_CTYPE, NULL);
|
save = setlocale(LC_CTYPE, NULL);
|
||||||
if (!save)
|
if (!save)
|
||||||
return -1; /* setlocale() broken? */
|
return -1; /* setlocale() broken? */
|
||||||
@ -269,6 +274,12 @@ pg_get_encoding_from_locale(const char *ctype)
|
|||||||
ctype = setlocale(LC_CTYPE, NULL);
|
ctype = setlocale(LC_CTYPE, NULL);
|
||||||
if (!ctype)
|
if (!ctype)
|
||||||
return -1; /* setlocale() broken? */
|
return -1; /* setlocale() broken? */
|
||||||
|
|
||||||
|
/* If locale is C or POSIX, we can allow all encodings */
|
||||||
|
if (pg_strcasecmp(ctype, "C") == 0 ||
|
||||||
|
pg_strcasecmp(ctype, "POSIX") == 0)
|
||||||
|
return PG_SQL_ASCII;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
sys = nl_langinfo(CODESET);
|
sys = nl_langinfo(CODESET);
|
||||||
if (sys)
|
if (sys)
|
||||||
@ -281,13 +292,6 @@ pg_get_encoding_from_locale(const char *ctype)
|
|||||||
if (!sys)
|
if (!sys)
|
||||||
return -1; /* out of memory; unlikely */
|
return -1; /* out of memory; unlikely */
|
||||||
|
|
||||||
/* If locale is C or POSIX, we can allow all encodings */
|
|
||||||
if (pg_strcasecmp(ctype, "C") == 0 || pg_strcasecmp(ctype, "POSIX") == 0)
|
|
||||||
{
|
|
||||||
free(sys);
|
|
||||||
return PG_SQL_ASCII;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the table */
|
/* Check the table */
|
||||||
for (i = 0; encoding_match_list[i].system_enc_name; i++)
|
for (i = 0; encoding_match_list[i].system_enc_name; i++)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user