@@ -1564,7 +1564,7 @@ setup_collation(void)
15641564int i ;
15651565FILE * locale_a_handle ;
15661566char localebuf [NAMEDATALEN ];
1567- int skipped = 0 ;
1567+ int count = 0 ;
15681568PG_CMD_DECL ;
15691569#endif
15701570
@@ -1579,7 +1579,7 @@ setup_collation(void)
15791579
15801580locale_a_handle = popen_check ("locale -a" ,"r" );
15811581if (!locale_a_handle )
1582- return ;
1582+ return ;/* complaint already printed */
15831583
15841584PG_CMD_OPEN ;
15851585
@@ -1597,12 +1597,11 @@ setup_collation(void)
15971597
15981598len = strlen (localebuf );
15991599
1600- if (localebuf [len - 1 ]!= '\n' )
1600+ if (len == 0 || localebuf [len - 1 ]!= '\n' )
16011601{
16021602if (debug )
16031603fprintf (stderr ,_ ("%s: locale name too long, skipped: %s\n" ),
16041604progname ,localebuf );
1605- skipped ++ ;
16061605continue ;
16071606}
16081607localebuf [len - 1 ]= '\0' ;
@@ -1628,22 +1627,23 @@ setup_collation(void)
16281627if (debug )
16291628fprintf (stderr ,_ ("%s: locale name has non-ASCII characters, skipped: %s\n" ),
16301629progname ,localebuf );
1631- skipped ++ ;
16321630continue ;
16331631}
16341632
16351633enc = pg_get_encoding_from_locale (localebuf ,debug );
16361634if (enc < 0 )
16371635{
1638- skipped ++ ;
1639- continue ;/* error message printed by pg_get_encoding_from_locale() */
1636+ /* error message printed by pg_get_encoding_from_locale() */
1637+ continue ;
16401638}
16411639if (!PG_VALID_BE_ENCODING (enc ))
16421640continue ;/* ignore locales for client-only encodings */
16431641if (enc == PG_SQL_ASCII )
16441642continue ;/* C/POSIX are already in the catalog */
16451643
1646- PG_CMD_PRINTF2 ("INSERT INTO tmp_pg_collation (locale, encoding) VALUES ('%s', %d);" ,
1644+ count ++ ;
1645+
1646+ PG_CMD_PRINTF2 ("INSERT INTO tmp_pg_collation (locale, encoding) VALUES ('%s', %d);\n" ,
16471647escape_quotes (localebuf ),enc );
16481648
16491649/*
@@ -1653,12 +1653,12 @@ setup_collation(void)
16531653 * "en_US" for LATIN1, say.
16541654 */
16551655if (normalize_locale_name (alias ,localebuf ))
1656- PG_CMD_PRINTF3 ("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('%s', '%s', %d);" ,
1656+ PG_CMD_PRINTF3 ("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('%s', '%s', %d);\n " ,
16571657escape_quotes (alias ),escape_quotes (localebuf ),enc );
16581658}
16591659
16601660/* Add an SQL-standard name */
1661- PG_CMD_PRINTF1 ("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('ucs_basic', 'C', %d);" ,PG_UTF8 );
1661+ PG_CMD_PRINTF1 ("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('ucs_basic', 'C', %d);\n " ,PG_UTF8 );
16621662
16631663/*
16641664 * When copying collations to the final location, eliminate
@@ -1674,21 +1674,17 @@ setup_collation(void)
16741674" COALESCE(collname, locale) AS final_collname, "
16751675" (SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog') AS collnamespace, "
16761676" (SELECT relowner FROM pg_class WHERE relname = 'pg_collation') AS collowner, "
1677- " encoding, "
1678- " locale, locale "
1677+ " encoding, locale, locale "
16791678" FROM tmp_pg_collation"
16801679" ORDER BY final_collname, collnamespace, encoding, (collname = locale) DESC, locale;\n" );
16811680
16821681pclose (locale_a_handle );
16831682PG_CMD_CLOSE ;
16841683
16851684check_ok ();
1686- if (skipped && !debug )
1685+ if (count == 0 && !debug )
16871686{
1688- printf (ngettext ("%d system locale has been omitted because it cannot supported by PostgreSQL.\n" ,
1689- "%d system locales have been omitted because they cannot be supported by PostgreSQL.\n" ,
1690- skipped ),
1691- skipped );
1687+ printf (_ ("No usable system locales were found.\n" ));
16921688printf (_ ("Use the option \"--debug\" to see details.\n" ));
16931689}
16941690#else /* not HAVE_LOCALE_T */