| 1340 | #ifdef ENABLE_NLS |
| 1341 | |
| 1342 | static void |
| 1343 | libpq_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 | |
| 1378 | char * |
| 1379 | libpq_gettext(const char *msgid) |
no test coverage detected