X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblunicode%2Fucdata%2Fucgendat.c;h=3be66a670eb34df44ed6984e32a4ab437131cac4;hb=a7c595088c1561c4f08932a97f9a716ae9dabd9c;hp=199af435f57a9d25489b155fd02d0dbb40ea67c2;hpb=d557ceda8f2e3116e136dd26c6793ac1983dd999;p=openldap diff --git a/libraries/liblunicode/ucdata/ucgendat.c b/libraries/liblunicode/ucdata/ucgendat.c index 199af435f5..3be66a670e 100644 --- a/libraries/liblunicode/ucdata/ucgendat.c +++ b/libraries/liblunicode/ucdata/ucgendat.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2012 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ #include "ldap_config.h" #include +#include #include #include #include @@ -46,6 +47,10 @@ #include +#ifndef HARDCODE_DATA +#define HARDCODE_DATA 1 +#endif + #undef ishdigit #define ishdigit(cc) (((cc) >= '0' && (cc) <= '9') ||\ ((cc) >= 'A' && (cc) <= 'F') ||\ @@ -136,7 +141,7 @@ static ac_uint4 kdecomps_size; */ #define COMPEX_SET(c) (compexs[(c) >> 5] |= (1 << ((c) & 31))) #define COMPEX_TEST(c) (compexs[(c) >> 5] & (1 << ((c) & 31))) -static ac_uint4 compexs[2048]; +static ac_uint4 compexs[8192]; /* * Struct for holding a composition pair, and array of composition pairs @@ -1073,7 +1078,7 @@ read_cdata(FILE *in) * Adjust the denominator in case of integers and add the number. */ if (wnum == 0) - number[1] = number[0]; + number[1] = 1; add_number(code, number[0], number[1]); } @@ -1200,10 +1205,11 @@ cmpcomps(const void *v_comp1, const void *v_comp2) static void read_compexdata(FILE *in) { - ac_uint2 i, code; + ac_uint2 i; + ac_uint4 code; char line[512], *s; - (void) memset((char *) compexs, 0, sizeof(ac_uint4) << 11); + (void) memset((char *) compexs, 0, sizeof(compexs)); while (fgets(line, sizeof(line), in)) { if( (s=strchr(line, '\n')) ) *s = '\0'; @@ -1214,10 +1220,11 @@ read_compexdata(FILE *in) continue; /* - * Collect the code. Assume max 4 digits + * Collect the code. Assume max 6 digits */ - for (s = line, i = code = 0; *s != '#' && i < 4; i++, s++) { + for (s = line, i = code = 0; *s != '#' && i < 6; i++, s++) { + if (isspace((unsigned char)*s)) break; code <<= 4; if (*s >= '0' && *s <= '9') code += *s - '0'; @@ -1253,14 +1260,37 @@ 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 +1481,7 @@ write_cdata(char *opath) fwrite((char *) title, sizeof(_case_t), title_used, out); fclose(out); +#endif /***************************************************************** * @@ -1394,6 +1494,27 @@ write_cdata(char *opath) */ create_comps(); +#if HARDCODE_DATA + fprintf(out, PREF "ac_uint4 _uccomp_size = %ld;\n\n", + comps_used * 4L); + + 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