From 64e1309c76aca35e32e62e69fc11e96aadfb2615 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 13 Apr 2012 20:37:07 +0300 Subject: [PATCH] Consistently quote encoding and locale names in messages --- src/backend/commands/dbcommands.c | 12 ++++++------ src/bin/initdb/initdb.c | 24 ++++++++++++------------ src/test/locale/test-ctype.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 9721ce9e0a..90155b9c14 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -323,12 +323,12 @@ createdb(const CreatedbStmt *stmt) if (!check_locale(LC_COLLATE, dbcollate, &canonname)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("invalid locale name %s", dbcollate))); + errmsg("invalid locale name: \"%s\"", dbcollate))); dbcollate = canonname; if (!check_locale(LC_CTYPE, dbctype, &canonname)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("invalid locale name %s", dbctype))); + errmsg("invalid locale name: \"%s\"", dbctype))); dbctype = canonname; check_encoding_locale_matches(encoding, dbcollate, dbctype); @@ -692,10 +692,10 @@ check_encoding_locale_matches(int encoding, const char *collate, const char *cty (encoding == PG_SQL_ASCII && superuser()))) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("encoding %s does not match locale %s", + errmsg("encoding \"%s\" does not match locale \"%s\"", pg_encoding_to_char(encoding), ctype), - errdetail("The chosen LC_CTYPE setting requires encoding %s.", + errdetail("The chosen LC_CTYPE setting requires encoding \"%s\".", pg_encoding_to_char(ctype_encoding)))); if (!(collate_encoding == encoding || @@ -707,10 +707,10 @@ check_encoding_locale_matches(int encoding, const char *collate, const char *cty (encoding == PG_SQL_ASCII && superuser()))) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("encoding %s does not match locale %s", + errmsg("encoding \"%s\" does not match locale \"%s\"", pg_encoding_to_char(encoding), collate), - errdetail("The chosen LC_COLLATE setting requires encoding %s.", + errdetail("The chosen LC_COLLATE setting requires encoding \"%s\".", pg_encoding_to_char(collate_encoding)))); } diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index b0bc4a2e55..87a9c95430 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1651,7 +1651,7 @@ setup_collation(void) if (len == 0 || localebuf[len - 1] != '\n') { if (debug) - fprintf(stderr, _("%s: locale name too long, skipped: %s\n"), + fprintf(stderr, _("%s: locale name too long, skipped: \"%s\"\n"), progname, localebuf); continue; } @@ -1676,7 +1676,7 @@ setup_collation(void) if (skip) { if (debug) - fprintf(stderr, _("%s: locale name has non-ASCII characters, skipped: %s\n"), + fprintf(stderr, _("%s: locale name has non-ASCII characters, skipped: \"%s\"\n"), progname, localebuf); continue; } @@ -2971,7 +2971,7 @@ main(int argc, char *argv[]) strcmp(lc_ctype, lc_numeric) == 0 && strcmp(lc_ctype, lc_monetary) == 0 && strcmp(lc_ctype, lc_messages) == 0) - printf(_("The database cluster will be initialized with locale %s.\n"), lc_ctype); + printf(_("The database cluster will be initialized with locale \"%s\".\n"), lc_ctype); else { printf(_("The database cluster will be initialized with locales\n" @@ -2998,7 +2998,7 @@ main(int argc, char *argv[]) if (ctype_enc == -1) { /* Couldn't recognize the locale's codeset */ - fprintf(stderr, _("%s: could not find suitable encoding for locale %s\n"), + fprintf(stderr, _("%s: could not find suitable encoding for locale \"%s\"\n"), progname, lc_ctype); fprintf(stderr, _("Rerun %s with the -E option.\n"), progname); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), @@ -3013,18 +3013,18 @@ main(int argc, char *argv[]) * UTF-8. */ #ifdef WIN32 - printf(_("Encoding %s implied by locale is not allowed as a server-side encoding.\n" - "The default database encoding will be set to %s instead.\n"), + printf(_("Encoding \"%s\" implied by locale is not allowed as a server-side encoding.\n" + "The default database encoding will be set to \"%s\" instead.\n"), pg_encoding_to_char(ctype_enc), pg_encoding_to_char(PG_UTF8)); ctype_enc = PG_UTF8; encodingid = encodingid_to_string(ctype_enc); #else fprintf(stderr, - _("%s: locale %s requires unsupported encoding %s\n"), + _("%s: locale \"%s\" requires unsupported encoding \"%s\"\n"), progname, lc_ctype, pg_encoding_to_char(ctype_enc)); fprintf(stderr, - _("Encoding %s is not allowed as a server-side encoding.\n" + _("Encoding \"%s\" is not allowed as a server-side encoding.\n" "Rerun %s with a different locale selection.\n"), pg_encoding_to_char(ctype_enc), progname); exit(1); @@ -3033,7 +3033,7 @@ main(int argc, char *argv[]) else { encodingid = encodingid_to_string(ctype_enc); - printf(_("The default database encoding has accordingly been set to %s.\n"), + printf(_("The default database encoding has accordingly been set to \"%s\".\n"), pg_encoding_to_char(ctype_enc)); } } @@ -3050,7 +3050,7 @@ main(int argc, char *argv[]) default_text_search_config = find_matching_ts_config(lc_ctype); if (default_text_search_config == NULL) { - printf(_("%s: could not find suitable text search configuration for locale %s\n"), + printf(_("%s: could not find suitable text search configuration for locale \"%s\"\n"), progname, lc_ctype); default_text_search_config = "simple"; } @@ -3061,12 +3061,12 @@ main(int argc, char *argv[]) if (checkmatch == NULL) { - printf(_("%s: warning: suitable text search configuration for locale %s is unknown\n"), + printf(_("%s: warning: suitable text search configuration for locale \"%s\" is unknown\n"), progname, lc_ctype); } else if (strcmp(checkmatch, default_text_search_config) != 0) { - printf(_("%s: warning: specified text search configuration \"%s\" might not match locale %s\n"), + printf(_("%s: warning: specified text search configuration \"%s\" might not match locale \"%s\"\n"), progname, default_text_search_config, lc_ctype); } } diff --git a/src/test/locale/test-ctype.c b/src/test/locale/test-ctype.c index 8839d2de50..a3f896c5ec 100644 --- a/src/test/locale/test-ctype.c +++ b/src/test/locale/test-ctype.c @@ -64,7 +64,7 @@ main() cur_locale = setlocale(LC_ALL, ""); if (cur_locale) - fprintf(stderr, "Successfulle set locale to %s\n", cur_locale); + fprintf(stderr, "Successfully set locale to \"%s\"\n", cur_locale); else { fprintf(stderr, "Cannot setup locale. Either your libc does not provide\nlocale support, or your locale data is corrupt, or you have not set\nLANG or LC_CTYPE environment variable to proper value. Program aborted.\n");