22 #include <my_global.h>
27 #define CHARSETS_SUBDIR "sql/share/charsets"
28 #define CTYPE_TABLE_SIZE 257
29 #define TO_LOWER_TABLE_SIZE 256
30 #define TO_UPPER_TABLE_SIZE 256
31 #define SORT_ORDER_TABLE_SIZE 256
34 void print_arrays_for(
char *
set);
37 char buf[1024], *p, *endptr;
40 main(
int argc,
char **argv)
45 fprintf(stderr,
"usage: %s source-dir [charset [, charset]]\n", prog);
51 if (chdir(*argv) != 0) {
52 fprintf(stderr,
"%s: can't cd to %s\n", prog, *argv);
57 if (chdir(CHARSETS_SUBDIR) != 0) {
58 fprintf(stderr,
"%s: can't cd to %s\n", prog, CHARSETS_SUBDIR);
63 print_arrays_for(*argv++);
69 print_array(FILE *f,
const char *
set,
const char *
name,
int n)
74 printf(
"uchar %s_%s[] = {\n", name,
set);
78 for (i = 0; i <
n; ++
i)
84 while (isspace(*endptr))
86 if (*endptr && *endptr !=
'#')
88 if ((fgets(
buf,
sizeof(
buf), f)) == NULL)
94 while (!isspace(*endptr))
101 if (i == 0 || i % ROW_LEN == n % ROW_LEN)
104 printf(
"%3d", (
unsigned char) strtol(val, (
char **) NULL, 16));
109 if ((i+1) % ROW_LEN == n % ROW_LEN)
117 print_arrays_for(
char *
set)
121 sprintf(
buf,
"%s.conf",
set);
123 if ((f = fopen(
buf,
"r")) == NULL) {
124 fprintf(stderr,
"%s: can't read conf file for charset %s\n", prog,
set);
129 /* The %s character set. Generated automatically by configure and\n\
135 print_array(f,
set,
"ctype", CTYPE_TABLE_SIZE);
136 print_array(f,
set,
"to_lower", TO_LOWER_TABLE_SIZE);
137 print_array(f,
set,
"to_upper", TO_UPPER_TABLE_SIZE);
138 print_array(f,
set,
"sort_order", SORT_ORDER_TABLE_SIZE);