summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2022-08-25 18:46:58 +0000
committerPeter Eisentraut2022-08-25 18:46:58 +0000
commit28ec316787674dd74d00b296724a009b6edc2fb0 (patch)
tree28b3e010878983f9ef1e90e5911db7a1b15846cb
parent66af5eea31e06fac288274cc056357cebbbbefe3 (diff)
libpq code should use libpq_gettext(), not _()
Fix some wrong use and install a safeguard against future mistakes.
-rw-r--r--src/interfaces/libpq/fe-auth-scram.c4
-rw-r--r--src/interfaces/libpq/libpq-int.h5
2 files changed, 7 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-auth-scram.c b/src/interfaces/libpq/fe-auth-scram.c
index 396b4ca0f0..35cfd9987d 100644
--- a/src/interfaces/libpq/fe-auth-scram.c
+++ b/src/interfaces/libpq/fe-auth-scram.c
@@ -922,7 +922,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)
@@ -931,7 +931,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");
free(prep_password);
return NULL;
}
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 1eb752a82d..c75ed63a2c 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -881,6 +881,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