]> git.sur5r.net Git - openldap/blobdiff - libraries/liblunicode/ucdata/ucgendat.c
Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / liblunicode / ucdata / ucgendat.c
index 7403a1dd81a7a11a3d92db1779ba9e80545c1b15..3be66a670eb34df44ed6984e32a4ab437131cac4 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * 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 <stdio.h>
+#include <ac/ctype.h>
 #include <ac/stdlib.h>
 #include <ac/string.h>
 #include <ac/unistd.h>
@@ -140,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
@@ -1204,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';
@@ -1218,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';
@@ -1266,8 +1269,9 @@ write_case(FILE *out, _case_t *tab, int num, int first)
     for (i=0; i<num; i++) {
        if (first) first = 0;
        else fprintf(out, ",");
-       fprintf(out, "\n\t0x%08x, 0x%08x, 0x%08x",
-               tab[i].key, tab[i].other1, tab[i].other2);
+       fprintf(out, "\n\t0x%08lx, 0x%08lx, 0x%08lx",
+               (unsigned long) tab[i].key, (unsigned long) tab[i].other1,
+               (unsigned long) tab[i].other2);
     }
 }
 
@@ -1281,7 +1285,9 @@ write_cdata(char *opath)
     FILE *out;
        ac_uint4 bytes;
     ac_uint4 i, idx, nprops;
+#if !(HARDCODE_DATA)
     ac_uint2 casecnt[2];
+#endif
     char path[BUFSIZ];
 #if HARDCODE_DATA
     int j, k;
@@ -1362,7 +1368,7 @@ write_cdata(char *opath)
            if (!(k&3)) fprintf(out,"\n\t");
            else fprintf(out, " ");
            k++;
-           fprintf(out, "0x%08x", proptbl[i].ranges[j]);
+           fprintf(out, "0x%08lx", (unsigned long) proptbl[i].ranges[j]);
          }
        }
     }
@@ -1402,11 +1408,11 @@ write_cdata(char *opath)
      *****************************************************************/
 
 #if HARDCODE_DATA
-    fprintf(out, PREF "ac_uint4 _uccase_size = %d;\n\n",
-       upper_used + lower_used + title_used);
+    fprintf(out, PREF "ac_uint4 _uccase_size = %ld;\n\n",
+        (long) (upper_used + lower_used + title_used));
 
-    fprintf(out, PREF "ac_uint2 _uccase_len[2] = {%d, %d};\n\n",
-       upper_used, lower_used);
+    fprintf(out, PREF "ac_uint2 _uccase_len[2] = {%ld, %ld};\n\n",
+        (long) upper_used, (long) lower_used);
     fprintf(out, PREF "ac_uint4 _uccase_map[] = {");
 
     if (upper_used > 0)
@@ -1489,8 +1495,8 @@ 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_size = %ld;\n\n",
+        comps_used * 4L);
 
     fprintf(out, PREF "ac_uint4 _uccomp_data[] = {");
 
@@ -1500,8 +1506,9 @@ write_cdata(char *opath)
     if (comps_used > 0) {
        for (i=0; i<comps_used; i++) {
            if (i) fprintf(out, ",");
-           fprintf(out, "\n\t0x%08x, 0x%08x, 0x%08x, 0x%08x",
-               comps[i].comp, comps[i].count, comps[i].code1, comps[i].code2);
+           fprintf(out, "\n\t0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx",
+               (unsigned long) comps[i].comp, (unsigned long) comps[i].count,
+               (unsigned long) comps[i].code1, (unsigned long) comps[i].code2);
        }
     } else {
        fprintf(out, "\t0");
@@ -1548,8 +1555,8 @@ write_cdata(char *opath)
     expand_decomp();
 
 #if HARDCODE_DATA
-    fprintf(out, PREF "ac_uint4 _ucdcmp_size = %d;\n\n",
-       decomps_used * 2);
+    fprintf(out, PREF "ac_uint4 _ucdcmp_size = %ld;\n\n",
+        decomps_used * 2L);
 
     fprintf(out, PREF "ac_uint4 _ucdcmp_nodes[] = {");
 
@@ -1558,14 +1565,15 @@ write_cdata(char *opath)
         * Write the list of decomp nodes.
         */
        for (i = idx = 0; i < decomps_used; i++) {
-           fprintf(out, "\n\t0x%08x, 0x%08x,", decomps[i].code, idx);
+           fprintf(out, "\n\t0x%08lx, 0x%08lx,",
+               (unsigned long) decomps[i].code, (unsigned long) idx);
            idx += decomps[i].used;
        }
 
        /*
         * Write the sentinel index as the last decomp node.
         */
-       fprintf(out, "\n\t0x%08x\n};\n\n", idx);
+       fprintf(out, "\n\t0x%08lx\n};\n\n", (unsigned long) idx);
 
        fprintf(out, PREF "ac_uint4 _ucdcmp_decomp[] = {");
        /*
@@ -1578,7 +1586,7 @@ write_cdata(char *opath)
            if (!(k&3)) fprintf(out,"\n\t");
            else fprintf(out, " ");
            k++;
-           fprintf(out, "0x%08x", decomps[i].decomp[j]);
+           fprintf(out, "0x%08lx", (unsigned long) decomps[i].decomp[j]);
          }
        fprintf(out, "\n};\n\n");
     }
@@ -1639,8 +1647,8 @@ write_cdata(char *opath)
 #endif
 
 #ifdef HARDCODE_DATA
-    fprintf(out, PREF "ac_uint4 _uckdcmp_size = %d;\n\n",
-       kdecomps_used * 2);
+    fprintf(out, PREF "ac_uint4 _uckdcmp_size = %ld;\n\n",
+        kdecomps_used * 2L);
 
     fprintf(out, PREF "ac_uint4 _uckdcmp_nodes[] = {");
 
@@ -1649,14 +1657,15 @@ write_cdata(char *opath)
         * Write the list of kdecomp nodes.
         */
        for (i = idx = 0; i < kdecomps_used; i++) {
-           fprintf(out, "\n\t0x%08x, 0x%08x,", kdecomps[i].code, idx);
+           fprintf(out, "\n\t0x%08lx, 0x%08lx,",
+               (unsigned long) kdecomps[i].code, (unsigned long) idx);
            idx += kdecomps[i].used;
        }
 
        /*
         * Write the sentinel index as the last decomp node.
         */
-       fprintf(out, "\n\t0x%08x\n};\n\n", idx);
+       fprintf(out, "\n\t0x%08lx\n};\n\n", (unsigned long) idx);
 
        fprintf(out, PREF "ac_uint4 _uckdcmp_decomp[] = {");
 
@@ -1670,7 +1679,7 @@ write_cdata(char *opath)
            if (!(k&3)) fprintf(out,"\n\t");
            else fprintf(out, " ");
            k++;
-           fprintf(out, "0x%08x", kdecomps[i].decomp[j]);
+           fprintf(out, "0x%08lx", (unsigned long) kdecomps[i].decomp[j]);
          }
        fprintf(out, "\n};\n\n");
     }
@@ -1736,7 +1745,7 @@ write_cdata(char *opath)
      *
      *****************************************************************/
 #ifdef HARDCODE_DATA
-    fprintf(out, PREF "ac_uint4 _uccmcl_size = %d;\n\n", ccl_used);
+    fprintf(out, PREF "ac_uint4 _uccmcl_size = %ld;\n\n", (long) ccl_used);
 
     fprintf(out, PREF "ac_uint4 _uccmcl_nodes[] = {");
 
@@ -1748,7 +1757,7 @@ write_cdata(char *opath)
            if (i) fprintf(out, ",");
            if (!(i&3)) fprintf(out, "\n\t");
            else fprintf(out, " ");
-           fprintf(out, "0x%08x", ccl[i]);
+           fprintf(out, "0x%08lx", (unsigned long) ccl[i]);
        }
     } else {
        fprintf(out, "\t0");
@@ -1795,7 +1804,8 @@ write_cdata(char *opath)
      *****************************************************************/
 
 #if HARDCODE_DATA
-    fprintf(out, PREF "ac_uint4 _ucnum_size = %d;\n\n", ncodes_used<<1);
+    fprintf(out, PREF "ac_uint4 _ucnum_size = %lu;\n\n",
+        (unsigned long)ncodes_used<<1);
 
     fprintf(out, PREF "ac_uint4 _ucnum_nodes[] = {");
 
@@ -1807,7 +1817,8 @@ write_cdata(char *opath)
            if (i) fprintf(out, ",");
            if (!(i&1)) fprintf(out, "\n\t");
            else fprintf(out, " ");
-           fprintf(out, "0x%08x, 0x%08x", ncodes[i].code, ncodes[i].idx);
+           fprintf(out, "0x%08lx, 0x%08lx",
+               (unsigned long) ncodes[i].code, (unsigned long) ncodes[i].idx);
        }
        fprintf(out, "\n};\n\n");