1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/* Prints case-convert and sort-convert tabell on stdout. This is used to
17
make _ctype.c easyer */
23
#include <my_global.h>
29
uchar to_lower[256], sort_order[256];
31
static int ascii_output=1;
32
static string tab_names[]={ "to_lower[]={","to_upper[]={","sort_order[]={" };
33
static uchar* tabell[]= {to_lower,to_upper,sort_order};
35
void get_options(),init_case_convert();
43
DBUG_PROCESS (argv[0]);
45
get_options(&argc,&argv);
47
puts("Tabells for caseconverts and sorttest of characters\n");
48
for (i=0 ; i < 3 ; i++)
50
printf("uchar %s\n",tab_names[i]);
51
for (j=0 ; j <= 255 ; j++)
53
ch=(int) tabell[i][j];
54
if (ascii_output && isprint(ch) && ! (ch & 128))
56
if (strchr("\\'",(char) ch))
57
printf("'\\%c', ",ch);
62
printf("'\\%03o',",ch);
73
void get_options(argc,argv)
75
register char **argv[];
81
help=0; ascii_output=1;
82
while (--*argc >0 && *(pos = *(++*argv)) == '-' )
88
case 'n': /* Numeric output */
93
*(pos--) = '\0'; /* Skippa argument */
99
printf("%s Ver 1.0\n",progname);
102
puts("Output tabells of to_lower[], to_upper[] and sortorder[]\n");
103
printf("Usage: %s [-n?I]\n",progname);
104
puts("Options: -? or -I \"Info\" -n \"numeric output\"");
107
fprintf(stderr,"illegal option: -%c\n",*pos);
116
/* set up max character for which isupper() and toupper() gives */
117
/* right answer. Is usually 127 or 255 */
119
#ifdef USE_INTERNAL_CTYPE
120
#define MAX_CHAR_OK CHAR_MAX /* All chars is right */
122
#define MAX_CHAR_OK 127 /* 7 Bit ascii */
125
/* Initiate arrays for case-conversation */
127
void init_case_convert()
130
reg2 uchar *higher_pos,*lower_pos;
131
DBUG_ENTER("init_case_convert");
133
for (i=0 ; i <= MAX_CHAR_OK ; i++)
135
to_upper[i]= sort_order[i]= (islower(i) ? toupper(i) : (char) i);
136
to_lower[i]= (isupper(i) ? tolower(i) : (char) i);
138
#if MAX_CHAR_OK != 255
139
for (i--; i++ < 255 ;)
140
to_upper[i]= sort_order[i]= to_lower[i]= (char) i;
144
higher_pos= (uchar *) "\217\216\231\232\220"; /* Extra chars to konv. */
145
lower_pos= (uchar *) "\206\204\224\201\202";
147
#if defined(HPUX10) && ASCII_BITS_USED == 8
148
higher_pos= (uchar *) "\xd0\xd8\xda\xdb\xdc\xd3";
149
lower_pos= (uchar *) "\xd4\xcc\xce\xdf\xc9\xd7";
151
#ifdef USE_INTERNAL_CTYPE
152
higher_pos=lower_pos= (uchar* ) ""; /* System converts chars */
154
#if defined(DEC_MULTINATIONAL_CHAR) || defined(HP_MULTINATIONAL_CHAR)
155
higher_pos= (uchar *) "\305\304\326\311\334";
156
lower_pos= (uchar *) "\345\344\366\351\374";
158
higher_pos= (uchar *) "[]\\@^";
159
lower_pos= (uchar *) "{}|`~";
161
#endif /* USE_INTERNAL_CTYPE */
167
to_upper[ *lower_pos ] = sort_order[ *lower_pos ] = (char) *higher_pos;
168
to_lower[ *higher_pos++ ] = (char) *lower_pos++;
171
/* sets upp sortorder; higer_pos character (upper and lower) is */
172
/* changed to lower_pos character */
175
higher_pos= (uchar *) "\217\216\231\232\220";
176
lower_pos= (uchar *) "\216\217\231YE";
178
#if defined(HPUX10) && ASCII_BITS_USED == 8
179
higher_pos= lower_pos= (uchar *) ""; /* Tecknen i r{tt ordning */
181
#ifdef USE_ISO_8859_1 /* As in USG5 ICL-386 */
182
higher_pos= (uchar *) "\305\304\326\334\311";
183
lower_pos= (uchar *) "\304\305\326YE";
185
higher_pos= (uchar *) "][\\~`"; /* R{tt ordning p} tecknen */
186
lower_pos= (uchar *) "[\\]YE"; /* Ordning enligt ascii */
187
#endif /* USE_ISO_8859_1 */
193
sort_order[ *higher_pos ] =
194
sort_order[(uchar)to_lower[*higher_pos]] = *lower_pos;
195
higher_pos++; lower_pos++;
198
} /* init_case_convert */