Commit 3082312f authored by bar@mysql.com's avatar bar@mysql.com

uca-dump.c:

  Mofidications to dump secondary and tertiary weigthts
  And some minor improvements
parent e3b94d4e
...@@ -23,13 +23,14 @@ struct uca_item_st ...@@ -23,13 +23,14 @@ struct uca_item_st
#define MY_UCA_PSHIFT 8 #define MY_UCA_PSHIFT 8
#endif #endif
static char *pname[]= {"", "2", "3"};
int main(int ac, char **av) int main(int ac, char **av)
{ {
char str[256]; char str[256];
char *weights[64]; char *weights[64];
struct uca_item_st uca[64*1024]; struct uca_item_st uca[64*1024];
size_t code, page, w; size_t code, w;
int pagemaxlen[MY_UCA_NPAGES];
int pageloaded[MY_UCA_NPAGES]; int pageloaded[MY_UCA_NPAGES];
bzero(uca, sizeof(uca)); bzero(uca, sizeof(uca));
...@@ -155,14 +156,20 @@ int main(int ac, char **av) ...@@ -155,14 +156,20 @@ int main(int ac, char **av)
printf("#define MY_UCA_CMASK %d\n",MY_UCA_CMASK); printf("#define MY_UCA_CMASK %d\n",MY_UCA_CMASK);
printf("#define MY_UCA_PSHIFT %d\n",MY_UCA_PSHIFT); printf("#define MY_UCA_PSHIFT %d\n",MY_UCA_PSHIFT);
for (w=0; w<1; w++) for (w=0; w<3; w++)
{ {
size_t page;
int pagemaxlen[MY_UCA_NPAGES];
for (page=0; page < MY_UCA_NPAGES; page++) for (page=0; page < MY_UCA_NPAGES; page++)
{ {
size_t offs; size_t offs;
size_t maxnum= 0; size_t maxnum= 0;
size_t nchars= 0; size_t nchars= 0;
size_t mchars; size_t mchars;
size_t ndefs= 0;
pagemaxlen[page]= 0;
/* /*
Skip this page if no weights were loaded Skip this page if no weights were loaded
...@@ -183,15 +190,37 @@ int main(int ac, char **av) ...@@ -183,15 +190,37 @@ int main(int ac, char **av)
code= page*MY_UCA_NCHARS+offs; code= page*MY_UCA_NCHARS+offs;
/* Calculate only non-zero weights */ /* Calculate only non-zero weights */
num=0; for (num=0, i=0; i < uca[code].num; i++)
for (i=0; i < uca[code].num; i++)
if (uca[code].weight[w][i]) if (uca[code].weight[w][i])
num++; num++;
maxnum= maxnum < num ? num : maxnum; maxnum= maxnum < num ? num : maxnum;
/* Check if default weight */
if (w == 1 && num == 1)
{
/* 0020 0000 ... */
if (uca[code].weight[w][0] == 0x0020)
ndefs++;
}
else if (w == 2 && num == 1)
{
/* 0002 0000 ... */
if (uca[code].weight[w][0] == 0x0002)
ndefs++;
}
} }
maxnum++; maxnum++;
/*
If the page have only default weights
then no needs to dump it, skip.
*/
if (ndefs == MY_UCA_NCHARS)
{
printf("/* Don't dump w=%d pg=%3X: ndefs=%d */\n",w, page, ndefs);
continue;
}
switch (maxnum) switch (maxnum)
{ {
case 0: mchars= 8; break; case 0: mchars= 8; break;
...@@ -210,8 +239,8 @@ int main(int ac, char **av) ...@@ -210,8 +239,8 @@ int main(int ac, char **av)
*/ */
printf("uint16 page%03Xdata[]= { /* %04X (%d weights per char) */\n", printf("uint16 page%03Xdata%s[]= { /* %04X (%d weights per char) */\n",
page, page*MY_UCA_NCHARS, maxnum); page, pname[w], page*MY_UCA_NCHARS, maxnum);
for (offs=0; offs < MY_UCA_NCHARS; offs++) for (offs=0; offs < MY_UCA_NCHARS; offs++)
{ {
...@@ -251,25 +280,28 @@ int main(int ac, char **av) ...@@ -251,25 +280,28 @@ int main(int ac, char **av)
} }
printf("};\n\n"); printf("};\n\n");
} }
}
printf("uchar ucal[%d]={\n",MY_UCA_NPAGES); printf("uchar ucal%s[%d]={\n", pname[w], MY_UCA_NPAGES);
for (page=0; page < MY_UCA_NPAGES; page++) for (page=0; page < MY_UCA_NPAGES; page++)
{ {
printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n"); printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n");
} }
printf("};\n"); printf("};\n");
printf("uint16 *ucaw[%d]={\n",MY_UCA_NPAGES); printf("uint16 *ucaw%s[%d]={\n", pname[w], MY_UCA_NPAGES);
for (page=0; page < MY_UCA_NPAGES; page++) for (page=0; page < MY_UCA_NPAGES; page++)
{ {
if (!pageloaded[page]) const char *comma= page < MY_UCA_NPAGES-1 ? "," : "";
printf("NULL %s%s",page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n"); const char *nline= (page+1) % 4 ? "" : "\n";
else if (!pagemaxlen[page])
printf("page%03Xdata%s%s",page,page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n"); printf("NULL %s%s", comma , nline);
else
printf("page%03Xdata%s%s%s", page, pname[w], comma, nline);
}
printf("};\n");
} }
printf("};\n");
printf("int main(void){ return 0;};\n"); printf("int main(void){ return 0;};\n");
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment