From: Howard Chu Date: Mon, 31 May 2004 01:54:27 +0000 (+0000) Subject: Use hardcoded Unicode data tables X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~316 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=688cadf099d4b3df16f077bc61c15220116b6470;p=openldap Use hardcoded Unicode data tables --- diff --git a/libraries/liblunicode/ucdata/ucdata.c b/libraries/liblunicode/ucdata/ucdata.c index 7f3778e180..4e5856218c 100644 --- a/libraries/liblunicode/ucdata/ucdata.c +++ b/libraries/liblunicode/ucdata/ucdata.c @@ -47,6 +47,14 @@ #include "lber_pvt.h" #include "ucdata.h" +#ifndef HARDCODE_DATA +#define HARDCODE_DATA 1 +#endif + +#if HARDCODE_DATA +#include "uctable.h" +#endif + /************************************************************************** * * Miscellaneous types, data, and support functions. @@ -80,6 +88,7 @@ static ac_uint4 masks32[32] = { #define endian_long(cc) ((((cc) & 0xff) << 24)|((((cc) >> 8) & 0xff) << 16)|\ ((((cc) >> 16) & 0xff) << 8)|((cc) >> 24)) +#if !HARDCODE_DATA static FILE * _ucopenfile(char *paths, char *filename, char *mode) { @@ -110,6 +119,7 @@ _ucopenfile(char *paths, char *filename, char *mode) return 0; } +#endif /************************************************************************** * @@ -117,6 +127,8 @@ _ucopenfile(char *paths, char *filename, char *mode) * **************************************************************************/ +#if !HARDCODE_DATA + static ac_uint4 _ucprop_size; static ac_uint2 *_ucprop_offsets; static ac_uint4 *_ucprop_ranges; @@ -228,6 +240,7 @@ _ucprop_unload(void) free((char *) _ucprop_offsets); _ucprop_size = 0; } +#endif static int _ucprop_lookup(ac_uint4 code, ac_uint4 n) @@ -298,6 +311,8 @@ ucisprop(ac_uint4 code, ac_uint4 mask1, ac_uint4 mask2) * **************************************************************************/ +#if !HARDCODE_DATA + static ac_uint4 _uccase_size; static ac_uint2 _uccase_len[2]; static ac_uint4 *_uccase_map; @@ -373,6 +388,7 @@ _uccase_unload(void) free((char *) _uccase_map); _uccase_size = 0; } +#endif static ac_uint4 _uccase_lookup(ac_uint4 code, long l, long r, int field) @@ -490,6 +506,8 @@ uctotitle(ac_uint4 code) * **************************************************************************/ +#if !HARDCODE_DATA + static ac_uint4 _uccomp_size; static ac_uint4 *_uccomp_data; @@ -566,6 +584,7 @@ _uccomp_unload(void) free((char *) _uccomp_data); _uccomp_size = 0; } +#endif int uccomp(ac_uint4 node1, ac_uint4 node2, ac_uint4 *comp) @@ -680,6 +699,8 @@ uccanoncomp(ac_uint4 *str, int len) * **************************************************************************/ +#if !HARDCODE_DATA + static ac_uint4 _ucdcmp_size; static ac_uint4 *_ucdcmp_nodes; static ac_uint4 *_ucdcmp_decomp; @@ -825,6 +846,7 @@ _uckdcmp_unload(void) free((char *) _uckdcmp_nodes); _uckdcmp_size = 0; } +#endif int ucdecomp(ac_uint4 code, ac_uint4 *num, ac_uint4 **decomp) @@ -851,7 +873,7 @@ ucdecomp(ac_uint4 code, ac_uint4 *num, ac_uint4 **decomp) r = m - 2; else if (code == _ucdcmp_nodes[m]) { *num = _ucdcmp_nodes[m + 3] - _ucdcmp_nodes[m + 1]; - *decomp = &_ucdcmp_decomp[_ucdcmp_nodes[m + 1]]; + *decomp = (ac_uint4*)&_ucdcmp_decomp[_ucdcmp_nodes[m + 1]]; return 1; } } @@ -883,7 +905,7 @@ uckdecomp(ac_uint4 code, ac_uint4 *num, ac_uint4 **decomp) r = m - 2; else if (code == _uckdcmp_nodes[m]) { *num = _uckdcmp_nodes[m + 3] - _uckdcmp_nodes[m + 1]; - *decomp = &_uckdcmp_decomp[_uckdcmp_nodes[m + 1]]; + *decomp = (ac_uint4*)&_uckdcmp_decomp[_uckdcmp_nodes[m + 1]]; return 1; } } @@ -995,6 +1017,7 @@ uccompatdecomp(const ac_uint4 *in, int inlen, * **************************************************************************/ +#if !HARDCODE_DATA static ac_uint4 _uccmcl_size; static ac_uint4 *_uccmcl_nodes; @@ -1060,6 +1083,7 @@ _uccmcl_unload(void) free((char *) _uccmcl_nodes); _uccmcl_size = 0; } +#endif ac_uint4 uccombining_class(ac_uint4 code) @@ -1088,6 +1112,7 @@ uccombining_class(ac_uint4 code) * **************************************************************************/ +#if !HARDCODE_DATA static ac_uint4 *_ucnum_nodes; static ac_uint4 _ucnum_size; static short *_ucnum_vals; @@ -1165,6 +1190,7 @@ _ucnumb_unload(void) free((char *) _ucnum_nodes); _ucnum_size = 0; } +#endif int ucnumber_lookup(ac_uint4 code, struct ucnumber *num) @@ -1186,7 +1212,7 @@ ucnumber_lookup(ac_uint4 code, struct ucnumber *num) else if (code < _ucnum_nodes[m]) r = m - 2; else { - vp = _ucnum_vals + _ucnum_nodes[m + 1]; + vp = (short *)_ucnum_vals + _ucnum_nodes[m + 1]; num->numerator = (int) *vp++; num->denominator = (int) *vp; return 1; @@ -1215,7 +1241,7 @@ ucdigit_lookup(ac_uint4 code, int *digit) else if (code < _ucnum_nodes[m]) r = m - 2; else { - vp = _ucnum_vals + _ucnum_nodes[m + 1]; + vp = (short *)_ucnum_vals + _ucnum_nodes[m + 1]; if (*vp == *(vp + 1)) { *digit = *vp; return 1; @@ -1266,6 +1292,11 @@ ucgetdigit(ac_uint4 code) * **************************************************************************/ +#if HARDCODE_DATA +int ucdata_load(char *paths, int masks) { return 0; } +void ucdata_unload(int masks) { } +int ucdata_reload(char *paths, int masks) { return 0; } +#else /* * Return 0 if okay, negative on error */ @@ -1336,6 +1367,7 @@ ucdata_reload(char *paths, int masks) return -error; } +#endif #ifdef TEST diff --git a/libraries/liblunicode/ucdata/ucgendat.c b/libraries/liblunicode/ucdata/ucgendat.c index 199af435f5..d397f1832a 100644 --- a/libraries/liblunicode/ucdata/ucgendat.c +++ b/libraries/liblunicode/ucdata/ucgendat.c @@ -46,6 +46,10 @@ #include +#ifndef HARDCODE_DATA +#define HARDCODE_DATA 1 +#endif + #undef ishdigit #define ishdigit(cc) (((cc) >= '0' && (cc) <= '9') ||\ ((cc) >= 'A' && (cc) <= 'F') ||\ @@ -1253,6 +1257,24 @@ create_comps(void) qsort(comps, comps_used, sizeof(_comp_t), cmpcomps); } +#if HARDCODE_DATA +static void +write_case(FILE *out, _case_t *tab, int num, int first) +{ + int i; + + for (i=0; i 0) { + for (j=0; j 0) + /* + * Write the upper case table. + */ + write_case(out, upper, upper_used, 1); + + if (lower_used > 0) + /* + * Write the lower case table. + */ + write_case(out, lower, lower_used, !upper_used); + + if (title_used > 0) + /* + * Write the title case table. + */ + write_case(out, title, title_used, !(upper_used||lower_used)); + + if (!(upper_used || lower_used || title_used)) + fprintf(out, "\t0"); + + fprintf(out, "\n};\n\n"); +#else /* * Open the case.dat file. */ @@ -1382,6 +1475,7 @@ write_cdata(char *opath) fwrite((char *) title, sizeof(_case_t), title_used, out); fclose(out); +#endif /***************************************************************** * @@ -1394,6 +1488,26 @@ write_cdata(char *opath) */ create_comps(); +#if HARDCODE_DATA + fprintf(out, PREF "ac_uint4 _uccomp_size = %d;\n\n", + comps_used * 4); + + fprintf(out, PREF "ac_uint4 _uccomp_data[] = {"); + + /* + * Now, if comps exist, write them out. + */ + if (comps_used > 0) { + for (i=0; i 0) { + /* + * Write the combining class ranges out. + */ + for (i = 0; i 0) { + for (i = 0; i