From: Tom Lane Date: Fri, 8 Jul 2005 15:25:19 +0000 (+0000) Subject: Make libpq_gettext save and restore errno in a Windows-compatible way. X-Git-Tag: REL7_4_9~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5d10d66d1c8768974ae6245bdff8f28e0dab31f;p=thirdparty%2Fpostgresql.git Make libpq_gettext save and restore errno in a Windows-compatible way. Also, back-patch fix into back branches. --- diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 4349a4e05aa..0f3f2813711 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.103 2003/10/19 21:36:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.103.2.1 2005/07/08 15:25:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1120,8 +1120,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);