diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-08-01 20:08:59 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-08-01 20:08:59 +0000 |
commit | 1217289737588e65b088b3535428b27c7287d699 (patch) | |
tree | 6a292ac767d219702e26a6a2111737f84a96900c /extra/locale | |
parent | 32b76c5ec3c257b7287913d0d1a96e0cbb2e9c6a (diff) |
Add a new *scanf implementation, includeing the *wscanf functions.
Should be standards compliant and with several optional features,
including support for hexadecimal float notation, locale awareness,
glibc-like locale-specific digit grouping with the `'' flag, and
positional arg support. I tested it pretty well (finding several
bugs in glibc's scanf in the process), but it is brand new so be
aware.
The *wprintf functions now support floating point output. Also, a
couple of bugs were squashed. Finally, %a/%A conversions are
now implemented.
Implement the glibc xlocale interface for thread-specific locale
support. Also add the various *_l(args, locale_t loc_arg) funcs.
NOTE!!! setlocale() is NOT threadsafe! NOTE!!!
The strto{floating point} conversion functions are now locale aware.
The also now support hexadecimal floating point notation.
Add the wcsto{floating point} conversion functions.
Fix a bug in mktime() related to dst. Note that unlike glibc's mktime,
uClibc's version always normalizes the struct tm before attempting
to determine the correct dst setting if tm_isdst == -1 on entry.
Add a stub version of the libintl functions. (untested)
Fixed a known memory leak in setlocale() related to the collation data.
Add lots of new config options (which Erik agreed to sort out :-),
including finally exposing some of the stripped down stdio configs.
Be careful with those though, as they haven't been tested in a
long time.
(temporary) GOTCHAs...
The ctype functions are currently incorrect for 8-bit locales. They
will be fixed shortly.
The ctype functions are now table-based, resulting in larger staticly
linked binaries. I'll be adding an option to use the old approach
in the stub locale configuration.
Diffstat (limited to 'extra/locale')
-rw-r--r-- | extra/locale/Makefile | 8 | ||||
-rw-r--r-- | extra/locale/gen_collate.c | 34 | ||||
-rw-r--r-- | extra/locale/gen_ldc.c | 78 | ||||
-rw-r--r-- | extra/locale/gen_locale.c | 62 | ||||
-rw-r--r-- | extra/locale/gen_wc8bit.c | 68 | ||||
-rw-r--r-- | extra/locale/gen_wctype.c | 18 | ||||
-rw-r--r-- | extra/locale/locale_mmap.h | 79 |
7 files changed, 180 insertions, 167 deletions
diff --git a/extra/locale/Makefile b/extra/locale/Makefile index 983c91c30..41438dadc 100644 --- a/extra/locale/Makefile +++ b/extra/locale/Makefile @@ -109,13 +109,17 @@ uClibc_locale_data.h: c8tables.h wctables.h lt_defines.h locale_mmap.h links-target: locale_data.o uClibc_locale_data.h ln -sf ../../../extra/locale/locale_data.o ../../libc/misc/locale - cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/ + cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h + +# cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/ pregen: $(CC) $(CFLAGS_mmap) -c locale_data.c $(STRIPTOOL) -x -R .note -R .comment locale_data.o ln -sf ../../../extra/locale/locale_data.o ../../libc/misc/locale - cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/ + cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h + +# cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/ clean: rm -f *.[oa] *~ core diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c index 51b6b7383..7a524c8f7 100644 --- a/extra/locale/gen_collate.c +++ b/extra/locale/gen_collate.c @@ -1274,7 +1274,7 @@ static void error_msg(const char *fmt, ...) static void pushfile(char *filename) { - static fbuf[PATH_MAX]; + static char fbuf[PATH_MAX]; snprintf(fbuf, PATH_MAX, "collation/%s", filename); @@ -2894,28 +2894,28 @@ static void finalize_base(void) unsigned int u = 0xe40; table_data *tbl = &table; -#define WCctype_TI_MASK ((1 << tbl->ti_shift)-1) -#define WCctype_TI_SHIFT (tbl->ti_shift) -#define WCctype_TI_LEN (tbl->ti_len) -#define WCctype_II_MASK ((1 << tbl->ii_shift)-1) -#define WCctype_II_SHIFT (tbl->ii_shift) -#define WCctype_II_LEN (tbl->ii_len) +#define __LOCALE_DATA_WCctype_TI_MASK ((1 << tbl->ti_shift)-1) +#define __LOCALE_DATA_WCctype_TI_SHIFT (tbl->ti_shift) +#define __LOCALE_DATA_WCctype_TI_LEN (tbl->ti_len) +#define __LOCALE_DATA_WCctype_II_MASK ((1 << tbl->ii_shift)-1) +#define __LOCALE_DATA_WCctype_II_SHIFT (tbl->ii_shift) +#define __LOCALE_DATA_WCctype_II_LEN (tbl->ii_len) - sc = u & WCctype_TI_MASK; - u >>= WCctype_TI_SHIFT; - n = u & WCctype_II_MASK; - u >>= WCctype_II_SHIFT; + sc = u & __LOCALE_DATA_WCctype_TI_MASK; + u >>= __LOCALE_DATA_WCctype_TI_SHIFT; + n = u & __LOCALE_DATA_WCctype_II_MASK; + u >>= __LOCALE_DATA_WCctype_II_SHIFT; i0 = tbl->ii[u]; fprintf(stderr, "i0 = %d\n", i0); - i0 <<= WCctype_II_SHIFT; - i1 = tbl->ii[WCctype_II_LEN + i0 + n]; + i0 <<= __LOCALE_DATA_WCctype_II_SHIFT; + i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n]; /* i1 = tbl->ti[i0 + n]; */ fprintf(stderr, "i1 = %d\n", i1); - i1 <<= WCctype_TI_SHIFT; - /* return *(uint16_t *)(&(tbl->ii[WCctype_II_LEN + WCctype_TI_LEN + i1 + sc])); */ - fprintf(stderr, "i2 = %d\n", WCctype_II_LEN + WCctype_TI_LEN + i1 + sc); - fprintf(stderr, "val = %d\n", tbl->ii[WCctype_II_LEN + WCctype_TI_LEN + i1 + sc]); + i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT; + /* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */ + fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc); + fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]); /* return tbl->ut[i1 + sc]; */ diff --git a/extra/locale/gen_ldc.c b/extra/locale/gen_ldc.c index 399587d96..3ffc90efe 100644 --- a/extra/locale/gen_ldc.c +++ b/extra/locale/gen_ldc.c @@ -17,10 +17,10 @@ /* #define __CTYPE_HAS_8_BIT_LOCALES */ #endif -/* #define Cctype_TBL_LEN 328 */ -/* #define Cuplow_TBL_LEN 400 */ -/* #define Cc2wc_TBL_LEN 1448 */ -/* #define Cwc2c_TBL_LEN 3744 */ +/* #define __LOCALE_DATA_Cctype_TBL_LEN 328 */ +/* #define __LOCALE_DATA_Cuplow_TBL_LEN 400 */ +/* #define __LOCALE_DATA_Cc2wc_TBL_LEN 1448 */ +/* #define __LOCALE_DATA_Cwc2c_TBL_LEN 3744 */ #define WANT_WCctype_data #define WANT_WCuplow_data @@ -34,9 +34,9 @@ /* #undef WANT_WCcomb_data */ /* #undef WANT_WCwidth_data */ - #define WCctype_TBL_LEN (WCctype_II_LEN + WCctype_TI_LEN + WCctype_UT_LEN) - #define WCuplow_TBL_LEN (WCuplow_II_LEN + WCuplow_TI_LEN + WCuplow_UT_LEN) - #define WCuplow_diff_TBL_LEN (2 * WCuplow_diffs) + #define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN) + #define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN) + #define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs) /* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */ #include "locale_collate.h" @@ -50,7 +50,7 @@ /* #define __PASTE3(A,B,C) A ## B ## C */ -/* #define MAGIC_SIZE 64 */ +/* #define __LOCALE_DATA_MAGIC_SIZE 64 */ /* #define COMMON_MMAP(X) \ */ /* unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; */ @@ -69,7 +69,7 @@ offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)) \ -static const size_t common_tbl_offsets[CATEGORIES*4] = { +static const size_t common_tbl_offsets[__LOCALE_DATA_CATEGORIES*4] = { COMMON_OFFSETS(ctype), COMMON_OFFSETS(numeric), COMMON_OFFSETS(monetary), @@ -152,9 +152,11 @@ int main(void) { FILE *lso; /* static object */ int i; - unsigned char magic[MAGIC_SIZE]; +#ifdef __LOCALE_DATA_MAGIC_SIZE + unsigned char magic[__LOCALE_DATA_MAGIC_SIZE]; - memset(magic, 0, MAGIC_SIZE); + memset(magic, 0, __LOCALE_DATA_MAGIC_SIZE); +#endif /* __LOCALE_DATA_MAGIC_SIZE */ if (!(lso = fopen("locale_data.c", "w"))) { printf("can't open locale_data.c!\n"); @@ -174,20 +176,22 @@ int main(void) "#include \"locale_mmap.h\"\n\n" "static const __locale_mmap_t locale_mmap = {\n\n" ); - out_uc(lso, magic, MAGIC_SIZE, "magic"); +#ifdef __LOCALE_DATA_MAGIC_SIZE + out_uc(lso, magic, __LOCALE_DATA_MAGIC_SIZE, "magic"); +#endif /* __LOCALE_DATA_MAGIC_SIZE */ #ifdef __CTYPE_HAS_8_BIT_LOCALES - out_uc(lso, Cctype_data, Cctype_TBL_LEN, "tbl8ctype"); - out_uc(lso, Cuplow_data, Cuplow_TBL_LEN, "tbl8uplow"); + out_uc(lso, __LOCALE_DATA_Cctype_data, __LOCALE_DATA_Cctype_TBL_LEN, "tbl8ctype"); + out_uc(lso, __LOCALE_DATA_Cuplow_data, __LOCALE_DATA_Cuplow_TBL_LEN, "tbl8uplow"); #ifdef __WCHAR_ENABLED - out_u16(lso, Cc2wc_data, Cc2wc_TBL_LEN, "tbl8c2wc"); - out_uc(lso, Cwc2c_data, Cwc2c_TBL_LEN, "tbl8wc2c"); + out_u16(lso, __LOCALE_DATA_Cc2wc_data, __LOCALE_DATA_Cc2wc_TBL_LEN, "tbl8c2wc"); + out_uc(lso, __LOCALE_DATA_Cwc2c_data, __LOCALE_DATA_Cwc2c_TBL_LEN, "tbl8wc2c"); /* translit */ #endif /* __WCHAR_ENABLED */ #endif /* __CTYPE_HAS_8_BIT_LOCALES */ #ifdef __WCHAR_ENABLED - out_uc(lso, WCctype_data, WCctype_TBL_LEN, "tblwctype"); - out_uc(lso, WCuplow_data, WCuplow_TBL_LEN, "tblwuplow"); - out_i16(lso, WCuplow_diff_data, WCuplow_diff_TBL_LEN, "tblwuplow_diff"); + out_uc(lso, __LOCALE_DATA_WCctype_data, __LOCALE_DATA_WCctype_TBL_LEN, "tblwctype"); + out_uc(lso, __LOCALE_DATA_WCuplow_data, __LOCALE_DATA_WCuplow_TBL_LEN, "tblwuplow"); + out_i16(lso, __LOCALE_DATA_WCuplow_diff_data, __LOCALE_DATA_WCuplow_diff_TBL_LEN, "tblwuplow_diff"); /* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */ /* width?? */ #endif /* __WCHAR_ENABLED */ @@ -200,12 +204,12 @@ int main(void) #ifdef __CTYPE_HAS_8_BIT_LOCALES fprintf(lso, "{ /* codeset_8_bit array */\n"); - for (i = 0 ; i < NUM_CODESETS ; i++) { + for (i = 0 ; i < __LOCALE_DATA_NUM_CODESETS ; i++) { fprintf(lso, "{ /* codeset_8_bit[%d] */\n", i); - out_uc(lso, codeset_8_bit[i].idx8ctype, Cctype_IDX_LEN, "idx8ctype"); - out_uc(lso, codeset_8_bit[i].idx8uplow, Cuplow_IDX_LEN, "idx8uplow"); - out_uc(lso, codeset_8_bit[i].idx8c2wc, Cc2wc_IDX_LEN, "idx8c2wc"); - out_uc(lso, codeset_8_bit[i].idx8wc2c, Cwc2c_II_LEN, "idx8wc2c"); + out_uc(lso, codeset_8_bit[i].idx8ctype, __LOCALE_DATA_Cctype_IDX_LEN, "idx8ctype"); + out_uc(lso, codeset_8_bit[i].idx8uplow, __LOCALE_DATA_Cuplow_IDX_LEN, "idx8uplow"); + out_uc(lso, codeset_8_bit[i].idx8c2wc, __LOCALE_DATA_Cc2wc_IDX_LEN, "idx8c2wc"); + out_uc(lso, codeset_8_bit[i].idx8wc2c, __LOCALE_DATA_Cwc2c_II_LEN, "idx8wc2c"); fprintf(lso, "},\n"); } fprintf(lso, "},\n"); @@ -237,7 +241,7 @@ int main(void) { - unsigned char co_buf[CATEGORIES] = { + unsigned char co_buf[__LOCALE_DATA_CATEGORIES] = { __lc_ctype_item_offsets_LEN, __lc_numeric_item_offsets_LEN, __lc_monetary_item_offsets_LEN, @@ -245,26 +249,26 @@ int main(void) 0, __lc_messages_item_offsets_LEN }; - out_uc(lso, co_buf, CATEGORIES, "lc_common_item_offsets_LEN"); + out_uc(lso, co_buf, __LOCALE_DATA_CATEGORIES, "lc_common_item_offsets_LEN"); } - out_size_t(lso, common_tbl_offsets, CATEGORIES * 4, "lc_common_tbl_offsets"); + out_size_t(lso, common_tbl_offsets, __LOCALE_DATA_CATEGORIES * 4, "lc_common_tbl_offsets"); /* offsets from start of locale_mmap_t */ /* rows, item_offsets, item_idx, data */ -#ifdef NUM_LOCALES - out_uc(lso, __locales, NUM_LOCALES * WIDTH_LOCALES, "locales"); - out_uc(lso, __locale_names5, 5 * NUM_LOCALE_NAMES, "locale_names5"); -#ifdef LOCALE_AT_MODIFIERS_LENGTH - out_uc(lso, __locale_at_modifiers, LOCALE_AT_MODIFIERS_LENGTH, "locale_at_modifiers"); +#ifdef __LOCALE_DATA_NUM_LOCALES + out_uc(lso, __locales, __LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES, "locales"); + out_uc(lso, __locale_names5, 5 * __LOCALE_DATA_NUM_LOCALE_NAMES, "locale_names5"); +#ifdef __LOCALE_DATA_AT_MODIFIERS_LENGTH + out_uc(lso, __locale_at_modifiers, __LOCALE_DATA_AT_MODIFIERS_LENGTH, "locale_at_modifiers"); #else -#error LOCALE_AT_MODIFIERS_LENGTH not defined! -#endif /* LOCALE_AT_MODIFIERS_LENGTH */ -#endif /* NUM_LOCALES */ +#error __LOCALE_DATA_AT_MODIFIERS_LENGTH not defined! +#endif /* __LOCALE_DATA_AT_MODIFIERS_LENGTH */ +#endif /* __LOCALE_DATA_NUM_LOCALES */ - out_uc(lso, lc_names, lc_names_LEN, "lc_names"); + out_uc(lso, lc_names, __lc_names_LEN, "lc_names"); #ifdef __CTYPE_HAS_8_BIT_LOCALES - out_uc(lso, (const unsigned char*) CODESET_LIST, sizeof(CODESET_LIST), "codeset_list"); + out_uc(lso, (const unsigned char*) __LOCALE_DATA_CODESET_LIST, sizeof(__LOCALE_DATA_CODESET_LIST), "codeset_list"); #endif /* __CTYPE_HAS_8_BIT_LOCALES */ fprintf(lso, diff --git a/extra/locale/gen_locale.c b/extra/locale/gen_locale.c index 1d50480ee..388f543c5 100644 --- a/extra/locale/gen_locale.c +++ b/extra/locale/gen_locale.c @@ -13,7 +13,7 @@ #include "c8tables.h" -#define CATEGORIES 6 +#define __LOCALE_DATA_CATEGORIES 6 /* must agree with ordering of gen_mmap! */ static const unsigned char *lc_names[] = { @@ -23,15 +23,15 @@ static const unsigned char *lc_names[] = { "LC_TIME", "LC_COLLATE", "LC_MESSAGES", -#if CATEGORIES == 12 +#if __LOCALE_DATA_CATEGORIES == 12 "LC_PAPER", "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT", "LC_IDENTIFICATION", -#elif CATEGORIES != 6 -#error unsupported CATEGORIES value! +#elif __LOCALE_DATA_CATEGORIES != 6 +#error unsupported __LOCALE_DATA_CATEGORIES value! #endif }; @@ -48,8 +48,8 @@ typedef struct { unsigned char lc_monetary_row; unsigned char lc_messages_row; unsigned char lc_ctype_row; -#if CATEGORIES != 6 -#error unsupported CATEGORIES value +#if __LOCALE_DATA_CATEGORIES != 6 +#error unsupported __LOCALE_DATA_CATEGORIES value #endif } locale_entry; @@ -99,17 +99,17 @@ static void do_locale_names(void) if (num_locales <= 1) { /* printf("error - only C locale?\n"); */ /* exit(EXIT_FAILURE); */ - fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + CATEGORIES)); + fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + __LOCALE_DATA_CATEGORIES)); fprintf(ofp, "static const unsigned char __locale_names5[5];\n"); } else { if (default_utf8) { fprintf(ofp, "#define __CTYPE_HAS_UTF_8_LOCALES\t\t\t1\n"); } - fprintf(ofp, "#define CATEGORIES\t\t\t%d\n", CATEGORIES); - fprintf(ofp, "#define WIDTH_LOCALES\t\t\t%d\n", 3+CATEGORIES); - fprintf(ofp, "#define NUM_LOCALES\t\t\t%d\n", num_locales); + fprintf(ofp, "#define __LOCALE_DATA_CATEGORIES\t\t\t%d\n", __LOCALE_DATA_CATEGORIES); + fprintf(ofp, "#define __LOCALE_DATA_WIDTH_LOCALES\t\t\t%d\n", 3+__LOCALE_DATA_CATEGORIES); + fprintf(ofp, "#define __LOCALE_DATA_NUM_LOCALES\t\t\t%d\n", num_locales); fprintf(ofp, "static const unsigned char __locales[%d] = {\n", - (num_locales) * (3 + CATEGORIES)); + (num_locales) * (3 + __LOCALE_DATA_CATEGORIES)); for (i=0 ; i < num_locales ; i++) { if (memcmp(locales[i].name, locales[i-1].name, 5) != 0) { locales[i].idx_name = uniq; @@ -143,7 +143,7 @@ static void do_locale_names(void) } fprintf(ofp, "};\n\n"); - fprintf(ofp, "#define NUM_LOCALE_NAMES\t\t%d\n", uniq ); + fprintf(ofp, "#define __LOCALE_DATA_NUM_LOCALE_NAMES\t\t%d\n", uniq ); fprintf(ofp, "static const unsigned char __locale_names5[%d] = \n\t", uniq * 5); uniq = 0; for (i=1 ; i < num_locales ; i++) { @@ -167,7 +167,7 @@ static void do_locale_names(void) p += 1 + (unsigned char) *p; } /* len, char, string\0 */ - fprintf(ofp, "#define LOCALE_AT_MODIFIERS_LENGTH\t\t%d\n", + fprintf(ofp, "#define __LOCALE_DATA_AT_MODIFIERS_LENGTH\t\t%d\n", i + (at_strings_end - at_strings)); fprintf(ofp, "static const unsigned char __locale_at_modifiers[%d] = {", i + (at_strings_end - at_strings)); @@ -188,41 +188,41 @@ static void do_locale_names(void) } { - int pos[CATEGORIES]; - pos[0] = CATEGORIES; - for (i=0 ; i < CATEGORIES ; i++) { + int pos[__LOCALE_DATA_CATEGORIES]; + pos[0] = __LOCALE_DATA_CATEGORIES; + for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) { fprintf(ofp, "#define __%s\t\t%d\n", lc_names[i], i); - if (i + 1 < CATEGORIES) { + if (i + 1 < __LOCALE_DATA_CATEGORIES) { pos[i+1] = 1 + strlen(lc_names[i]) + pos[i]; } } - if (pos[CATEGORIES-1] > 255) { - printf("error - lc_names is too big (%d)\n", pos[CATEGORIES-1]); + if (pos[__LOCALE_DATA_CATEGORIES-1] > 255) { + printf("error - lc_names is too big (%d)\n", pos[__LOCALE_DATA_CATEGORIES-1]); exit(EXIT_FAILURE); } fprintf(ofp, "#define __LC_ALL\t\t%d\n\n", i); - fprintf(ofp, "#define lc_names_LEN\t\t%d\n", - pos[CATEGORIES-1] + strlen(lc_names[CATEGORIES-1]) + 1); - total_size += pos[CATEGORIES-1] + strlen(lc_names[CATEGORIES-1]) + 1; + fprintf(ofp, "#define __lc_names_LEN\t\t%d\n", + pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1); + total_size += pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1; fprintf(ofp, "static unsigned const char lc_names[%d] =\n", - pos[CATEGORIES-1] + strlen(lc_names[CATEGORIES-1]) + 1); + pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1); fprintf(ofp, "\t\""); - for (i=0 ; i < CATEGORIES ; i++) { + for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) { fprintf(ofp, "\\x%02x", (unsigned char) pos[i]); } fprintf(ofp, "\""); - for (i=0 ; i < CATEGORIES ; i++) { + for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) { fprintf(ofp, "\n\t\"%s\\0\"", lc_names[i]); } fprintf(ofp, ";\n\n"); } printf("locale data = %d name data = %d for %d uniq\n", - num_locales * (3 + CATEGORIES), uniq * 5, uniq); + num_locales * (3 + __LOCALE_DATA_CATEGORIES), uniq * 5, uniq); - total_size += num_locales * (3 + CATEGORIES) + uniq * 5; + total_size += num_locales * (3 + __LOCALE_DATA_CATEGORIES) + uniq * 5; } } @@ -343,19 +343,19 @@ static void read_enable_disable(void) } while (1); } -#ifdef CODESET_LIST +#ifdef __LOCALE_DATA_CODESET_LIST static int find_codeset_num(const char *cs) { int r = 2; - char *s = CODESET_LIST; + char *s = __LOCALE_DATA_CODESET_LIST; /* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */ if (strcmp(cs, "UTF-8") != 0) { ++r; - while (*s && strcmp(CODESET_LIST+ ((unsigned char) *s), cs)) { -/* printf("tried %s\n", CODESET_LIST + ((unsigned char) *s)); */ + while (*s && strcmp(__LOCALE_DATA_CODESET_LIST+ ((unsigned char) *s), cs)) { +/* printf("tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */ ++r; ++s; } diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c index 0c39d0f12..75054667a 100644 --- a/extra/locale/gen_wc8bit.c +++ b/extra/locale/gen_wc8bit.c @@ -111,8 +111,8 @@ int main(int argc, char **argv) fprintf(out, "#endif\n"); fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n"); - fprintf(out, "#define NUM_CODESETS\t\t0\n"); - fprintf(out, "#define CODESET_LIST\t\t\"\"\n"); + fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n"); + fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n"); fclose(out); return EXIT_SUCCESS; } @@ -124,30 +124,30 @@ int main(int argc, char **argv) if (argc == 1) { fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n"); - fprintf(out, "#define NUM_CODESETS\t\t0\n"); - fprintf(out, "#define CODESET_LIST\t\t\"\"\n"); + fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n"); + fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n"); } else { fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n"); } - fprintf(out, "#define Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT); - fprintf(out, "#define Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN); + fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN); #ifdef CTYPE_PACKED - fprintf(out, "#define Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1); - fprintf(out, "#define Cctype_PACKED\t\t1\n"); + fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1); + fprintf(out, "#define __LOCALE_DATA_Cctype_PACKED\t\t1\n"); #else - fprintf(out, "#define Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN); - fprintf(out, "#undef Cctype_PACKED\n"); + fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN); + fprintf(out, "#undef __LOCALE_DATA_Cctype_PACKED\n"); #endif - fprintf(out, "\n#define Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT); - fprintf(out, "#define Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN); - fprintf(out, "#define Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN); + fprintf(out, "\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN); + fprintf(out, "#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN); #ifdef DO_WIDE_CHAR - fprintf(out, "\n#define Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN); - fprintf(out, "#define Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT); - fprintf(out, "#define Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN); + fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN); + fprintf(out, "#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN); #endif fprintf(out, "\ntypedef struct {\n"); @@ -157,10 +157,10 @@ int main(int argc, char **argv) fprintf(out, "\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN); fprintf(out, "\tunsigned char idx8wc2c[%d];\n", II_LEN); #endif - fprintf(out, "} codeset_8_bit_t;\n\n"); + fprintf(out, "} __codeset_8_bit_t;\n\n"); fprintf(out, "#ifdef WANT_DATA\n\n"); - fprintf(out, "static const codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1); + fprintf(out, "static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1); max_wchar = 0x7f; numsets = 0; @@ -514,19 +514,19 @@ int main(int argc, char **argv) #ifdef DO_WIDE_CHAR fprintf(out, "\n"); - fprintf(out, "#define Cwc2c_DOMAIN_MAX\t%#x\n", RANGE); - fprintf(out, "#define Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT); - fprintf(out, "#define Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT); - fprintf(out, "#define Cwc2c_II_LEN\t\t%d\n", II_LEN); - fprintf(out, "#define Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT); - fprintf(out, "#define Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT); + fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT); fprintf(out, "\n"); - fprintf(out, "\n#define Cwc2c_TBL_LEN\t\t%d\n", + fprintf(out, "\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n", (ti_num << TI_SHIFT) + (tt_num << TT_SHIFT)); fprintf(out, "#ifdef WANT_DATA\n\n"); - fprintf(out, "static const unsigned char Cwc2c_data[%d] = {\n", + fprintf(out, "static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n", (ti_num << TI_SHIFT) + (tt_num << TT_SHIFT)); fprintf(out, "\t/* ti_table */\n\t"); for (i=0 ; i < ti_num << TI_SHIFT ; i++) { @@ -548,11 +548,11 @@ int main(int argc, char **argv) fprintf(out, "\n#endif /* WANT_DATA */\n"); #endif /* DO_WIDE_CHAR */ - fprintf(out, "\n#define Cuplow_TBL_LEN\t\t%d\n", + fprintf(out, "\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n", n_uplow_rows * UPLOW_ROW_LEN); fprintf(out, "\n#ifdef WANT_DATA\n\n"); - fprintf(out, "\nstatic const unsigned char Cuplow_data[%d] = {\n", + fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n", n_uplow_rows * UPLOW_ROW_LEN); p = uplow_tbl; for (j=0 ; j < n_uplow_rows ; j++) { @@ -566,7 +566,7 @@ int main(int argc, char **argv) fprintf(out, "};\n"); fprintf(out, "\n#endif /* WANT_DATA */\n"); - fprintf(out, "\n#define Cctype_TBL_LEN\t\t%d\n", + fprintf(out, "\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n", #ifdef CTYPE_PACKED n_ctype_rows * CTYPE_ROW_LEN / 2 #else @@ -576,7 +576,7 @@ int main(int argc, char **argv) fprintf(out, "\n#ifdef WANT_DATA\n\n"); - fprintf(out, "\nstatic const unsigned char Cctype_data[%d] = {\n", + fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n", #ifdef CTYPE_PACKED n_ctype_rows * CTYPE_ROW_LEN / 2 #else @@ -603,11 +603,11 @@ int main(int argc, char **argv) #ifdef DO_WIDE_CHAR - fprintf(out, "\n#define Cc2wc_TBL_LEN\t\t%d\n", + fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n", n_c2wc_rows * C2WC_ROW_LEN); fprintf(out, "\n#ifdef WANT_DATA\n\n"); - fprintf(out, "\nstatic const unsigned short Cc2wc_data[%d] = {\n", + fprintf(out, "\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n", n_c2wc_rows * C2WC_ROW_LEN); p = (char *) c2wc_tbl; for (j=0 ; j < n_c2wc_rows ; j++) { @@ -623,8 +623,8 @@ int main(int argc, char **argv) #endif /* DO_WIDE_CHAR */ fprintf(out, "\n\n"); - fprintf(out, "#define NUM_CODESETS\t\t%d\n", numsets); - fprintf(out, "#define CODESET_LIST \\\n\t\""); + fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets); + fprintf(out, "#define __LOCALE_DATA_CODESET_LIST \\\n\t\""); for (i=0 ; i < numsets ; i++) { fprintf(out, "\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]); if (((i & 7) == 7) && (i + 1 < numsets)) { diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c index 1c8c10c43..a9bcf614b 100644 --- a/extra/locale/gen_wctype.c +++ b/extra/locale/gen_wctype.c @@ -159,17 +159,17 @@ void output_table(FILE *fp, const char *name, table_data *tbl) { size_t i; - fprintf(fp, "#define WC%s_II_LEN %7u\n", name, tbl->ii_len); - fprintf(fp, "#define WC%s_TI_LEN %7u\n", name, tbl->ti_len); - fprintf(fp, "#define WC%s_UT_LEN %7u\n", name, tbl->ut_len); + fprintf(fp, "#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len); + fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len); + fprintf(fp, "#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len); - fprintf(fp, "#define WC%s_II_SHIFT %7u\n", name, tbl->ii_shift); - fprintf(fp, "#define WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift); + fprintf(fp, "#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift); + fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift); fprintf(fp, "\n#ifdef WANT_WC%s_data\n", name); i = tbl->ii_len + tbl->ti_len + tbl->ut_len; - fprintf(fp, "\nstatic const unsigned char WC%s_data[%zu] = {", name, i); + fprintf(fp, "\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i); for (i=0 ; i < tbl->ii_len ; i++) { if (i % 12 == 0) { fprintf(fp, "\n"); @@ -730,16 +730,16 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - fprintf(fp, "#define WC_TABLE_DOMAIN_MAX %#8lx\n\n", + fprintf(fp, "#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n", (unsigned long) RANGE); output_table(fp, "ctype", &cttable); output_table(fp, "uplow", &ultable); #warning fix the upper bound on the upper/lower tables... save 200 bytes or so - fprintf(fp, "#define WCuplow_diffs %7u\n", ul_count); + fprintf(fp, "#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count); fprintf(fp, "\n#ifdef WANT_WCuplow_diff_data\n\n"); - fprintf(fp, "\nstatic const short WCuplow_diff_data[%zu] = {", + fprintf(fp, "\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {", 2 * (size_t) ul_count); for (i=0 ; i < ul_count ; i++) { if (i % 4 == 0) { diff --git a/extra/locale/locale_mmap.h b/extra/locale/locale_mmap.h index 12c4025e1..1b748239b 100644 --- a/extra/locale/locale_mmap.h +++ b/extra/locale/locale_mmap.h @@ -1,13 +1,16 @@ -/* #include "lt_defines.h" */ - -/* TODO - fix */ -#define MAGIC_SIZE 64 +/* #define __LOCALE_DATA_MAGIC_SIZE 64 */ +#ifndef __WCHAR_ENABLED +#if 0 +#warning WHOA!!! __WCHAR_ENABLED is not defined! defining it now... +#endif +#define __WCHAR_ENABLED +#endif /* TODO - fix */ #ifdef __WCHAR_ENABLED -#define WCctype_TBL_LEN (WCctype_II_LEN + WCctype_TI_LEN + WCctype_UT_LEN) -#define WCuplow_TBL_LEN (WCuplow_II_LEN + WCuplow_TI_LEN + WCuplow_UT_LEN) -#define WCuplow_diff_TBL_LEN (2 * WCuplow_diffs) +#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN) +#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN) +#define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs) /* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */ #endif @@ -16,70 +19,72 @@ #undef __PASTE3 #define __PASTE3(A,B,C) A ## B ## C -#define COMMON_MMAP(X) \ +#define __LOCALE_DATA_COMMON_MMAP(X) \ unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; -#define COMMON_MMIDX(X) \ +#define __LOCALE_DATA_COMMON_MMIDX(X) \ unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \ uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \ uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \ typedef struct { - unsigned char magic[MAGIC_SIZE]; +#ifdef __LOCALE_DATA_MAGIC_SIZE + unsigned char magic[__LOCALE_DATA_MAGIC_SIZE]; +#endif /* __LOCALE_DATA_MAGIC_SIZE */ #ifdef __CTYPE_HAS_8_BIT_LOCALES - const unsigned char tbl8ctype[Cctype_TBL_LEN]; - const unsigned char tbl8uplow[Cuplow_TBL_LEN]; + const unsigned char tbl8ctype[__LOCALE_DATA_Cctype_TBL_LEN]; + const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN]; #ifdef __WCHAR_ENABLED - const uint16_t tbl8c2wc[Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */ - const unsigned char tbl8wc2c[Cwc2c_TBL_LEN]; + const uint16_t tbl8c2wc[__LOCALE_DATA_Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */ + const unsigned char tbl8wc2c[__LOCALE_DATA_Cwc2c_TBL_LEN]; /* translit */ #endif /* __WCHAR_ENABLED */ #endif /* __CTYPE_HAS_8_BIT_LOCALES */ #ifdef __WCHAR_ENABLED - const unsigned char tblwctype[WCctype_TBL_LEN]; - const unsigned char tblwuplow[WCuplow_TBL_LEN]; - const int16_t tblwuplow_diff[WCuplow_diff_TBL_LEN]; + const unsigned char tblwctype[__LOCALE_DATA_WCctype_TBL_LEN]; + const unsigned char tblwuplow[__LOCALE_DATA_WCuplow_TBL_LEN]; + const int16_t tblwuplow_diff[__LOCALE_DATA_WCuplow_diff_TBL_LEN]; /* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */ /* width?? */ #endif /* __WCHAR_ENABLED */ - COMMON_MMAP(ctype); - COMMON_MMAP(numeric); - COMMON_MMAP(monetary); - COMMON_MMAP(time); + __LOCALE_DATA_COMMON_MMAP(ctype); + __LOCALE_DATA_COMMON_MMAP(numeric); + __LOCALE_DATA_COMMON_MMAP(monetary); + __LOCALE_DATA_COMMON_MMAP(time); /* collate is different */ - COMMON_MMAP(messages); + __LOCALE_DATA_COMMON_MMAP(messages); #ifdef __CTYPE_HAS_8_BIT_LOCALES - const codeset_8_bit_t codeset_8_bit[NUM_CODESETS]; + const __codeset_8_bit_t codeset_8_bit[__LOCALE_DATA_NUM_CODESETS]; #endif /* __CTYPE_HAS_8_BIT_LOCALES */ - COMMON_MMIDX(ctype); - COMMON_MMIDX(numeric); - COMMON_MMIDX(monetary); - COMMON_MMIDX(time); + __LOCALE_DATA_COMMON_MMIDX(ctype); + __LOCALE_DATA_COMMON_MMIDX(numeric); + __LOCALE_DATA_COMMON_MMIDX(monetary); + __LOCALE_DATA_COMMON_MMIDX(time); /* collate is different */ - COMMON_MMIDX(messages); + __LOCALE_DATA_COMMON_MMIDX(messages); const uint16_t collate_data[__lc_collate_data_LEN]; - unsigned char lc_common_item_offsets_LEN[CATEGORIES]; - size_t lc_common_tbl_offsets[CATEGORIES * 4]; + unsigned char lc_common_item_offsets_LEN[__LOCALE_DATA_CATEGORIES]; + size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4]; /* offsets from start of locale_mmap_t */ /* rows, item_offsets, item_idx, data */ -#ifdef NUM_LOCALES - unsigned char locales[NUM_LOCALES * WIDTH_LOCALES]; - unsigned char locale_names5[5*NUM_LOCALE_NAMES]; - unsigned char locale_at_modifiers[LOCALE_AT_MODIFIERS_LENGTH]; -#endif /* NUM_LOCALES */ +#ifdef __LOCALE_DATA_NUM_LOCALES + unsigned char locales[__LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES]; + unsigned char locale_names5[5*__LOCALE_DATA_NUM_LOCALE_NAMES]; + unsigned char locale_at_modifiers[__LOCALE_DATA_AT_MODIFIERS_LENGTH]; +#endif /* __LOCALE_DATA_NUM_LOCALES */ - unsigned char lc_names[lc_names_LEN]; + unsigned char lc_names[__lc_names_LEN]; #ifdef __CTYPE_HAS_8_BIT_LOCALES - unsigned char codeset_list[sizeof(CODESET_LIST)]; /* TODO - fix */ + unsigned char codeset_list[sizeof(__LOCALE_DATA_CODESET_LIST)]; /* TODO - fix */ #endif /* __CTYPE_HAS_8_BIT_LOCALES */ |