Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
libpq code should use libpq_gettext(), not _()
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 25 Aug 2022 18:46:58 +0000 (20:46 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 25 Aug 2022 18:48:20 +0000 (20:48 +0200)
Fix some wrong use and install a safeguard against future mistakes.

src/interfaces/libpq/fe-auth-scram.c
src/interfaces/libpq/libpq-int.h

index e5ad13daa50e91aa743b9e0e6eb0aa9f63d8116d..6ee51d4e5e79182b4db766dd6de85f39632d8ac6 100644 (file)
@@ -931,7 +931,7 @@ pg_fe_scram_build_secret(const char *password, const char **errstr)
    rc = pg_saslprep(password, &prep_password);
    if (rc == SASLPREP_OOM)
    {
-       *errstr = _("out of memory");
+       *errstr = libpq_gettext("out of memory");
        return NULL;
    }
    if (rc == SASLPREP_SUCCESS)
@@ -940,7 +940,7 @@ pg_fe_scram_build_secret(const char *password, const char **errstr)
    /* Generate a random salt */
    if (!pg_strong_random(saltbuf, SCRAM_DEFAULT_SALT_LEN))
    {
-       *errstr = _("could not generate random salt");
+       *errstr = libpq_gettext("could not generate random salt");
        if (prep_password)
            free(prep_password);
        return NULL;
index 51ab51f9f926df6ebc661e0ec1536796ddd7a28e..a27dd3785e11fd8bd333629f3a373a421ceb61cc 100644 (file)
@@ -880,6 +880,11 @@ extern char *libpq_ngettext(const char *msgid, const char *msgid_plural, unsigne
 #define libpq_gettext(x) (x)
 #define libpq_ngettext(s, p, n) ((n) == 1 ? (s) : (p))
 #endif
+/*
+ * libpq code should use the above, not _(), since that would use the
+ * surrounding programs's message catalog.
+ */
+#undef _
 
 /*
  * These macros are needed to let error-handling code be portable between