From d88e5dfa8b989dafff4b748bfb3cba3512c8482e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 20 Oct 2018 21:54:20 -0400 Subject: adapt setlocale to support possibility of failure introduce a new LOC_MAP_FAILED sentinel for errors, since null pointers for a category's locale map indicate the C locale. at this time, __get_locale does not fail, so there should be no functional change by this commit. --- src/locale/setlocale.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/locale/setlocale.c') diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c index 11d823ce..637e7aa0 100644 --- a/src/locale/setlocale.c +++ b/src/locale/setlocale.c @@ -7,19 +7,10 @@ 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; @@ -33,6 +24,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); -- cgit v1.2.1