Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 99382f4

Browse files
committed
Save and restore errno across bindtextdomain call, per discussion.
1 parent 3d6b0d8 commit 99382f4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/interfaces/libpq/fe-misc.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1994, Regents of the University of California
2424
*
2525
* IDENTIFICATION
26-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.114 2005/06/12 00:00:21 neilc Exp $
26+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.115 2005/07/06 16:25:59 tgl Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -1128,13 +1128,21 @@ PQenv2encoding(void)
11281128
char *
11291129
libpq_gettext(const char *msgid)
11301130
{
1131-
static int already_bound = 0;
1131+
static bool already_bound = false;
11321132

11331133
if (!already_bound)
11341134
{
1135-
already_bound = 1;
1135+
/* dgettext() preserves errno, but bindtextdomain() doesn't */
1136+
int save_errno = errno;
1137+
const char *ldir;
1138+
1139+
already_bound = true;
11361140
/* No relocatable lookup here because the binary could be anywhere */
1137-
bindtextdomain("libpq", getenv("PGLOCALEDIR") ? getenv("PGLOCALEDIR") : LOCALEDIR);
1141+
ldir = getenv("PGLOCALEDIR");
1142+
if (!ldir)
1143+
ldir = LOCALEDIR;
1144+
bindtextdomain("libpq", ldir);
1145+
errno = save_errno;
11381146
}
11391147

11401148
return dgettext("libpq", msgid);

0 commit comments

Comments
 (0)