3 #include "locale_impl.h"
5 int __loc_is_allocated(locale_t loc)
7 return loc && loc != C_LOCALE && loc != UTF8_LOCALE;
10 locale_t __newlocale(int mask, const char *name, locale_t loc)
13 struct __locale_struct tmp;
14 const struct __locale_map *lm;
16 /* For locales with allocated storage, modify in-place. */
17 if (__loc_is_allocated(loc)) {
18 for (i=0; i<LC_ALL; i++)
20 loc->cat[i] = __get_locale(i, name);
24 /* Otherwise, build a temporary locale object, which will only
25 * be instantiated in allocated storage if it does not match
26 * one of the built-in static locales. This makes the common
27 * usage case for newlocale, getting a C locale with predictable
28 * behavior, very fast, and more importantly, fail-safe. */
29 for (j=i=0; i<LC_ALL; i++) {
30 if (loc && !(mask & (1<<i)))
33 lm = __get_locale(i, mask & (1<<i) ? name : "");
40 if (j==1 && tmp.cat[LC_CTYPE]==&__c_dot_utf8)
43 if ((loc = malloc(sizeof *loc))) *loc = tmp;
48 weak_alias(__newlocale, newlocale);