diff options
Diffstat (limited to 'src/locale/newlocale.c')
-rw-r--r-- | src/locale/newlocale.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c index 447c8fc2..39501d0c 100644 --- a/src/locale/newlocale.c +++ b/src/locale/newlocale.c @@ -3,12 +3,24 @@ #include "locale_impl.h" #include "libc.h" -locale_t newlocale(int mask, const char *name, locale_t base) +locale_t __newlocale(int mask, const char *name, locale_t loc) { - if (*name && strcmp(name, "C") && strcmp(name, "POSIX")) - return 0; - if (!base) base = calloc(1, sizeof *base); - return base; + int i; + + if (!loc) { + loc = calloc(1, sizeof *loc + LOCALE_NAME_MAX + 1); + if (!loc) return 0; + loc->messages_name = (void *)(loc+1); + for (i=0; i<LC_ALL; i++) + if (!(mask & (1<<i))) + __setlocalecat(loc, i, ""); + } + + for (i=0; i<LC_ALL; i++) + if (mask & (1<<i)) + __setlocalecat(loc, i, name); + + return loc; } -weak_alias(newlocale, __newlocale); +weak_alias(__newlocale, newlocale); |