summaryrefslogtreecommitdiff
path: root/strings/uca-dump.c
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2004-11-22 13:02:27 +0400
committerunknown <bar@mysql.com>2004-11-22 13:02:27 +0400
commitabb53b6f99ffdabb41b71dca70f93701bea9c772 (patch)
treefab0de4e84330707085526d7ace3df3c022db523 /strings/uca-dump.c
parent6d6b38c27fcac1da19a11fa07a5f02c2c22635fe (diff)
downloadmariadb-git-abb53b6f99ffdabb41b71dca70f93701bea9c772.tar.gz
uca-dump.c:
Mofidications to dump secondary and tertiary weigthts And some minor improvements strings/uca-dump.c: Mofidications to dump secondary and tertiary weigthts And some minor improvements
Diffstat (limited to 'strings/uca-dump.c')
-rw-r--r--strings/uca-dump.c80
1 files changed, 56 insertions, 24 deletions
diff --git a/strings/uca-dump.c b/strings/uca-dump.c
index 6836c321526..c9642598c3c 100644
--- a/strings/uca-dump.c
+++ b/strings/uca-dump.c
@@ -23,13 +23,14 @@ struct uca_item_st
#define MY_UCA_PSHIFT 8
#endif
+static char *pname[]= {"", "2", "3"};
+
int main(int ac, char **av)
{
char str[256];
char *weights[64];
struct uca_item_st uca[64*1024];
- size_t code, page, w;
- int pagemaxlen[MY_UCA_NPAGES];
+ size_t code, w;
int pageloaded[MY_UCA_NPAGES];
bzero(uca, sizeof(uca));
@@ -155,14 +156,20 @@ int main(int ac, char **av)
printf("#define MY_UCA_CMASK %d\n",MY_UCA_CMASK);
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++)
{
size_t offs;
size_t maxnum= 0;
size_t nchars= 0;
size_t mchars;
+ size_t ndefs= 0;
+
+ pagemaxlen[page]= 0;
/*
Skip this page if no weights were loaded
@@ -183,15 +190,37 @@ int main(int ac, char **av)
code= page*MY_UCA_NCHARS+offs;
/* Calculate only non-zero weights */
- num=0;
- for (i=0; i < uca[code].num; i++)
+ for (num=0, i=0; i < uca[code].num; i++)
if (uca[code].weight[w][i])
num++;
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++;
+ /*
+ 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)
{
case 0: mchars= 8; break;
@@ -210,8 +239,8 @@ int main(int ac, char **av)
*/
- printf("uint16 page%03Xdata[]= { /* %04X (%d weights per char) */\n",
- page, page*MY_UCA_NCHARS, maxnum);
+ printf("uint16 page%03Xdata%s[]= { /* %04X (%d weights per char) */\n",
+ page, pname[w], page*MY_UCA_NCHARS, maxnum);
for (offs=0; offs < MY_UCA_NCHARS; offs++)
{
@@ -251,25 +280,28 @@ int main(int ac, char **av)
}
printf("};\n\n");
}
- }
- printf("uchar ucal[%d]={\n",MY_UCA_NPAGES);
- for (page=0; page < MY_UCA_NPAGES; page++)
- {
- printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n");
- }
- printf("};\n");
-
-
- printf("uint16 *ucaw[%d]={\n",MY_UCA_NPAGES);
- for (page=0; page < MY_UCA_NPAGES; page++)
- {
- if (!pageloaded[page])
- printf("NULL %s%s",page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n");
- else
- printf("page%03Xdata%s%s",page,page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n");
+ printf("uchar ucal%s[%d]={\n", pname[w], MY_UCA_NPAGES);
+ for (page=0; page < MY_UCA_NPAGES; page++)
+ {
+ printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n");
+ }
+ printf("};\n");
+
+
+ printf("uint16 *ucaw%s[%d]={\n", pname[w], MY_UCA_NPAGES);
+ for (page=0; page < MY_UCA_NPAGES; page++)
+ {
+ const char *comma= page < MY_UCA_NPAGES-1 ? "," : "";
+ const char *nline= (page+1) % 4 ? "" : "\n";
+ if (!pagemaxlen[page])
+ 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");
return 0;