11 /* #define Cctype_TBL_LEN 328 */
12 /* #define Cuplow_TBL_LEN 400 */
13 /* #define Cc2wc_TBL_LEN 1448 */
14 /* #define Cwc2c_TBL_LEN 3744 */
16 #define WANT_WCctype_data
17 #define WANT_WCuplow_data
18 #define WANT_WCuplow_diff_data
19 /* #define WANT_WCcomb_data */
20 /* #define WANT_WCwidth_data */
22 #undef WANT_WCctype_data
23 #undef WANT_WCuplow_data
24 #undef WANT_WCuplow_diff_data
25 /* #undef WANT_WCcomb_data */
26 /* #undef WANT_WCwidth_data */
28 /* #define WCctype_TBL_LEN (WCctype_II_LEN + WCctype_TI_LEN + WCctype_UT_LEN) */
29 /* #define WCuplow_TBL_LEN (WCuplow_II_LEN + WCuplow_TI_LEN + WCuplow_UT_LEN) */
30 /* #define WCuplow_diff_TBL_LEN (2 * WCuplow_diffs) */
31 /* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */
33 #include "locale_tables.h"
35 #include "locale_mmap.h"
38 /* #define __PASTE2(A,B) A ## B */
40 /* #define __PASTE3(A,B,C) A ## B ## C */
43 /* #define MAGIC_SIZE 64 */
45 /* #define COMMON_MMAP(X) \ */
46 /* unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; */
48 /* #define COMMON_MMIDX(X) \ */
49 /* unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \ */
50 /* uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \ */
51 /* uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \ */
53 #define WRITE_COMMON_MMAP(X) \
54 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)), SEEK_SET); \
55 for (i=0 ; i < __PASTE3(__lc_,X,_data_LEN) ; i++) { \
56 putc(__PASTE3(__lc_,X,_data)[i], fp); \
59 #define WRITE_COMMON_MMIDX(X) \
60 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_rows)), SEEK_SET); \
61 for (i=0 ; i < __PASTE3(__lc_,X,_rows_LEN) ; i++) { \
62 putc(__PASTE3(__lc_,X,_rows)[i], fp); \
64 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_offsets)), SEEK_SET); \
65 for (i=0 ; i < __PASTE3(__lc_,X,_item_offsets_LEN) ; i++) { \
66 putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_offsets)[i]))[0], fp); \
67 putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_offsets)[i]))[1], fp); \
69 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_idx)), SEEK_SET); \
70 for (i=0 ; i < __PASTE3(__lc_,X,_item_idx_LEN) ; i++) { \
71 putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_idx)[i]))[0], fp); \
72 putc( ((unsigned char *) &(__PASTE3(__lc_,X,_item_idx)[i]))[1], fp); \
75 #define WRITE_WC_DATA(X) \
76 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tblw,X)), SEEK_SET); \
77 for (i=0 ; i < __PASTE3(WC,X,_TBL_LEN) ; i++) { \
78 putc(__PASTE3(WC,X,_data)[i], fp); \
81 #define WRITE_WC_I16_DATA(X) \
82 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tblw,X)), SEEK_SET); \
83 for (i=0 ; i < __PASTE3(WC,X,_TBL_LEN) ; i++) { \
84 putc( ((unsigned char *) &(__PASTE3(WC,X,_data)[i]))[0], fp); \
85 putc( ((unsigned char *) &(__PASTE3(WC,X,_data)[i]))[1], fp); \
88 #define WRITE_C_DATA(X) \
89 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tbl8,X)), SEEK_SET); \
90 for (i=0 ; i < __PASTE3(C,X,_TBL_LEN) ; i++) { \
91 putc(__PASTE3(C,X,_data)[i], fp); \
94 #define WRITE_C_U16_DATA(X) \
95 fseek(fp, (long) offsetof(__locale_mmap_t, __PASTE2(tbl8,X)), SEEK_SET); \
96 for (i=0 ; i < __PASTE3(C,X,_TBL_LEN) ; i++) { \
97 putc( ((unsigned char *) &(__PASTE3(C,X,_data)[i]))[0], fp); \
98 putc( ((unsigned char *) &(__PASTE3(C,X,_data)[i]))[1], fp); \
101 /**********************************************************************/
103 #define COMMON_OFFSETS(X) \
104 offsetof(__locale_mmap_t, __PASTE3(lc_,X,_rows)), \
105 offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_offsets)), \
106 offsetof(__locale_mmap_t, __PASTE3(lc_,X,_item_idx)), \
107 offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)) \
110 static const size_t common_tbl_offsets[CATEGORIES*4] = {
111 0, 0, 0, 0, /* ctype */
112 COMMON_OFFSETS(numeric),
113 COMMON_OFFSETS(monetary),
114 COMMON_OFFSETS(time),
115 0, 0, 0, 0, /* collate */
116 COMMON_OFFSETS(messages),
129 if (!(fp = fopen("locale.mmap", "w"))) {
130 printf("error - can't open locale.mmap for writing!");
134 for (i=0 ; i < sizeof(__locale_mmap_t) ; i++) {
135 putc(0, fp); /* Zero out the file. */
138 #ifdef __CTYPE_HAS_8_BIT_LOCALES
141 #ifdef __WCHAR_ENABLED
142 WRITE_C_U16_DATA(c2wc);
145 #endif /* __WCHAR_ENABLED */
146 #endif /* __CTYPE_HAS_8_BIT_LOCALES */
148 #ifdef __WCHAR_ENABLED
149 WRITE_WC_DATA(ctype);
150 WRITE_WC_DATA(uplow);
151 WRITE_WC_I16_DATA(uplow_diff);
152 /* WRITE_WC_DATA(comb); */
154 #endif /* __WCHAR_ENABLED */
156 WRITE_COMMON_MMAP(numeric);
157 WRITE_COMMON_MMAP(monetary);
158 WRITE_COMMON_MMAP(time);
160 WRITE_COMMON_MMAP(messages);
162 #ifdef __CTYPE_HAS_8_BIT_LOCALES
163 fseek(fp, (long) offsetof(__locale_mmap_t, codeset_8_bit), SEEK_SET); \
164 p = (unsigned char *) codeset_8_bit;
165 for (i=0 ; i < sizeof(codeset_8_bit) ; i++) {
168 #endif /* __CTYPE_HAS_8_BIT_LOCALES */
170 WRITE_COMMON_MMIDX(numeric);
171 WRITE_COMMON_MMIDX(monetary);
172 WRITE_COMMON_MMIDX(time);
174 WRITE_COMMON_MMIDX(messages);
176 fseek(fp, (long) offsetof(__locale_mmap_t, lc_common_item_offsets_LEN), SEEK_SET);
177 putc(1, fp); /* ctype -- (codeset) handled specially */
178 putc(__lc_numeric_item_offsets_LEN, fp);
179 putc(__lc_monetary_item_offsets_LEN, fp);
180 putc(__lc_time_item_offsets_LEN, fp);
181 putc(0, fp); /* collate */
182 putc(__lc_messages_item_offsets_LEN, fp);
184 fseek(fp, (long) offsetof(__locale_mmap_t, lc_common_tbl_offsets), SEEK_SET);
185 for (i=0 ; i < sizeof(common_tbl_offsets) ; i++) {
186 putc(((unsigned char *)common_tbl_offsets)[i], fp);
190 fseek(fp, (long) offsetof(__locale_mmap_t, locales), SEEK_SET);
191 for (i=0 ; i < (NUM_LOCALES * WIDTH_LOCALES) ; i++) {
192 putc(__locales[i], fp);
195 fseek(fp, (long) offsetof(__locale_mmap_t, locale_names5), SEEK_SET);
196 for (i=0 ; i < 5 * NUM_LOCALE_NAMES ; i++) {
197 putc(__locale_names5[i], fp);
200 #ifdef LOCALE_AT_MODIFIERS_LENGTH
201 fseek(fp, (long) offsetof(__locale_mmap_t, locale_at_modifiers), SEEK_SET);
202 for (i=0 ; i < LOCALE_AT_MODIFIERS_LENGTH ; i++) {
203 putc(__locale_at_modifiers[i], fp);
205 #endif /* LOCALE_AT_MODIFIERS_LENGTH */
206 #endif /* NUM_LOCALES */
208 fseek(fp, (long) offsetof(__locale_mmap_t, lc_names), SEEK_SET);
209 for (i=0 ; i < lc_names_LEN ; i++) {
210 putc(lc_names[i], fp);
213 #ifdef __CTYPE_HAS_8_BIT_LOCALES
214 fseek(fp, (long) offsetof(__locale_mmap_t, codeset_list), SEEK_SET);
215 for (i=0 ; i < sizeof(CODESET_LIST) ; i++) {
216 putc((unsigned char)(CODESET_LIST[i]), fp);
218 #endif /* __CTYPE_HAS_8_BIT_LOCALES */
221 if (ferror(fp) || (fclose(fp) == EOF)) {
222 printf("error - stream in error state or fclose failed!");
226 printf("sizeof(__locale_mmap_t) = %zd\n", sizeof(__locale_mmap_t));
232 * collate data (8-bit weighted single char only)
234 * codeset list? yes, since we'll want to be able to inspect them...
235 * that means putting some header stuff in magic
236 * fix ctype LEN defines in gen_c8tables