X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Flocale%2Fsetlocale.c;h=360c4437644b88f86ac8b9f0db5d92915019c8d7;hb=8ef9d46f4d0ff4f0073da6bee7ed0cb5f9035ead;hp=60e3353c9a7ac962cf5c94fa9fcb2d59251829eb;hpb=13d1afa46f8098df290008c681816c9eb89ffbdb;p=musl diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c index 60e3353c..360c4437 100644 --- a/src/locale/setlocale.c +++ b/src/locale/setlocale.c @@ -3,27 +3,17 @@ #include #include "locale_impl.h" #include "libc.h" -#include "atomic.h" +#include "lock.h" static char buf[LC_ALL*(LOCALE_NAME_MAX+1)]; -static char *setlocale_one_unlocked(int cat, const char *name) -{ - const struct __locale_map *lm; - - if (name) libc.global_locale.cat[cat] = lm = __get_locale(cat, name); - else lm = libc.global_locale.cat[cat]; - - return lm ? (char *)lm->name : "C"; -} - char *setlocale(int cat, const char *name) { - static volatile int lock[1]; + const struct __locale_map *lm; if ((unsigned)cat > LC_ALL) return 0; - LOCK(lock); + LOCK(__locale_lock); /* For LC_ALL, setlocale is required to return a string which * encodes the current setting for all categories. The format of @@ -33,6 +23,7 @@ char *setlocale(int cat, const char *name) if (cat == LC_ALL) { int i; if (name) { + struct __locale_struct tmp_locale; char part[LOCALE_NAME_MAX+1] = "C.UTF-8"; const char *p = name; for (i=0; iname : "C"; - UNLOCK(lock); + UNLOCK(__locale_lock); return ret; }