MCPcopy Create free account
hub / github.com/apache/cloudberry / libpq_binddomain

Function libpq_binddomain

src/interfaces/libpq/fe-misc.c:1342–1376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1340#ifdef ENABLE_NLS
1341
1342static void
1343libpq_binddomain(void)
1344{
1345 /*
1346 * If multiple threads come through here at about the same time, it's okay
1347 * for more than one of them to call bindtextdomain(). But it's not okay
1348 * for any of them to return to caller before bindtextdomain() is
1349 * complete, so don't set the flag till that's done. Use "volatile" just
1350 * to be sure the compiler doesn't try to get cute.
1351 */
1352 static volatile bool already_bound = false;
1353
1354 if (!already_bound)
1355 {
1356 /* bindtextdomain() does not preserve errno */
1357#ifdef WIN32
1358 int save_errno = GetLastError();
1359#else
1360 int save_errno = errno;
1361#endif
1362 const char *ldir;
1363
1364 /* No relocatable lookup here because the binary could be anywhere */
1365 ldir = getenv("PGLOCALEDIR");
1366 if (!ldir)
1367 ldir = LOCALEDIR;
1368 bindtextdomain(PG_TEXTDOMAIN("libpq"), ldir);
1369 already_bound = true;
1370#ifdef WIN32
1371 SetLastError(save_errno);
1372#else
1373 errno = save_errno;
1374#endif
1375 }
1376}
1377
1378char *
1379libpq_gettext(const char *msgid)

Callers 2

libpq_gettextFunction · 0.85
libpq_ngettextFunction · 0.85

Calls 2

GetLastErrorFunction · 0.85
SetLastErrorFunction · 0.85

Tested by

no test coverage detected