Fix untranslatable assembly of libpq connection failure message
Even though this only affects the insertion of a parenthesized word, it's unwise to assume that parentheses can pass through untranslated. And in any case, the new version is clearer in the code and for translators.
This commit is contained in:
parent
8d89549380
commit
fcd4575905
|
@ -1012,7 +1012,7 @@ connectFailureMessage(PGconn *conn, int errorno)
|
||||||
#endif /* HAVE_UNIX_SOCKETS */
|
#endif /* HAVE_UNIX_SOCKETS */
|
||||||
{
|
{
|
||||||
char host_addr[NI_MAXHOST];
|
char host_addr[NI_MAXHOST];
|
||||||
bool display_host_addr;
|
const char *displayed_host;
|
||||||
struct sockaddr_storage *addr = &conn->raddr.addr;
|
struct sockaddr_storage *addr = &conn->raddr.addr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1042,30 +1042,36 @@ connectFailureMessage(PGconn *conn, int errorno)
|
||||||
else
|
else
|
||||||
strcpy(host_addr, "???");
|
strcpy(host_addr, "???");
|
||||||
|
|
||||||
|
if (conn->pghostaddr && conn->pghostaddr[0] != '\0')
|
||||||
|
displayed_host = conn->pghostaddr;
|
||||||
|
else if (conn->pghost && conn->pghost[0] != '\0')
|
||||||
|
displayed_host = conn->pghost;
|
||||||
|
else
|
||||||
|
displayed_host = DefaultHost;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the user did not supply an IP address using 'hostaddr', and
|
* If the user did not supply an IP address using 'hostaddr', and
|
||||||
* 'host' was missing or does not match our lookup, display the
|
* 'host' was missing or does not match our lookup, display the
|
||||||
* looked-up IP address.
|
* looked-up IP address.
|
||||||
*/
|
*/
|
||||||
display_host_addr = (conn->pghostaddr == NULL) &&
|
if ((conn->pghostaddr == NULL) &&
|
||||||
((conn->pghost == NULL) ||
|
(conn->pghost == NULL || strcmp(conn->pghost, host_addr) != 0))
|
||||||
(strcmp(conn->pghost, host_addr) != 0));
|
appendPQExpBuffer(&conn->errorMessage,
|
||||||
|
libpq_gettext("could not connect to server: %s\n"
|
||||||
appendPQExpBuffer(&conn->errorMessage,
|
"\tIs the server running on host \"%s\" (%s) and accepting\n"
|
||||||
libpq_gettext("could not connect to server: %s\n"
|
"\tTCP/IP connections on port %s?\n"),
|
||||||
"\tIs the server running on host \"%s\"%s%s%s and accepting\n"
|
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
|
||||||
"\tTCP/IP connections on port %s?\n"),
|
displayed_host,
|
||||||
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
|
host_addr,
|
||||||
(conn->pghostaddr && conn->pghostaddr[0] != '\0')
|
conn->pgport);
|
||||||
? conn->pghostaddr
|
else
|
||||||
: (conn->pghost && conn->pghost[0] != '\0')
|
appendPQExpBuffer(&conn->errorMessage,
|
||||||
? conn->pghost
|
libpq_gettext("could not connect to server: %s\n"
|
||||||
: DefaultHost,
|
"\tIs the server running on host \"%s\" and accepting\n"
|
||||||
/* display the IP address only if not already output */
|
"\tTCP/IP connections on port %s?\n"),
|
||||||
display_host_addr ? " (" : "",
|
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
|
||||||
display_host_addr ? host_addr : "",
|
displayed_host,
|
||||||
display_host_addr ? ")" : "",
|
conn->pgport);
|
||||||
conn->pgport);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue