OLD | NEW |
---|---|
1 #include <locale.h> | 1 #include <locale.h> |
2 #include <string.h> | 2 #include <string.h> |
3 #include "locale_impl.h" | 3 #include "locale_impl.h" |
4 #include "libc.h" | 4 #include "libc.h" |
5 #include "atomic.h" | 5 #include "atomic.h" |
6 | 6 |
7 const char *__lctrans_impl(const char *msg, const struct __locale_map *lm) | 7 const char *__lctrans_impl(const char *msg, const struct __locale_map *lm) |
8 { | 8 { |
9 const char *trans = 0; | 9 const char *trans = 0; |
10 if (lm) trans = __mo_lookup(lm->map, lm->map_size, msg); | 10 if (lm) trans = __mo_lookup(lm->map, lm->map_size, msg); |
(...skipping 17 matching lines...) Expand all Loading... | |
28 { | 28 { |
29 static int lock[2]; | 29 static int lock[2]; |
30 static void *volatile loc_head; | 30 static void *volatile loc_head; |
31 const struct __locale_map *p; | 31 const struct __locale_map *p; |
32 struct __locale_map *new = 0; | 32 struct __locale_map *new = 0; |
33 const char *path = 0, *z; | 33 const char *path = 0, *z; |
34 char buf[256]; | 34 char buf[256]; |
35 size_t l, n; | 35 size_t l, n; |
36 | 36 |
37 if (!*val) { | 37 if (!*val) { |
38 » » (val = getenv("LC_ALL")) && *val || | 38 » » ((val = getenv("LC_ALL")) && *val) || |
viettrungluu
2016/01/12 18:43:18
This makes me puke in my mouth....
| |
39 » » (val = getenv(envvars[cat])) && *val || | 39 » » ((val = getenv(envvars[cat])) && *val) || |
40 » » (val = getenv("LANG")) && *val || | 40 » » ((val = getenv("LANG")) && *val) || |
41 (val = "C.UTF-8"); | 41 (val = "C.UTF-8"); |
42 } | 42 } |
43 | 43 |
44 /* Limit name length and forbid leading dot or any slashes. */ | 44 /* Limit name length and forbid leading dot or any slashes. */ |
45 for (n=0; n<LOCALE_NAME_MAX && val[n] && val[n]!='/'; n++); | 45 for (n=0; n<LOCALE_NAME_MAX && val[n] && val[n]!='/'; n++); |
46 if (val[0]=='.' || val[n]) val = "C.UTF-8"; | 46 if (val[0]=='.' || val[n]) val = "C.UTF-8"; |
47 int builtin = (val[0]=='C' && !val[1]) | 47 int builtin = (val[0]=='C' && !val[1]) |
48 || !strcmp(val, "C.UTF-8") | 48 || !strcmp(val, "C.UTF-8") |
49 || !strcmp(val, "POSIX"); | 49 || !strcmp(val, "POSIX"); |
50 | 50 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 loc_head = new; | 107 loc_head = new; |
108 } | 108 } |
109 | 109 |
110 /* For LC_CTYPE, never return a null pointer unless the | 110 /* For LC_CTYPE, never return a null pointer unless the |
111 * requested name was "C" or "POSIX". */ | 111 * requested name was "C" or "POSIX". */ |
112 if (!new && cat == LC_CTYPE) new = (void *)&__c_dot_utf8; | 112 if (!new && cat == LC_CTYPE) new = (void *)&__c_dot_utf8; |
113 | 113 |
114 UNLOCK(lock); | 114 UNLOCK(lock); |
115 return new; | 115 return new; |
116 } | 116 } |
OLD | NEW |