88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/port/chklocale.c,v 1.12 2009/11/1202:46:16 tgl Exp $
11+ * $PostgreSQL: pgsql/src/port/chklocale.c,v 1.13 2009/11/1203:37:15 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -237,6 +237,11 @@ pg_get_encoding_from_locale(const char *ctype)
237237char * save ;
238238char * 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+
240245save = setlocale (LC_CTYPE ,NULL );
241246if (!save )
242247return -1 ;/* setlocale() broken? */
@@ -269,6 +274,12 @@ pg_get_encoding_from_locale(const char *ctype)
269274ctype = setlocale (LC_CTYPE ,NULL );
270275if (!ctype )
271276return -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
273284sys = nl_langinfo (CODESET );
274285if (sys )
@@ -281,13 +292,6 @@ pg_get_encoding_from_locale(const char *ctype)
281292if (!sys )
282293return -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 */
292296for (i = 0 ;encoding_match_list [i ].system_enc_name ;i ++ )
293297{