const struct __locale_map *next;
};
+extern const struct __locale_map __c_dot_utf8;
+extern const struct __locale_struct __c_locale;
+extern const struct __locale_struct __c_dot_utf8_locale;
+
const struct __locale_map *__get_locale(int, const char *);
const char *__mo_lookup(const void *, size_t, const char *);
const char *__lctrans(const char *, const struct __locale_map *);
#define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)])
#define LCTRANS_CUR(msg) __lctrans_cur(msg)
+#define C_LOCALE ((locale_t)&__c_locale)
+#define UTF8_LOCALE ((locale_t)&__c_dot_utf8_locale)
+
#define CURRENT_LOCALE (__pthread_self()->locale)
#define CURRENT_UTF8 (!!__pthread_self()->locale->cat[LC_CTYPE])
--- /dev/null
+#include "locale_impl.h"
+#include <stdint.h>
+
+static const uint32_t empty_mo[] = { 0x950412de, 0, -1, -1, -1 };
+
+const struct __locale_map __c_dot_utf8 = {
+ .map = empty_mo,
+ .map_size = sizeof empty_mo,
+ .name = "C.UTF-8"
+};
+
+const struct __locale_struct __c_locale = { 0 };
+const struct __locale_struct __c_dot_utf8_locale = {
+ .cat[LC_CTYPE] = &__c_dot_utf8
+};
"LC_MESSAGES",
};
-static const uint32_t empty_mo[] = { 0x950412de, 0, -1, -1, -1 };
-
-const struct __locale_map __c_dot_utf8 = {
- .map = empty_mo,
- .map_size = sizeof empty_mo,
- .name = "C.UTF-8"
-};
-
const struct __locale_map *__get_locale(int cat, const char *val)
{
static int lock[2];
* sake of being able to do message translations at the
* application level. */
if (!new && (new = malloc(sizeof *new))) {
- new->map = empty_mo;
- new->map_size = sizeof empty_mo;
+ new->map = __c_dot_utf8.map;
+ new->map_size = __c_dot_utf8.map_size;
memcpy(new->name, val, n);
new->name[n] = 0;
new->next = loc_head;
#include "locale_impl.h"
#include "libc.h"
-extern const struct __locale_map __c_dot_utf8;
-
-static const struct __locale_struct c_locale = { 0 };
-static const struct __locale_struct c_dot_utf8_locale = {
- .cat[LC_CTYPE] = &__c_dot_utf8
-};
-
int __loc_is_allocated(locale_t loc)
{
- return loc && loc != &c_locale && loc != &c_dot_utf8_locale;
+ return loc && loc != C_LOCALE && loc != UTF8_LOCALE;
}
locale_t __newlocale(int mask, const char *name, locale_t loc)
}
if (!j)
- return (locale_t)&c_locale;
- if (j==1 && tmp.cat[LC_CTYPE]==c_dot_utf8_locale.cat[LC_CTYPE])
- return (locale_t)&c_dot_utf8_locale;
+ return C_LOCALE;
+ if (j==1 && tmp.cat[LC_CTYPE]==&__c_dot_utf8)
+ return UTF8_LOCALE;
if ((loc = malloc(sizeof *loc))) *loc = tmp;