aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-07-06 16:25:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-07-06 16:25:59 +0000
commit99382f45815d2720196e6d2510391d5781d0f46c (patch)
treeb4039a28c720ff25e9fe2de0b37df624452b1b42
parent3d6b0d8631a7944b290873e5443455bb82773373 (diff)
downloadpostgresql-99382f45815d2720196e6d2510391d5781d0f46c.tar.gz
postgresql-99382f45815d2720196e6d2510391d5781d0f46c.zip
Save and restore errno across bindtextdomain call, per discussion.
-rw-r--r--src/interfaces/libpq/fe-misc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 66ad325c528..6d3b814a9de 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
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.114 2005/06/12 00:00:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.115 2005/07/06 16:25:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1128,13 +1128,21 @@ PQenv2encoding(void)
char *
libpq_gettext(const char *msgid)
{
- static int already_bound = 0;
+ static bool already_bound = false;
if (!already_bound)
{
- already_bound = 1;
+ /* dgettext() preserves errno, but bindtextdomain() doesn't */
+ int save_errno = errno;
+ const char *ldir;
+
+ already_bound = true;
/* No relocatable lookup here because the binary could be anywhere */
- bindtextdomain("libpq", getenv("PGLOCALEDIR") ? getenv("PGLOCALEDIR") : LOCALEDIR);
+ ldir = getenv("PGLOCALEDIR");
+ if (!ldir)
+ ldir = LOCALEDIR;
+ bindtextdomain("libpq", ldir);
+ errno = save_errno;
}
return dgettext("libpq", msgid);