Author: zooey Date: 2010-03-31 10:36:54 +0200 (Wed, 31 Mar 2010) New Revision: 36014 Changeset: http://dev.haiku-os.org/changeset/36014/haiku Modified: haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.h haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp Log: * all parts of the decision whether or not to load the backend have been moved into setlocale(), no need to keep them separate Modified: haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp =================================================================== --- haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp 2010-03-31 08:08:11 UTC (rev 36013) +++ haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.cpp 2010-03-31 08:36:54 UTC (rev 36014) @@ -47,19 +47,12 @@ status_t -LocaleBackend::LoadBackendIfNeededFor(const char* locale) +LocaleBackend::LoadBackend() { - // nothing to do if the backend is already loaded, or if it's a query - if (gLocaleBackend || locale == NULL) - return B_OK; + if (gLocaleBackend == NULL) + pthread_once(&sBackendInitOnce, &BPrivate::LoadBackend); - // for any locale other than POSIX/C, we try to activate the ICU backend - if (strcmp(locale, "POSIX") != 0 && strcmp(locale, "C") != 0) { - pthread_once(&sBackendInitOnce, &LoadBackend); - return gLocaleBackend != NULL ? B_OK : B_ERROR; - } - - return B_OK; + return gLocaleBackend != NULL ? B_OK : B_ERROR; } Modified: haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.h =================================================================== --- haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.h 2010-03-31 08:08:11 UTC (rev 36013) +++ haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/LocaleBackend.h 2010-03-31 08:36:54 UTC (rev 36014) @@ -23,7 +23,7 @@ virtual const char* SetLocale(int category, const char* locale) = 0; virtual struct lconv* LocaleConv() = 0; -static status_t LoadBackendIfNeededFor(const char* locale); +static status_t LoadBackend(); }; Modified: haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp =================================================================== --- haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp 2010-03-31 08:08:11 UTC (rev 36013) +++ haiku/branches/developer/zooey/posix-locale/src/system/libroot/posix/locale/setlocale.cpp 2010-03-31 08:36:54 UTC (rev 36014) @@ -56,9 +56,12 @@ if (locale && *locale == '\0') locale = LocaleAccordingToEnvironment(category); - if (!gLocaleBackend) { - if (LocaleBackend::LoadBackendIfNeededFor(locale) != B_OK) - return NULL; + // for any locale other than POSIX/C, we try to activate the ICU backend, + // unless the backend has already been loaded, or a query has been requested + if (!gLocaleBackend && locale != NULL && strcmp(locale, "POSIX") != 0 + && strcmp(locale, "C") != 0) { + if (LocaleBackend::LoadBackend() != B_OK) + return NULL; } if (gLocaleBackend)