From 91d381e3c01062f506ea947891d9f257cfe207f6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 8 Jul 2005 15:25:46 +0000 Subject: [PATCH] Make libpq_gettext save and restore errno in a Windows-compatible way. Also, back-patch fix into back branches. --- src/interfaces/libpq/fe-misc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 7e166f4a38f..45634a1286a 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.65 2001/12/03 00:28:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.65.2.1 2005/07/08 15:25:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -844,8 +844,16 @@ libpq_gettext(const char *msgid) if (!already_bound) { + /* dgettext() preserves errno, but bindtextdomain() doesn't */ + int save_errno = errno; + already_bound = 1; bindtextdomain("libpq", LOCALEDIR); +#ifdef WIN32 + SetLastError(save_errno); +#else + errno = save_errno; +#endif } return dgettext("libpq", msgid); -- 2.39.5