1 | /* Copyright (C) 2000 MySQL AB |
---|
2 | |
---|
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; either version 2 of the License, or |
---|
6 | (at your option) any later version. |
---|
7 | |
---|
8 | This program is distributed in the hope that it will be useful, |
---|
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | GNU General Public License for more details. |
---|
12 | |
---|
13 | You should have received a copy of the GNU General Public License |
---|
14 | along with this program; if not, write to the Free Software |
---|
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
---|
16 | |
---|
17 | /* |
---|
18 | A better inplementation of the UNIX ctype(3) library. |
---|
19 | Notes: my_global.h should be included before ctype.h |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _m_ctype_h |
---|
23 | #define _m_ctype_h |
---|
24 | |
---|
25 | #ifdef __cplusplus |
---|
26 | extern "C" { |
---|
27 | #endif |
---|
28 | |
---|
29 | #define MY_CS_NAME_SIZE 32 |
---|
30 | #define MY_CS_CTYPE_TABLE_SIZE 257 |
---|
31 | #define MY_CS_TO_LOWER_TABLE_SIZE 256 |
---|
32 | #define MY_CS_TO_UPPER_TABLE_SIZE 256 |
---|
33 | #define MY_CS_SORT_ORDER_TABLE_SIZE 256 |
---|
34 | #define MY_CS_TO_UNI_TABLE_SIZE 256 |
---|
35 | |
---|
36 | #define CHARSET_DIR "charsets/" |
---|
37 | |
---|
38 | #define my_wc_t ulong |
---|
39 | |
---|
40 | typedef struct unicase_info_st |
---|
41 | { |
---|
42 | uint16 toupper; |
---|
43 | uint16 tolower; |
---|
44 | uint16 sort; |
---|
45 | } MY_UNICASE_INFO; |
---|
46 | |
---|
47 | |
---|
48 | extern MY_UNICASE_INFO *my_unicase_default[256]; |
---|
49 | extern MY_UNICASE_INFO *my_unicase_turkish[256]; |
---|
50 | |
---|
51 | |
---|
52 | /* wm_wc and wc_mb return codes */ |
---|
53 | #define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */ |
---|
54 | #define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */ |
---|
55 | #define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */ |
---|
56 | #define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */ |
---|
57 | #define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */ |
---|
58 | /* These following three are currently not really used */ |
---|
59 | #define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */ |
---|
60 | #define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */ |
---|
61 | #define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */ |
---|
62 | /* A helper macros for "need at least n bytes" */ |
---|
63 | #define MY_CS_TOOSMALLN(n) (-100-(n)) |
---|
64 | |
---|
65 | #define MY_SEQ_INTTAIL 1 |
---|
66 | #define MY_SEQ_SPACES 2 |
---|
67 | |
---|
68 | /* My charsets_list flags */ |
---|
69 | #define MY_CS_COMPILED 1 /* compiled-in sets */ |
---|
70 | #define MY_CS_CONFIG 2 /* sets that have a *.conf file */ |
---|
71 | #define MY_CS_INDEX 4 /* sets listed in the Index file */ |
---|
72 | #define MY_CS_LOADED 8 /* sets that are currently loaded */ |
---|
73 | #define MY_CS_BINSORT 16 /* if binary sort order */ |
---|
74 | #define MY_CS_PRIMARY 32 /* if primary collation */ |
---|
75 | #define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */ |
---|
76 | #define MY_CS_UNICODE 128 /* is a charset is full unicode */ |
---|
77 | #define MY_CS_READY 256 /* if a charset is initialized */ |
---|
78 | #define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ |
---|
79 | #define MY_CS_CSSORT 1024 /* if case sensitive sort order */ |
---|
80 | #define MY_CHARSET_UNDEFINED 0 |
---|
81 | |
---|
82 | |
---|
83 | typedef struct my_uni_idx_st |
---|
84 | { |
---|
85 | uint16 from; |
---|
86 | uint16 to; |
---|
87 | uchar *tab; |
---|
88 | } MY_UNI_IDX; |
---|
89 | |
---|
90 | typedef struct |
---|
91 | { |
---|
92 | uint beg; |
---|
93 | uint end; |
---|
94 | uint mblen; |
---|
95 | } my_match_t; |
---|
96 | |
---|
97 | enum my_lex_states |
---|
98 | { |
---|
99 | MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT, |
---|
100 | MY_LEX_IDENT_SEP, MY_LEX_IDENT_START, |
---|
101 | MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER, |
---|
102 | MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END, |
---|
103 | MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL, |
---|
104 | MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE, |
---|
105 | MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON, |
---|
106 | MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP, |
---|
107 | MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR, |
---|
108 | MY_LEX_IDENT_OR_KEYWORD, |
---|
109 | MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR, |
---|
110 | MY_LEX_STRING_OR_DELIMITER |
---|
111 | }; |
---|
112 | |
---|
113 | struct charset_info_st; |
---|
114 | |
---|
115 | typedef struct my_collation_handler_st |
---|
116 | { |
---|
117 | my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); |
---|
118 | /* Collation routines */ |
---|
119 | int (*strnncoll)(struct charset_info_st *, |
---|
120 | const uchar *, uint, const uchar *, uint, my_bool); |
---|
121 | int (*strnncollsp)(struct charset_info_st *, |
---|
122 | const uchar *, uint, const uchar *, uint, |
---|
123 | my_bool diff_if_only_endspace_difference); |
---|
124 | int (*strnxfrm)(struct charset_info_st *, |
---|
125 | uchar *, uint, const uchar *, uint); |
---|
126 | uint (*strnxfrmlen)(struct charset_info_st *, uint); |
---|
127 | my_bool (*like_range)(struct charset_info_st *, |
---|
128 | const char *s, uint s_length, |
---|
129 | pchar w_prefix, pchar w_one, pchar w_many, |
---|
130 | uint res_length, |
---|
131 | char *min_str, char *max_str, |
---|
132 | uint *min_len, uint *max_len); |
---|
133 | int (*wildcmp)(struct charset_info_st *, |
---|
134 | const char *str,const char *str_end, |
---|
135 | const char *wildstr,const char *wildend, |
---|
136 | int escape,int w_one, int w_many); |
---|
137 | |
---|
138 | int (*strcasecmp)(struct charset_info_st *, const char *, const char *); |
---|
139 | |
---|
140 | uint (*instr)(struct charset_info_st *, |
---|
141 | const char *b, uint b_length, |
---|
142 | const char *s, uint s_length, |
---|
143 | my_match_t *match, uint nmatch); |
---|
144 | |
---|
145 | /* Hash calculation */ |
---|
146 | void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len, |
---|
147 | ulong *nr1, ulong *nr2); |
---|
148 | my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len); |
---|
149 | } MY_COLLATION_HANDLER; |
---|
150 | |
---|
151 | extern MY_COLLATION_HANDLER my_collation_mb_bin_handler; |
---|
152 | extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler; |
---|
153 | extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; |
---|
154 | extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; |
---|
155 | |
---|
156 | |
---|
157 | typedef struct my_charset_handler_st |
---|
158 | { |
---|
159 | my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); |
---|
160 | /* Multibyte routines */ |
---|
161 | int (*ismbchar)(struct charset_info_st *, const char *, const char *); |
---|
162 | int (*mbcharlen)(struct charset_info_st *, uint); |
---|
163 | uint (*numchars)(struct charset_info_st *, const char *b, const char *e); |
---|
164 | uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); |
---|
165 | uint (*well_formed_len)(struct charset_info_st *, |
---|
166 | const char *b,const char *e, |
---|
167 | uint nchars, int *error); |
---|
168 | uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); |
---|
169 | uint (*numcells)(struct charset_info_st *, const char *b, const char *e); |
---|
170 | |
---|
171 | /* Unicode convertion */ |
---|
172 | int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc, |
---|
173 | const unsigned char *s,const unsigned char *e); |
---|
174 | int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc, |
---|
175 | unsigned char *s,unsigned char *e); |
---|
176 | |
---|
177 | /* Functions for case and sort convertion */ |
---|
178 | void (*caseup_str)(struct charset_info_st *, char *); |
---|
179 | void (*casedn_str)(struct charset_info_st *, char *); |
---|
180 | uint (*caseup)(struct charset_info_st *, char *src, uint srclen, |
---|
181 | char *dst, uint dstlen); |
---|
182 | uint (*casedn)(struct charset_info_st *, char *src, uint srclen, |
---|
183 | char *dst, uint dstlen); |
---|
184 | |
---|
185 | /* Charset dependant snprintf() */ |
---|
186 | int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, |
---|
187 | ...); |
---|
188 | int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix, |
---|
189 | long int val); |
---|
190 | int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, |
---|
191 | int radix, longlong val); |
---|
192 | |
---|
193 | void (*fill)(struct charset_info_st *, char *to, uint len, int fill); |
---|
194 | |
---|
195 | /* String-to-number convertion routines */ |
---|
196 | long (*strntol)(struct charset_info_st *, const char *s, uint l, |
---|
197 | int base, char **e, int *err); |
---|
198 | ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, |
---|
199 | int base, char **e, int *err); |
---|
200 | longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, |
---|
201 | int base, char **e, int *err); |
---|
202 | ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l, |
---|
203 | int base, char **e, int *err); |
---|
204 | double (*strntod)(struct charset_info_st *, char *s, uint l, char **e, |
---|
205 | int *err); |
---|
206 | longlong (*strtoll10)(struct charset_info_st *cs, |
---|
207 | const char *nptr, char **endptr, int *error); |
---|
208 | ulong (*scan)(struct charset_info_st *, const char *b, const char *e, |
---|
209 | int sq); |
---|
210 | } MY_CHARSET_HANDLER; |
---|
211 | |
---|
212 | extern MY_CHARSET_HANDLER my_charset_8bit_handler; |
---|
213 | extern MY_CHARSET_HANDLER my_charset_ucs2_handler; |
---|
214 | |
---|
215 | |
---|
216 | typedef struct charset_info_st |
---|
217 | { |
---|
218 | uint number; |
---|
219 | uint primary_number; |
---|
220 | uint binary_number; |
---|
221 | uint state; |
---|
222 | const char *csname; |
---|
223 | const char *name; |
---|
224 | const char *comment; |
---|
225 | const char *tailoring; |
---|
226 | uchar *ctype; |
---|
227 | uchar *to_lower; |
---|
228 | uchar *to_upper; |
---|
229 | uchar *sort_order; |
---|
230 | uint16 *contractions; |
---|
231 | uint16 **sort_order_big; |
---|
232 | uint16 *tab_to_uni; |
---|
233 | MY_UNI_IDX *tab_from_uni; |
---|
234 | MY_UNICASE_INFO **caseinfo; |
---|
235 | uchar *state_map; |
---|
236 | uchar *ident_map; |
---|
237 | uint strxfrm_multiply; |
---|
238 | uchar caseup_multiply; |
---|
239 | uchar casedn_multiply; |
---|
240 | uint mbminlen; |
---|
241 | uint mbmaxlen; |
---|
242 | uint16 min_sort_char; |
---|
243 | uint16 max_sort_char; /* For LIKE optimization */ |
---|
244 | uchar pad_char; |
---|
245 | my_bool escape_with_backslash_is_dangerous; |
---|
246 | |
---|
247 | MY_CHARSET_HANDLER *cset; |
---|
248 | MY_COLLATION_HANDLER *coll; |
---|
249 | |
---|
250 | } CHARSET_INFO; |
---|
251 | |
---|
252 | |
---|
253 | extern CHARSET_INFO my_charset_bin; |
---|
254 | extern CHARSET_INFO my_charset_big5_chinese_ci; |
---|
255 | extern CHARSET_INFO my_charset_big5_bin; |
---|
256 | extern CHARSET_INFO my_charset_cp932_japanese_ci; |
---|
257 | extern CHARSET_INFO my_charset_cp932_bin; |
---|
258 | extern CHARSET_INFO my_charset_eucjpms_japanese_ci; |
---|
259 | extern CHARSET_INFO my_charset_eucjpms_bin; |
---|
260 | extern CHARSET_INFO my_charset_euckr_korean_ci; |
---|
261 | extern CHARSET_INFO my_charset_euckr_bin; |
---|
262 | extern CHARSET_INFO my_charset_gb2312_chinese_ci; |
---|
263 | extern CHARSET_INFO my_charset_gb2312_bin; |
---|
264 | extern CHARSET_INFO my_charset_gbk_chinese_ci; |
---|
265 | extern CHARSET_INFO my_charset_gbk_bin; |
---|
266 | extern CHARSET_INFO my_charset_latin1; |
---|
267 | extern CHARSET_INFO my_charset_latin1_german2_ci; |
---|
268 | extern CHARSET_INFO my_charset_latin1_bin; |
---|
269 | extern CHARSET_INFO my_charset_latin2_czech_ci; |
---|
270 | extern CHARSET_INFO my_charset_sjis_japanese_ci; |
---|
271 | extern CHARSET_INFO my_charset_sjis_bin; |
---|
272 | extern CHARSET_INFO my_charset_tis620_thai_ci; |
---|
273 | extern CHARSET_INFO my_charset_tis620_bin; |
---|
274 | extern CHARSET_INFO my_charset_ucs2_general_ci; |
---|
275 | extern CHARSET_INFO my_charset_ucs2_bin; |
---|
276 | extern CHARSET_INFO my_charset_ucs2_general_uca; |
---|
277 | extern CHARSET_INFO my_charset_ujis_japanese_ci; |
---|
278 | extern CHARSET_INFO my_charset_ujis_bin; |
---|
279 | extern CHARSET_INFO my_charset_utf8_general_ci; |
---|
280 | extern CHARSET_INFO my_charset_utf8_bin; |
---|
281 | extern CHARSET_INFO my_charset_cp1250_czech_ci; |
---|
282 | |
---|
283 | /* declarations for simple charsets */ |
---|
284 | extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, |
---|
285 | uint); |
---|
286 | uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); |
---|
287 | extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, |
---|
288 | const uchar *, uint, my_bool); |
---|
289 | |
---|
290 | extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint, |
---|
291 | const uchar *, uint, |
---|
292 | my_bool diff_if_only_endspace_difference); |
---|
293 | |
---|
294 | extern void my_hash_sort_simple(CHARSET_INFO *cs, |
---|
295 | const uchar *key, uint len, |
---|
296 | ulong *nr1, ulong *nr2); |
---|
297 | |
---|
298 | extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length); |
---|
299 | |
---|
300 | extern uint my_instr_simple(struct charset_info_st *, |
---|
301 | const char *b, uint b_length, |
---|
302 | const char *s, uint s_length, |
---|
303 | my_match_t *match, uint nmatch); |
---|
304 | |
---|
305 | |
---|
306 | /* Functions for 8bit */ |
---|
307 | extern void my_caseup_str_8bit(CHARSET_INFO *, char *); |
---|
308 | extern void my_casedn_str_8bit(CHARSET_INFO *, char *); |
---|
309 | extern uint my_caseup_8bit(CHARSET_INFO *, char *src, uint srclen, |
---|
310 | char *dst, uint dstlen); |
---|
311 | extern uint my_casedn_8bit(CHARSET_INFO *, char *src, uint srclen, |
---|
312 | char *dst, uint dstlen); |
---|
313 | |
---|
314 | extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *); |
---|
315 | |
---|
316 | int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e); |
---|
317 | int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e); |
---|
318 | |
---|
319 | ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); |
---|
320 | |
---|
321 | int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, |
---|
322 | const char *fmt, ...); |
---|
323 | |
---|
324 | long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base, |
---|
325 | char **e, int *err); |
---|
326 | ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base, |
---|
327 | char **e, int *err); |
---|
328 | longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base, |
---|
329 | char **e, int *err); |
---|
330 | ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base, |
---|
331 | char **e, int *err); |
---|
332 | double my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e, |
---|
333 | int *err); |
---|
334 | int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, |
---|
335 | long int val); |
---|
336 | int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, |
---|
337 | longlong val); |
---|
338 | |
---|
339 | longlong my_strtoll10_8bit(CHARSET_INFO *cs, |
---|
340 | const char *nptr, char **endptr, int *error); |
---|
341 | longlong my_strtoll10_ucs2(CHARSET_INFO *cs, |
---|
342 | const char *nptr, char **endptr, int *error); |
---|
343 | |
---|
344 | void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); |
---|
345 | |
---|
346 | my_bool my_like_range_simple(CHARSET_INFO *cs, |
---|
347 | const char *ptr, uint ptr_length, |
---|
348 | pbool escape, pbool w_one, pbool w_many, |
---|
349 | uint res_length, |
---|
350 | char *min_str, char *max_str, |
---|
351 | uint *min_length, uint *max_length); |
---|
352 | |
---|
353 | my_bool my_like_range_mb(CHARSET_INFO *cs, |
---|
354 | const char *ptr, uint ptr_length, |
---|
355 | pbool escape, pbool w_one, pbool w_many, |
---|
356 | uint res_length, |
---|
357 | char *min_str, char *max_str, |
---|
358 | uint *min_length, uint *max_length); |
---|
359 | |
---|
360 | my_bool my_like_range_ucs2(CHARSET_INFO *cs, |
---|
361 | const char *ptr, uint ptr_length, |
---|
362 | pbool escape, pbool w_one, pbool w_many, |
---|
363 | uint res_length, |
---|
364 | char *min_str, char *max_str, |
---|
365 | uint *min_length, uint *max_length); |
---|
366 | |
---|
367 | |
---|
368 | int my_wildcmp_8bit(CHARSET_INFO *, |
---|
369 | const char *str,const char *str_end, |
---|
370 | const char *wildstr,const char *wildend, |
---|
371 | int escape, int w_one, int w_many); |
---|
372 | |
---|
373 | int my_wildcmp_bin(CHARSET_INFO *, |
---|
374 | const char *str,const char *str_end, |
---|
375 | const char *wildstr,const char *wildend, |
---|
376 | int escape, int w_one, int w_many); |
---|
377 | |
---|
378 | uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); |
---|
379 | uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); |
---|
380 | uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); |
---|
381 | uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, |
---|
382 | uint pos, int *error); |
---|
383 | int my_mbcharlen_8bit(CHARSET_INFO *, uint c); |
---|
384 | |
---|
385 | |
---|
386 | /* Functions for multibyte charsets */ |
---|
387 | extern void my_caseup_str_mb(CHARSET_INFO *, char *); |
---|
388 | extern void my_casedn_str_mb(CHARSET_INFO *, char *); |
---|
389 | extern uint my_caseup_mb(CHARSET_INFO *, char *src, uint srclen, |
---|
390 | char *dst, uint dstlen); |
---|
391 | extern uint my_casedn_mb(CHARSET_INFO *, char *src, uint srclen, |
---|
392 | char *dst, uint dstlen); |
---|
393 | extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *); |
---|
394 | |
---|
395 | int my_wildcmp_mb(CHARSET_INFO *, |
---|
396 | const char *str,const char *str_end, |
---|
397 | const char *wildstr,const char *wildend, |
---|
398 | int escape, int w_one, int w_many); |
---|
399 | uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); |
---|
400 | uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); |
---|
401 | uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); |
---|
402 | uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, |
---|
403 | uint pos, int *error); |
---|
404 | uint my_instr_mb(struct charset_info_st *, |
---|
405 | const char *b, uint b_length, |
---|
406 | const char *s, uint s_length, |
---|
407 | my_match_t *match, uint nmatch); |
---|
408 | |
---|
409 | int my_wildcmp_unicode(CHARSET_INFO *cs, |
---|
410 | const char *str, const char *str_end, |
---|
411 | const char *wildstr, const char *wildend, |
---|
412 | int escape, int w_one, int w_many, |
---|
413 | MY_UNICASE_INFO **weights); |
---|
414 | |
---|
415 | extern my_bool my_parse_charset_xml(const char *bug, uint len, |
---|
416 | int (*add)(CHARSET_INFO *cs)); |
---|
417 | |
---|
418 | my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len); |
---|
419 | my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len); |
---|
420 | |
---|
421 | |
---|
422 | #define _MY_U 01 /* Upper case */ |
---|
423 | #define _MY_L 02 /* Lower case */ |
---|
424 | #define _MY_NMR 04 /* Numeral (digit) */ |
---|
425 | #define _MY_SPC 010 /* Spacing character */ |
---|
426 | #define _MY_PNT 020 /* Punctuation */ |
---|
427 | #define _MY_CTR 040 /* Control character */ |
---|
428 | #define _MY_B 0100 /* Blank */ |
---|
429 | #define _MY_X 0200 /* heXadecimal digit */ |
---|
430 | |
---|
431 | |
---|
432 | #define my_isascii(c) (!((c) & ~0177)) |
---|
433 | #define my_toascii(c) ((c) & 0177) |
---|
434 | #define my_tocntrl(c) ((c) & 31) |
---|
435 | #define my_toprint(c) ((c) | 64) |
---|
436 | #define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)]) |
---|
437 | #define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)]) |
---|
438 | #define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L)) |
---|
439 | #define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U) |
---|
440 | #define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L) |
---|
441 | #define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR) |
---|
442 | #define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X) |
---|
443 | #define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR)) |
---|
444 | #define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC) |
---|
445 | #define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT) |
---|
446 | #define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B)) |
---|
447 | #define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR)) |
---|
448 | #define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR) |
---|
449 | |
---|
450 | /* Some macros that should be cleaned up a little */ |
---|
451 | #define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_') |
---|
452 | #define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_') |
---|
453 | |
---|
454 | #define my_binary_compare(s) ((s)->state & MY_CS_BINSORT) |
---|
455 | #define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM) |
---|
456 | #define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d))) |
---|
457 | #define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0)) |
---|
458 | #define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \ |
---|
459 | ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j))) |
---|
460 | #define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m))) |
---|
461 | #define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b))) |
---|
462 | #define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num)) |
---|
463 | |
---|
464 | |
---|
465 | #define use_mb(s) ((s)->cset->ismbchar != NULL) |
---|
466 | #define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b))) |
---|
467 | #ifdef USE_MB |
---|
468 | #define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a))) |
---|
469 | #else |
---|
470 | #define my_mbcharlen(s, a) 1 |
---|
471 | #endif |
---|
472 | |
---|
473 | #define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a))) |
---|
474 | #define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a))) |
---|
475 | #define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e))) |
---|
476 | #define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e))) |
---|
477 | #define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e))) |
---|
478 | #define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e))) |
---|
479 | #define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d))) |
---|
480 | |
---|
481 | |
---|
482 | /* XXX: still need to take care of this one */ |
---|
483 | #ifdef MY_CHARSET_TIS620 |
---|
484 | #error The TIS620 charset is broken at the moment. Tell tim to fix it. |
---|
485 | #define USE_TIS620 |
---|
486 | #include "t_ctype.h" |
---|
487 | #endif |
---|
488 | |
---|
489 | #ifdef __cplusplus |
---|
490 | } |
---|
491 | #endif |
---|
492 | |
---|
493 | #endif /* _m_ctype_h */ |
---|