mirror of
https://github.com/postgres/postgres.git
synced 2025-06-01 00:01:20 -04:00
Save and restore errno across bindtextdomain call, per discussion.
This commit is contained in:
parent
3d6b0d8631
commit
99382f4581
@ -23,7 +23,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 *
|
char *
|
||||||
libpq_gettext(const char *msgid)
|
libpq_gettext(const char *msgid)
|
||||||
{
|
{
|
||||||
static int already_bound = 0;
|
static bool already_bound = false;
|
||||||
|
|
||||||
if (!already_bound)
|
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 */
|
/* 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);
|
return dgettext("libpq", msgid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user