diff --git a/src/system/libroot/posix/locale/locale_t.cpp b/src/system/libroot/posix/locale/locale_t.cpp index a5c23eb8c5..780c4cb8c6 100644 --- a/src/system/libroot/posix/locale/locale_t.cpp +++ b/src/system/libroot/posix/locale/locale_t.cpp @@ -34,14 +34,15 @@ duplocale(locale_t l) errno = ENOMEM; return (locale_t)0; } + newObj->magic = LOCALE_T_MAGIC; + newObj->backend = NULL; + newObj->databridge = NULL; LocaleBackend* backend = (l == LC_GLOBAL_LOCALE) ? gGlobalLocaleBackend : (LocaleBackend*)locObj->backend; - if (backend == NULL) { - newObj->backend = NULL; + if (backend == NULL) return (locale_t)newObj; - } // Check if everything is set to "C" or "POSIX", // and avoid making a backend. @@ -49,7 +50,6 @@ duplocale(locale_t l) if ((strcasecmp(localeDescription, "POSIX") == 0) || (strcasecmp(localeDescription, "C") == 0)) { - newObj->backend = NULL; return (locale_t)newObj; } @@ -81,8 +81,6 @@ duplocale(locale_t l) newBackend->SetLocale(lc, backend->SetLocale(lc, NULL)); } - newObj->magic = LOCALE_T_MAGIC; - return (locale_t)newObj; } @@ -275,3 +273,13 @@ __current_locale_t() return locale; } + + +extern "C" locale_t +__posix_locale_t() +{ + static LocaleBackendData posix_locale_t; + posix_locale_t.backend = NULL; + posix_locale_t.databridge = NULL; + return &posix_locale_t; +} diff --git a/src/system/libroot/posix/musl/internal/locale_impl.h b/src/system/libroot/posix/musl/internal/locale_impl.h index a7cd0de87d..51b245bc66 100644 --- a/src/system/libroot/posix/musl/internal/locale_impl.h +++ b/src/system/libroot/posix/musl/internal/locale_impl.h @@ -10,6 +10,8 @@ #define __nl_langinfo_l nl_langinfo_l locale_t __current_locale_t(); +locale_t __posix_locale_t(); #define CURRENT_LOCALE (__current_locale_t()) +#define C_LOCALE (__posix_locale_t()) #endif