diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-05-08 19:17:30 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-05-08 19:17:30 -0400 |
commit | be3d8140a0a1c3a1b4ec7b2ca2e931d7f0ef47fd (patch) | |
tree | 74d77374f14b356a46f4f7e9671b0996e1c4ce1b /src/locale/__get_locale.c | |
parent | 8f4d1a2409bf7465a9be027268ed35e4099b3e34 (diff) |
load the locale lazily
Diffstat (limited to 'src/locale/__get_locale.c')
-rw-r--r-- | src/locale/__get_locale.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/locale/__get_locale.c b/src/locale/__get_locale.c index 94bb62a0..b795d0f0 100644 --- a/src/locale/__get_locale.c +++ b/src/locale/__get_locale.c @@ -5,8 +5,19 @@ This implementation only supports a single, global locale. A second implementation will be needed for POSIX.1-2008 per-thread locales. */ +#ifdef _POSIX_SOURCE +# define DEFAULT_LOCALE "POSIX" +#else +# define DEFAULT_LOCALE "C" +#endif + struct __locale_t * __get_locale(void) { static struct __locale_t l; + static int loaded = 0; + if (!loaded) { + loaded = 1; + __load_locale(&l, LC_ALL, DEFAULT_LOCALE); + } return &l; } |