Consistently quote encoding and locale names in messages
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 13 Apr 2012 17:37:07 +0000 (20:37 +0300)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 13 Apr 2012 17:37:07 +0000 (20:37 +0300)
src/backend/commands/dbcommands.c
src/bin/initdb/initdb.c
src/test/locale/test-ctype.c

index 9721ce9e0a6562b8b934c786adcc01eafd28b20c..90155b9c14b78f54d125c9704932b9b1a434e39e 100644 (file)
@@ -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))));
 }
 
index b0bc4a2e55ab8109b92693cbffea3d29f913f171..87a9c95430e953819393d1774974ef5eb345ff7c 100644 (file)
@@ -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);
        }
    }
index 8839d2de50fb58a5c90581d803565472ae959d98..a3f896c5ecb60045f061d6e8ad839673016a73be 100644 (file)
@@ -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");