summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorPeter Eisentraut2011-05-19 19:56:53 +0000
committerPeter Eisentraut2011-05-19 19:56:53 +0000
commitfcd4575905608a6dd0868bd6ab99f3e06a743152 (patch)
tree8d0af8f1cfcabd9599481cb5c36afd8da1451d9e /src/interfaces
parent8d8954938094744ef4cab9d6f45f8e9e8abeb58f (diff)
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.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/libpq/fe-connect.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 6648753da0..f89ceb9664 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1012,7 +1012,7 @@ connectFailureMessage(PGconn *conn, int errorno)
#endif /* HAVE_UNIX_SOCKETS */
{
char host_addr[NI_MAXHOST];
- bool display_host_addr;
+ const char *displayed_host;
struct sockaddr_storage *addr = &conn->raddr.addr;
/*
@@ -1042,30 +1042,36 @@ connectFailureMessage(PGconn *conn, int errorno)
else
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
* 'host' was missing or does not match our lookup, display the
* looked-up IP address.
*/
- display_host_addr = (conn->pghostaddr == NULL) &&
- ((conn->pghost == NULL) ||
- (strcmp(conn->pghost, host_addr) != 0));
-
- appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not connect to server: %s\n"
- "\tIs the server running on host \"%s\"%s%s%s and accepting\n"
- "\tTCP/IP connections on port %s?\n"),
- SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
- (conn->pghostaddr && conn->pghostaddr[0] != '\0')
- ? conn->pghostaddr
- : (conn->pghost && conn->pghost[0] != '\0')
- ? conn->pghost
- : DefaultHost,
- /* display the IP address only if not already output */
- display_host_addr ? " (" : "",
- display_host_addr ? host_addr : "",
- display_host_addr ? ")" : "",
- conn->pgport);
+ if ((conn->pghostaddr == NULL) &&
+ (conn->pghost == NULL || strcmp(conn->pghost, host_addr) != 0))
+ appendPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("could not connect to server: %s\n"
+ "\tIs the server running on host \"%s\" (%s) and accepting\n"
+ "\tTCP/IP connections on port %s?\n"),
+ SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
+ displayed_host,
+ host_addr,
+ conn->pgport);
+ else
+ appendPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("could not connect to server: %s\n"
+ "\tIs the server running on host \"%s\" and accepting\n"
+ "\tTCP/IP connections on port %s?\n"),
+ SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
+ displayed_host,
+ conn->pgport);
}
}