@@ -1564,7 +1564,7 @@ setup_collation(void)
1564
1564
int i ;
1565
1565
FILE * locale_a_handle ;
1566
1566
char localebuf [NAMEDATALEN ];
1567
- int skipped = 0 ;
1567
+ int count = 0 ;
1568
1568
PG_CMD_DECL ;
1569
1569
#endif
1570
1570
@@ -1579,7 +1579,7 @@ setup_collation(void)
1579
1579
1580
1580
locale_a_handle = popen_check ("locale -a" , "r" );
1581
1581
if (!locale_a_handle )
1582
- return ;
1582
+ return ; /* complaint already printed */
1583
1583
1584
1584
PG_CMD_OPEN ;
1585
1585
@@ -1597,12 +1597,11 @@ setup_collation(void)
1597
1597
1598
1598
len = strlen (localebuf );
1599
1599
1600
- if (localebuf [len - 1 ] != '\n' )
1600
+ if (len == 0 || localebuf [len - 1 ] != '\n' )
1601
1601
{
1602
1602
if (debug )
1603
1603
fprintf (stderr , _ ("%s: locale name too long, skipped: %s\n" ),
1604
1604
progname , localebuf );
1605
- skipped ++ ;
1606
1605
continue ;
1607
1606
}
1608
1607
localebuf [len - 1 ] = '\0' ;
@@ -1628,22 +1627,23 @@ setup_collation(void)
1628
1627
if (debug )
1629
1628
fprintf (stderr , _ ("%s: locale name has non-ASCII characters, skipped: %s\n" ),
1630
1629
progname , localebuf );
1631
- skipped ++ ;
1632
1630
continue ;
1633
1631
}
1634
1632
1635
1633
enc = pg_get_encoding_from_locale (localebuf , debug );
1636
1634
if (enc < 0 )
1637
1635
{
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 ;
1640
1638
}
1641
1639
if (!PG_VALID_BE_ENCODING (enc ))
1642
1640
continue ; /* ignore locales for client-only encodings */
1643
1641
if (enc == PG_SQL_ASCII )
1644
1642
continue ; /* C/POSIX are already in the catalog */
1645
1643
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" ,
1647
1647
escape_quotes (localebuf ), enc );
1648
1648
1649
1649
/*
@@ -1653,12 +1653,12 @@ setup_collation(void)
1653
1653
* "en_US" for LATIN1, say.
1654
1654
*/
1655
1655
if (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 " ,
1657
1657
escape_quotes (alias ), escape_quotes (localebuf ), enc );
1658
1658
}
1659
1659
1660
1660
/* 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 );
1662
1662
1663
1663
/*
1664
1664
* When copying collations to the final location, eliminate
@@ -1674,21 +1674,17 @@ setup_collation(void)
1674
1674
" COALESCE(collname, locale) AS final_collname, "
1675
1675
" (SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog') AS collnamespace, "
1676
1676
" (SELECT relowner FROM pg_class WHERE relname = 'pg_collation') AS collowner, "
1677
- " encoding, "
1678
- " locale, locale "
1677
+ " encoding, locale, locale "
1679
1678
" FROM tmp_pg_collation"
1680
1679
" ORDER BY final_collname, collnamespace, encoding, (collname = locale) DESC, locale;\n" );
1681
1680
1682
1681
pclose (locale_a_handle );
1683
1682
PG_CMD_CLOSE ;
1684
1683
1685
1684
check_ok ();
1686
- if (skipped && !debug )
1685
+ if (count == 0 && !debug )
1687
1686
{
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" ));
1692
1688
printf (_ ("Use the option \"--debug\" to see details.\n" ));
1693
1689
}
1694
1690
#else /* not HAVE_LOCALE_T */
0 commit comments