diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/misc/ctype/ctype.c | 6 | ||||
-rw-r--r-- | libc/misc/locale/locale.c | 30 | ||||
-rw-r--r-- | libc/misc/wchar/wchar.c | 18 | ||||
-rw-r--r-- | libc/misc/wctype/_wctype.c | 20 | ||||
-rw-r--r-- | libc/stdio/_fpmaxtostr.c | 12 | ||||
-rw-r--r-- | libc/stdio/_scanf.c | 16 | ||||
-rw-r--r-- | libc/stdio/_uintmaxtostr.c | 26 | ||||
-rw-r--r-- | libc/stdio/_vfprintf.c | 6 | ||||
-rw-r--r-- | libc/stdlib/stdlib.c | 4 | ||||
-rw-r--r-- | libc/string/_collate.c | 2 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/uClibc_locale.h | 103 |
11 files changed, 114 insertions, 129 deletions
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c index 8d20a39cf..a98d345d8 100644 --- a/libc/misc/ctype/ctype.c +++ b/libc/misc/ctype/ctype.c @@ -433,7 +433,7 @@ int isctype(int c, int mask) const __ctype_mask_t **__ctype_b_loc(void) { - return &(__UCLIBC_CURLOCALE_DATA).__ctype_b; + return &(__UCLIBC_CURLOCALE->__ctype_b); } libc_hidden_def(__ctype_b_loc) @@ -448,7 +448,7 @@ libc_hidden_def(__ctype_b_loc) /* libc_hidden_proto(__ctype_tolower_loc) */ const __ctype_touplow_t **__ctype_tolower_loc(void) { - return &(__UCLIBC_CURLOCALE_DATA).__ctype_tolower; + return &(__UCLIBC_CURLOCALE->__ctype_tolower); } libc_hidden_def(__ctype_tolower_loc) @@ -463,7 +463,7 @@ libc_hidden_def(__ctype_tolower_loc) /* libc_hidden_proto(__ctype_toupper_loc) */ const __ctype_touplow_t **__ctype_toupper_loc(void) { - return &(__UCLIBC_CURLOCALE_DATA).__ctype_toupper; + return &(__UCLIBC_CURLOCALE->__ctype_toupper); } libc_hidden_def(__ctype_toupper_loc) diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c index a2a898fdd..ec6189279 100644 --- a/libc/misc/locale/locale.c +++ b/libc/misc/locale/locale.c @@ -340,7 +340,7 @@ static struct lconv the_lconv; struct lconv *localeconv(void) { register char *p = (char *) &the_lconv; - register char **q = (char **) &(__UCLIBC_CURLOCALE_DATA).decimal_point; + register char **q = (char **) &(__UCLIBC_CURLOCALE->decimal_point); do { *((char **)p) = *q; @@ -373,7 +373,7 @@ libc_hidden_def(localeconv) /* libc_hidden_proto(__ctype_toupper) */ #endif -__uclibc_locale_t __global_locale_data; +struct __uclibc_locale_struct __global_locale_data; __locale_t __global_locale = &__global_locale_data; @@ -881,12 +881,12 @@ void attribute_hidden _locale_init_l(__locale_t base) LC_ALL); ++base->category_item_count[0]; /* Increment for codeset entry. */ - base->category_offsets[0] = offsetof(__uclibc_locale_t, outdigit0_mb); - base->category_offsets[1] = offsetof(__uclibc_locale_t, decimal_point); - base->category_offsets[2] = offsetof(__uclibc_locale_t, int_curr_symbol); - base->category_offsets[3] = offsetof(__uclibc_locale_t, abday_1); -/* base->category_offsets[4] = offsetof(__uclibc_locale_t, collate???); */ - base->category_offsets[5] = offsetof(__uclibc_locale_t, yesexpr); + base->category_offsets[0] = offsetof(struct __uclibc_locale_struct, outdigit0_mb); + base->category_offsets[1] = offsetof(struct __uclibc_locale_struct, decimal_point); + base->category_offsets[2] = offsetof(struct __uclibc_locale_struct, int_curr_symbol); + base->category_offsets[3] = offsetof(struct __uclibc_locale_struct, abday_1); +/* base->category_offsets[4] = offsetof(struct __uclibc_locale_struct, collate???); */ + base->category_offsets[5] = offsetof(struct __uclibc_locale_struct, yesexpr); #ifdef __CTYPE_HAS_8_BIT_LOCALES base->tbl8ctype @@ -1321,7 +1321,7 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base) } #else if (!base) { - base = malloc(sizeof(__uclibc_locale_t)); + base = malloc(sizeof(struct __uclibc_locale_struct)); if (base == NULL) return base; _locale_init_l(base); @@ -1352,12 +1352,12 @@ __locale_t duplocale(__locale_t dataset) assert(dataset != LC_GLOBAL_LOCALE); - if ((r = malloc(sizeof(__uclibc_locale_t))) != NULL) { - n = 2*dataset->collate.max_col_index+2; - if ((i2w = calloc(n, sizeof(uint16_t))) - != NULL - ) { - memcpy(r, dataset, sizeof(__uclibc_locale_t)); + r = malloc(sizeof(struct __uclibc_locale_struct)); + if (r != NULL) { + n = 2 * dataset->collate.max_col_index + 2; + i2w = calloc(n, sizeof(uint16_t)); + if (i2w != NULL) { + memcpy(r, dataset, sizeof(struct __uclibc_locale_struct)); r->collate.index2weight = i2w; memcpy(i2w, dataset->collate.index2weight, n * sizeof(uint16_t)); } else { diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c index 9bdaafe90..d921e4363 100644 --- a/libc/misc/wchar/wchar.c +++ b/libc/misc/wchar/wchar.c @@ -119,7 +119,7 @@ #endif #endif /* __UCLIBC_MJN3_ONLY__ */ -#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding) +#define ENCODING (__UCLIBC_CURLOCALE->encoding) #define Cc2wc_IDX_SHIFT __LOCALE_DATA_Cc2wc_IDX_SHIFT #define Cc2wc_ROW_LEN __LOCALE_DATA_Cc2wc_ROW_LEN @@ -752,8 +752,8 @@ size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, while (count) { if ((wc = ((unsigned char)(*s))) >= 0x80) { /* Non-ASCII... */ wc -= 0x80; - wc = __UCLIBC_CURLOCALE_DATA.tbl8c2wc[ - (__UCLIBC_CURLOCALE_DATA.idx8c2wc[wc >> Cc2wc_IDX_SHIFT] + wc = __UCLIBC_CURLOCALE->tbl8c2wc[ + (__UCLIBC_CURLOCALE->idx8c2wc[wc >> Cc2wc_IDX_SHIFT] << Cc2wc_IDX_SHIFT) + (wc & (Cc2wc_ROW_LEN - 1))]; if (!wc) { goto BAD; @@ -863,12 +863,12 @@ size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, } else { u = 0; if (wc <= Cwc2c_DOMAIN_MAX) { - u = __UCLIBC_CURLOCALE_DATA.idx8wc2c[wc >> (Cwc2c_TI_SHIFT + u = __UCLIBC_CURLOCALE->idx8wc2c[wc >> (Cwc2c_TI_SHIFT + Cwc2c_TT_SHIFT)]; - u = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[(u << Cwc2c_TI_SHIFT) + u = __UCLIBC_CURLOCALE->tbl8wc2c[(u << Cwc2c_TI_SHIFT) + ((wc >> Cwc2c_TT_SHIFT) & ((1 << Cwc2c_TI_SHIFT)-1))]; - u = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[Cwc2c_TI_LEN + u = __UCLIBC_CURLOCALE->tbl8wc2c[Cwc2c_TI_LEN + (u << Cwc2c_TT_SHIFT) + (wc & ((1 << Cwc2c_TT_SHIFT)-1))]; } @@ -1468,7 +1468,7 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf, const __codeset_8_bit_t *c8b = __locale_mmap->codeset_8_bit + px->fromcodeset - 3; wc -= 0x80; - wc = __UCLIBC_CURLOCALE_DATA.tbl8c2wc[ + wc = __UCLIBC_CURLOCALE->tbl8c2wc[ (c8b->idx8c2wc[wc >> Cc2wc_IDX_SHIFT] << Cc2wc_IDX_SHIFT) + (wc & (Cc2wc_ROW_LEN - 1))]; if (!wc) { @@ -1553,10 +1553,10 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf, = __locale_mmap->codeset_8_bit + px->tocodeset - 3; __uwchar_t u; u = c8b->idx8wc2c[wc >> (Cwc2c_TI_SHIFT + Cwc2c_TT_SHIFT)]; - u = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[(u << Cwc2c_TI_SHIFT) + u = __UCLIBC_CURLOCALE->tbl8wc2c[(u << Cwc2c_TI_SHIFT) + ((wc >> Cwc2c_TT_SHIFT) & ((1 << Cwc2c_TI_SHIFT)-1))]; - wc = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[Cwc2c_TI_LEN + wc = __UCLIBC_CURLOCALE->tbl8wc2c[Cwc2c_TI_LEN + (u << Cwc2c_TT_SHIFT) + (wc & ((1 << Cwc2c_TT_SHIFT)-1))]; if (wc) { diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c index c6f536d91..0f3201d49 100644 --- a/libc/misc/wctype/_wctype.c +++ b/libc/misc/wctype/_wctype.c @@ -123,12 +123,12 @@ enum { #endif #endif /* __UCLIBC_MJN3_ONLY__ */ -#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding) +#define ENCODING (__UCLIBC_CURLOCALE->encoding) -#define WCctype ((__UCLIBC_CURLOCALE_DATA).tblwctype) -#define WCuplow ((__UCLIBC_CURLOCALE_DATA).tblwuplow) -#define WCcmob ((__UCLIBC_CURLOCALE_DATA).tblwcomb) -#define WCuplow_diff ((__UCLIBC_CURLOCALE_DATA).tblwuplow_diff) +#define WCctype (__UCLIBC_CURLOCALE->tblwctype) +#define WCuplow (__UCLIBC_CURLOCALE->tblwuplow) +#define WCcmob (__UCLIBC_CURLOCALE->tblwcomb) +#define WCuplow_diff (__UCLIBC_CURLOCALE->tblwuplow_diff) #define WC_TABLE_DOMAIN_MAX __LOCALE_DATA_WC_TABLE_DOMAIN_MAX @@ -256,9 +256,7 @@ ISW_FUNC_BODY(xdigit); #define TOWLOWER(w) towlower(w) #else /* L_towlower */ #define TOWLOWER(w) towlower_l(w, __locale_t locale) -#undef __UCLIBC_CURLOCALE_DATA #undef __UCLIBC_CURLOCALE -#define __UCLIBC_CURLOCALE_DATA (*locale) #define __UCLIBC_CURLOCALE (locale) #endif /* L_towlower */ @@ -363,9 +361,7 @@ libc_hidden_def(towlower) #define TOWUPPER(w) towupper(w) #else /* L_towupper */ #define TOWUPPER(w) towupper_l(w, __locale_t locale) -#undef __UCLIBC_CURLOCALE_DATA #undef __UCLIBC_CURLOCALE -#define __UCLIBC_CURLOCALE_DATA (*locale) #define __UCLIBC_CURLOCALE (locale) #endif /* L_towupper */ @@ -619,9 +615,7 @@ int iswctype(wint_t wc, wctype_t desc) #define ISWCTYPE(w,d) iswctype(w,d) #else /* L_iswctype */ #define ISWCTYPE(w,d) iswctype_l(w,d, __locale_t locale) -#undef __UCLIBC_CURLOCALE_DATA #undef __UCLIBC_CURLOCALE -#define __UCLIBC_CURLOCALE_DATA (*locale) #define __UCLIBC_CURLOCALE (locale) #endif /* L_iswctype */ @@ -668,7 +662,7 @@ int ISWCTYPE(wint_t wc, wctype_t desc) <= ctype_range[2*desc + 1] ) && ((desc != _CTYPE_iswblank) || (d & 1)); #else - return (__UCLIBC_CURLOCALE_DATA).code2flag[d] & desc2flag[desc]; + return __UCLIBC_CURLOCALE->code2flag[d] & desc2flag[desc]; #endif } @@ -728,9 +722,7 @@ wint_t towctrans(wint_t wc, wctrans_t desc) #define TOWCTRANS(w,d) towctrans(w,d) #else /* L_towctrans */ #define TOWCTRANS(w,d) towctrans_l(w,d, __locale_t locale) -#undef __UCLIBC_CURLOCALE_DATA #undef __UCLIBC_CURLOCALE -#define __UCLIBC_CURLOCALE_DATA (*locale) #define __UCLIBC_CURLOCALE (locale) #endif /* L_towctrans */ diff --git a/libc/stdio/_fpmaxtostr.c b/libc/stdio/_fpmaxtostr.c index b8d93a091..0aab23364 100644 --- a/libc/stdio/_fpmaxtostr.c +++ b/libc/stdio/_fpmaxtostr.c @@ -501,8 +501,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info, const char *p; if (PRINT_INFO_FLAG_VAL(info,group) - && *(p = __UCLIBC_CURLOCALE_DATA.grouping) - ) { + && *(p = __UCLIBC_CURLOCALE->grouping) + ) { int nblk1; nblk2 = nblk1 = *p; @@ -522,8 +522,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info, tslen = 1; } else { #endif /* __UCLIBC_HAS_WCHAR__ */ - ts = __UCLIBC_CURLOCALE_DATA.thousands_sep; - tslen = __UCLIBC_CURLOCALE_DATA.thousands_sep_len; + ts = __UCLIBC_CURLOCALE->thousands_sep; + tslen = __UCLIBC_CURLOCALE->thousands_sep_len; #ifdef __UCLIBC_HAS_WCHAR__ } #endif /* __UCLIBC_HAS_WCHAR__ */ @@ -576,8 +576,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info, ppc[2] = (intptr_t)(fmt + DECPT_OFFSET); } else { #endif /* __UCLIBC_HAS_WCHAR__ */ - ppc[1] = __UCLIBC_CURLOCALE_DATA.decimal_point_len; - ppc[2] = (intptr_t)(__UCLIBC_CURLOCALE_DATA.decimal_point); + ppc[1] = __UCLIBC_CURLOCALE->decimal_point_len; + ppc[2] = (intptr_t)(__UCLIBC_CURLOCALE->decimal_point); #ifdef __UCLIBC_HAS_WCHAR__ } #endif /* __UCLIBC_HAS_WCHAR__ */ diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c index 1fa6208d4..9189a52e1 100644 --- a/libc/stdio/_scanf.c +++ b/libc/stdio/_scanf.c @@ -717,26 +717,26 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc, #endif /* __UCLIBC_HAS_WCHAR__ */ #ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ - if (*(sc->grouping = __UCLIBC_CURLOCALE_DATA.grouping)) { - sc->thousands_sep = (const unsigned char *) __UCLIBC_CURLOCALE_DATA.thousands_sep; - sc->tslen = __UCLIBC_CURLOCALE_DATA.thousands_sep_len; + if (*(sc->grouping = __UCLIBC_CURLOCALE->grouping)) { + sc->thousands_sep = (const unsigned char *) __UCLIBC_CURLOCALE->thousands_sep; + sc->tslen = __UCLIBC_CURLOCALE->thousands_sep_len; #ifdef __UCLIBC_HAS_WCHAR__ - sc->thousands_sep_wc = __UCLIBC_CURLOCALE_DATA.thousands_sep_wc; + sc->thousands_sep_wc = __UCLIBC_CURLOCALE->thousands_sep_wc; #endif /* __UCLIBC_HAS_WCHAR__ */ } #endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */ #ifdef __UCLIBC_HAS_FLOATS__ #ifdef __UCLIBC_HAS_LOCALE__ - sc->decpt = (const unsigned char *) __UCLIBC_CURLOCALE_DATA.decimal_point; - sc->decpt_len = __UCLIBC_CURLOCALE_DATA.decimal_point_len; + sc->decpt = (const unsigned char *) __UCLIBC_CURLOCALE->decimal_point; + sc->decpt_len = __UCLIBC_CURLOCALE->decimal_point_len; #else /* __UCLIBC_HAS_LOCALE__ */ sc->fake_decpt = sc->decpt = (unsigned char *) decpt_str; sc->decpt_len = 1; #endif /* __UCLIBC_HAS_LOCALE__ */ #ifdef __UCLIBC_HAS_WCHAR__ #ifdef __UCLIBC_HAS_LOCALE__ - sc->decpt_wc = __UCLIBC_CURLOCALE_DATA.decimal_point_wc; + sc->decpt_wc = __UCLIBC_CURLOCALE->decimal_point_wc; #else sc->decpt_wc = '.'; #endif @@ -1193,7 +1193,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) #if defined(__UCLIBC_HAS_LOCALE__) && !defined(L_vfwscanf) /* ANSI/ISO C99 requires format string to be a valid multibyte string * beginning and ending in its initial shift state. */ - if (((__UCLIBC_CURLOCALE_DATA).encoding) != __ctype_encoding_7_bit) { + if (__UCLIBC_CURLOCALE->encoding != __ctype_encoding_7_bit) { const char *p = format; mbstate.__mask = 0; /* Initialize the mbstate. */ if (mbsrtowcs(NULL, &p, SIZE_MAX, &mbstate) == ((size_t)(-1))) { diff --git a/libc/stdio/_uintmaxtostr.c b/libc/stdio/_uintmaxtostr.c index 0d25a0a9f..086f6abd1 100644 --- a/libc/stdio/_uintmaxtostr.c +++ b/libc/stdio/_uintmaxtostr.c @@ -50,7 +50,7 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_ alphacase ^= outdigit; if (alphacase == __UIM_GROUP) { assert(base == 10); - if (*(g = __UCLIBC_CURLOCALE_DATA.grouping)) { + if (*(g = __UCLIBC_CURLOCALE->grouping)) { grouping = *g; } } @@ -62,9 +62,9 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_ do { #ifndef __LOCALE_C_ONLY if (!grouping) { /* Finished a group. */ - bufend -= __UCLIBC_CURLOCALE_DATA.thousands_sep_len; - memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep, - __UCLIBC_CURLOCALE_DATA.thousands_sep_len); + bufend -= __UCLIBC_CURLOCALE->thousands_sep_len; + memcpy(bufend, __UCLIBC_CURLOCALE->thousands_sep, + __UCLIBC_CURLOCALE->thousands_sep_len); if (g[1] != 0) { /* g[1] == 0 means repeat last grouping. */ /* Note: g[1] == -1 means no further grouping. But since * we'll never wrap around, we can set grouping to -1 without @@ -80,10 +80,10 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_ #ifndef __LOCALE_C_ONLY if (unlikely(outdigit)) { - bufend -= __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]; + bufend -= __UCLIBC_CURLOCALE->outdigit_length[digit]; memcpy(bufend, - (&__UCLIBC_CURLOCALE_DATA.outdigit0_mb)[digit], - __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]); + (&__UCLIBC_CURLOCALE->outdigit0_mb)[digit], + __UCLIBC_CURLOCALE->outdigit_length[digit]); } else #endif { @@ -105,9 +105,9 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_ do { #ifndef __LOCALE_C_ONLY if (!grouping) { /* Finished a group. */ - bufend -= __UCLIBC_CURLOCALE_DATA.thousands_sep_len; - memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep, - __UCLIBC_CURLOCALE_DATA.thousands_sep_len); + bufend -= __UCLIBC_CURLOCALE->thousands_sep_len; + memcpy(bufend, __UCLIBC_CURLOCALE->thousands_sep, + __UCLIBC_CURLOCALE->thousands_sep_len); if (g[1] != 0) { /* g[1] == 0 means repeat last grouping. */ /* Note: g[1] == -1 means no further grouping. But since * we'll never wrap around, we can set grouping to -1 without @@ -132,10 +132,10 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_ #ifndef __LOCALE_C_ONLY if (unlikely(outdigit)) { - bufend -= __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]; + bufend -= __UCLIBC_CURLOCALE->outdigit_length[digit]; memcpy(bufend, - (&__UCLIBC_CURLOCALE_DATA.outdigit0_mb)[digit], - __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]); + (&__UCLIBC_CURLOCALE->outdigit0_mb)[digit], + __UCLIBC_CURLOCALE->outdigit_length[digit]); } else #endif { diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c index 850c83486..c9d0f6bb9 100644 --- a/libc/stdio/_vfprintf.c +++ b/libc/stdio/_vfprintf.c @@ -525,7 +525,7 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0) #endif #ifdef __UCLIBC_HAS_LOCALE__ /* To support old programs, don't check mb validity if in C locale. */ - if (((__UCLIBC_CURLOCALE_DATA).encoding) != __ctype_encoding_7_bit) { + if (__UCLIBC_CURLOCALE->encoding != __ctype_encoding_7_bit) { /* ANSI/ISO C99 requires format string to be a valid multibyte string * beginning and ending in its initial shift state. */ static const char invalid_mbs[] = "Invalid multibyte format string."; @@ -1314,11 +1314,11 @@ static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf) #ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ if (s[i] == ',') { - wbuf[i] = __UCLIBC_CURLOCALE_DATA.thousands_sep_wc; + wbuf[i] = __UCLIBC_CURLOCALE->thousands_sep_wc; } else #endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */ if (s[i] == '.') { - wbuf[i] = __UCLIBC_CURLOCALE_DATA.decimal_point_wc; + wbuf[i] = __UCLIBC_CURLOCALE->decimal_point_wc; } else { wbuf[i] = s[i]; } diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c index 7202182d9..ef92ea4fd 100644 --- a/libc/stdlib/stdlib.c +++ b/libc/stdlib/stdlib.c @@ -114,7 +114,7 @@ #ifdef __UCLIBC_HAS_LOCALE__ -#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding) +#define ENCODING (__UCLIBC_CURLOCALE->encoding) #ifndef __CTYPE_HAS_UTF_8_LOCALES #ifdef L_mblen /* emit only once */ @@ -916,7 +916,7 @@ void ssort(void *base, size_t _stdlib_mb_cur_max(void) { #ifdef __CTYPE_HAS_UTF_8_LOCALES - return __UCLIBC_CURLOCALE_DATA.mb_cur_max; + return __UCLIBC_CURLOCALE->mb_cur_max; #else #ifdef __CTYPE_HAS_8_BIT_LOCALES #ifdef __UCLIBC_MJN3_ONLY__ diff --git a/libc/string/_collate.c b/libc/string/_collate.c index 3c53404ad..9cc9ed055 100644 --- a/libc/string/_collate.c +++ b/libc/string/_collate.c @@ -81,7 +81,7 @@ libc_hidden_def(wcsxfrm) #if 0 -#define CUR_COLLATE (&__UCLIBC_CURLOCALE_DATA.collate) +#define CUR_COLLATE (&__UCLIBC_CURLOCALE->collate) #else #define CUR_COLLATE (& __LOCALE_PTR->collate) #endif diff --git a/libc/sysdeps/linux/common/bits/uClibc_locale.h b/libc/sysdeps/linux/common/bits/uClibc_locale.h index 39ed97959..9790da29d 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_locale.h +++ b/libc/sysdeps/linux/common/bits/uClibc_locale.h @@ -35,49 +35,38 @@ #ifdef __UCLIBC_HAS_LOCALE__ -#undef __LOCALE_C_ONLY +# undef __LOCALE_C_ONLY -#else /* __UCLIBC_HAS_LOCALE__ */ +#else -#define __LOCALE_C_ONLY +# define __LOCALE_C_ONLY -#define __XL_NPP(N) N -#define __LOCALE_PARAM -#define __LOCALE_ARG +# ifdef _LIBC +# define __XL_NPP(N) N +# define __LOCALE_PARAM +# define __LOCALE_ARG +# endif -#endif /* __UCLIBC_HAS_LOCALE__ */ +#endif /**********************************************************************/ -#define __NL_ITEM_CATEGORY_SHIFT (8) -#define __NL_ITEM_INDEX_MASK (0xff) +#define __NL_ITEM_CATEGORY_SHIFT 8 +#define __NL_ITEM_INDEX_MASK 0xff /* TODO: Make sure these agree with the locale mmap file gererator! */ -#define __LC_CTYPE 0 -#define __LC_NUMERIC 1 -#define __LC_MONETARY 2 -#define __LC_TIME 3 -#define __LC_COLLATE 4 -#define __LC_MESSAGES 5 -#define __LC_ALL 6 +#define __LC_CTYPE 0 +#define __LC_NUMERIC 1 +#define __LC_MONETARY 2 +#define __LC_TIME 3 +#define __LC_COLLATE 4 +#define __LC_MESSAGES 5 +#define __LC_ALL 6 /**********************************************************************/ #ifndef __LOCALE_C_ONLY -#if defined _LIBC /* && (defined IS_IN_libc || defined NOT_IN_libc) */ -#include <stddef.h> -#include <stdint.h> -#include <bits/uClibc_touplow.h> - -#ifndef __UCLIBC_GEN_LOCALE -#include <bits/uClibc_locale_data.h> -#endif -#endif - -/* extern void _locale_set(const unsigned char *p); */ -/* extern void _locale_init(void); */ - enum { __ctype_encoding_7_bit, /* C/POSIX */ __ctype_encoding_utf8, /* UTF-8 */ @@ -98,7 +87,21 @@ enum { * In particular, C/POSIX locale is '#' + "\x80\x01"}*LC_ALL + nul. */ +struct __uclibc_locale_struct; +typedef struct __uclibc_locale_struct *__locale_t; + #ifdef _LIBC + +/* extern void _locale_set(const unsigned char *p); */ +/* extern void _locale_init(void); */ + +#include <stddef.h> +#include <stdint.h> +#include <bits/uClibc_touplow.h> +#ifndef __UCLIBC_GEN_LOCALE +# include <bits/uClibc_locale_data.h> +#endif + #ifndef __UCLIBC_GEN_LOCALE /* && (defined IS_IN_libc || defined NOT_IN_libc) */ typedef struct { uint16_t num_weights; @@ -140,10 +143,9 @@ typedef struct { uint16_t MAX_WEIGHTS; } __collate_t; - /* static unsigned char cur_locale[LOCALE_STRING_SIZE]; */ -typedef struct __uclibc_locale_struct { +struct __uclibc_locale_struct { #ifdef __UCLIBC_HAS_XLOCALE__ const __ctype_mask_t *__ctype_b; const __ctype_touplow_t *__ctype_tolower; @@ -176,13 +178,13 @@ typedef struct __uclibc_locale_struct { const unsigned char *tbl8ctype; const unsigned char *idx8uplow; const unsigned char *tbl8uplow; -#ifdef __UCLIBC_HAS_WCHAR__ +# ifdef __UCLIBC_HAS_WCHAR__ const unsigned char *idx8c2wc; const uint16_t *tbl8c2wc; /* char > 0x7f to wide char */ const unsigned char *idx8wc2c; const unsigned char *tbl8wc2c; /* translit */ -#endif /* __UCLIBC_HAS_WCHAR__ */ +# endif #endif /* __CTYPE_HAS_8_BIT_LOCALES */ #ifdef __UCLIBC_HAS_WCHAR__ @@ -310,19 +312,16 @@ typedef struct __uclibc_locale_struct { /* collate is at the end */ __collate_t collate; +}; -} __uclibc_locale_t; - -extern __uclibc_locale_t __global_locale_data; +extern struct __uclibc_locale_struct __global_locale_data; +extern struct __uclibc_locale_struct *__global_locale; #endif /* !__UCLIBC_GEN_LOCALE */ -#endif /* _LIBC */ - -extern struct __uclibc_locale_struct * __global_locale; -typedef struct __uclibc_locale_struct *__locale_t; - -/* if we need to leave only _LIBC, then attribute_hidden is not usable */ -#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +#if defined IS_IN_libc || defined NOT_IN_libc +/* If you plan to remove xxx_IN_libc guards, + * remove attribute_hidden, it won't work. + */ extern int __locale_mbrtowc_l(wchar_t *__restrict dst, const char *__restrict src, __locale_t loc) attribute_hidden; @@ -332,29 +331,22 @@ extern int __locale_mbrtowc_l(wchar_t *__restrict dst, /* so we only get the warning once... */ #warning need thread version of CUR_LOCALE! #endif + /**********************************************************************/ #ifdef __UCLIBC_HAS_XLOCALE__ extern __locale_t __curlocale_var; - # ifdef __UCLIBC_HAS_THREADS__ - extern __locale_t __curlocale(void) __THROW __attribute__ ((__const__)); extern __locale_t __curlocale_set(__locale_t newloc); -# define __UCLIBC_CURLOCALE (__curlocale()) -# define __UCLIBC_CURLOCALE_DATA (*__curlocale()) - +# define __UCLIBC_CURLOCALE (__curlocale()) # else - -# define __UCLIBC_CURLOCALE (__curlocale_var) -# define __UCLIBC_CURLOCALE_DATA (*__curlocale_var) - +# define __UCLIBC_CURLOCALE (__curlocale_var) # endif #elif defined(__UCLIBC_HAS_LOCALE__) -# define __UCLIBC_CURLOCALE (__global_locale) -# define __UCLIBC_CURLOCALE_DATA (*__global_locale) +# define __UCLIBC_CURLOCALE (__global_locale) #endif /**********************************************************************/ @@ -375,7 +367,8 @@ extern __locale_t __curlocale_set(__locale_t newloc); #endif /**********************************************************************/ +#endif /* _LIBC */ + #endif /* !defined(__LOCALE_C_ONLY) */ -/**********************************************************************/ #endif /* _UCLIBC_LOCALE_H */ |