Annotation of win32/sql/mysql/include/m_ctype.h, revision 1.1
1.1 ! parser 1: /* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
! 2: For a more info consult the file COPYRIGHT distributed with this file */
! 3: /*
! 4: A better inplementation of the UNIX ctype(3) library.
! 5: Notes: global.h should be included before ctype.h
! 6: */
! 7:
! 8: #ifndef _m_ctype_h
! 9: #define _m_ctype_h
! 10:
! 11: #define MY_CHARSET_UNDEFINED 0
! 12: #define MY_CHARSET_BIG5 1
! 13: #define MY_CHARSET_CZECH 2
! 14: #define MY_CHARSET_DEC8 3
! 15: #define MY_CHARSET_DOS 4
! 16: #define MY_CHARSET_GERMAN1 5
! 17: #define MY_CHARSET_HP8 6
! 18: #define MY_CHARSET_KOI8_RU 7
! 19: #define MY_CHARSET_LATIN1 8
! 20: #define MY_CHARSET_LATIN2 9
! 21: #define MY_CHARSET_SWE7 10
! 22: #define MY_CHARSET_USA7 11
! 23: #define MY_CHARSET_UJIS 12
! 24: #define MY_CHARSET_SJIS 13
! 25: #define MY_CHARSET_CP1251 14
! 26: #define MY_CHARSET_DANISH 15
! 27: #define MY_CHARSET_HEBREW 16
! 28: #define MY_CHARSET_WIN1251 17
! 29: #define MY_CHARSET_TIS620 18
! 30: #define MY_CHARSET_EUC_KR 19
! 31: #define MY_CHARSET_ESTONIA 20
! 32: #define MY_CHARSET_HUNGARIAN 21
! 33: #define MY_CHARSET_KOI8_UKR 22
! 34: #define MY_CHARSET_WIN1251UKR 23
! 35: #define MY_CHARSET_GB2312 24
! 36: #define MY_CHARSET_GREEK 25
! 37: #define MY_CHARSET_WIN1250 26
! 38: #define MY_CHARSET_CROAT 27
! 39: #define MY_CHARSET_GBK 28
! 40:
! 41: #ifdef __cplusplus
! 42: extern "C" {
! 43: #endif
! 44:
! 45: #ifdef __WIN32__
! 46: #include <ctype.h>
! 47: #endif
! 48: /* Don't include std ctype.h when this is included */
! 49: #define _CTYPE_H
! 50: #define _CTYPE_INCLUDED
! 51: #define __CTYPE_INCLUDED
! 52: #define _CTYPE_USING /* Don't put names in global namespace. */
! 53:
! 54: #ifndef CTYPE_LIBRARY
! 55: #define EXT extern
! 56: #define D(x)
! 57: #else
! 58: #define EXT
! 59: #define D(x) = x
! 60: #endif
! 61:
! 62: #define _U 01 /* Upper case */
! 63: #define _L 02 /* Lower case */
! 64: #define _N 04 /* Numeral (digit) */
! 65: #define _S 010 /* Spacing character */
! 66: #define _P 020 /* Punctuation */
! 67: #define _C 040 /* Control character */
! 68: #define _B 0100 /* Blank */
! 69: #define _X 0200 /* heXadecimal digit */
! 70:
! 71: extern uchar NEAR ctype_latin1[];
! 72: extern uchar NEAR to_upper_latin1[];
! 73: extern uchar NEAR to_lower_latin1[];
! 74: extern uchar NEAR sort_order_latin1[];
! 75:
! 76: #define my_ctype ctype_latin1
! 77: #define my_to_upper to_upper_latin1
! 78: #define my_to_lower to_lower_latin1
! 79: #define my_sort_order sort_order_latin1
! 80:
! 81: #ifndef __WIN32__
! 82: #define _toupper(c) (char) my_to_upper[(uchar) (c)]
! 83: #define _tolower(c) (char) my_to_lower[(uchar) (c)]
! 84: #define toupper(c) (char) my_to_upper[(uchar) (c)]
! 85: #define tolower(c) (char) my_to_lower[(uchar) (c)]
! 86:
! 87: #define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
! 88: #define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
! 89: #define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
! 90: #define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _N)
! 91: #define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
! 92: #define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _N))
! 93: #define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
! 94: #define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _P)
! 95: #define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
! 96: #define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
! 97: #define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
! 98: #define isascii(c) (!((c) & ~0177))
! 99: #define toascii(c) ((c) & 0177)
! 100:
! 101: #ifdef ctype
! 102: #undef ctype
! 103: #endif /* ctype */
! 104:
! 105: #endif /* __WIN32__ */
! 106:
! 107: /* Some macros that should be cleaned up a little */
! 108: #define isvar(c) (isalnum(c) || (c) == '_')
! 109: #define isvar_start(c) (isalpha(c) || (c) == '_')
! 110: #define tocntrl(c) ((c) & 31)
! 111: #define toprint(c) ((c) | 64)
! 112:
! 113: /* Support for Japanese(UJIS) characters, by tommy@valley.ne.jp */
! 114: #if MY_CHARSET_CURRENT == MY_CHARSET_UJIS
! 115: #define USE_MB
! 116: #define USE_MB_IDENT
! 117: #define isujis(c) ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xfe))
! 118: #define iskata(c) ((0xa1<=((c)&0xff) && ((c)&0xff)<=0xdf))
! 119: #define isujis_ss2(c) (((c)&0xff) == 0x8e)
! 120: #define isujis_ss3(c) (((c)&0xff) == 0x8f)
! 121: #define ismbchar(p, end) ((*(uchar*)(p)<0x80)? 0:\
! 122: isujis(*(p)) && (end)-(p)>1 && isujis(*((p)+1))? 2:\
! 123: isujis_ss2(*(p)) && (end)-(p)>1 && iskata(*((p)+1))? 2:\
! 124: isujis_ss3(*(p)) && (end)-(p)>2 && isujis(*((p)+1)) && isujis(*((p)+2))? 3:\
! 125: 0)
! 126: #define ismbhead(c) (isujis(c) || isujis_ss2(c) || isujis_ss3(c))
! 127: #define mbcharlen(c) (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 0)
! 128: #define MBMAXLEN 3
! 129: #endif
! 130:
! 131: /* Support for Japanese(SJIS) characters, by tommy@valley.ne.jp */
! 132: #if MY_CHARSET_CURRENT == MY_CHARSET_SJIS
! 133: #define USE_MB
! 134: #define USE_MB_IDENT
! 135: #define issjishead(c) ((0x81<=((c)&0xff) && ((c)&0xff)<=0x9f) || (0xe0<=((c)&0xff) && ((c)&0xff)<=0xfc))
! 136: #define issjistail(c) ((0x40<=((c)&0xff) && ((c)&0xff)<=0x7e) || (0x80<=((c)&0xff) && ((c)&0xff)<=0xfc))
! 137: #define ismbchar(p, end) (issjishead(*(p)) && (end)-(p)>1 && issjistail(*((p)+1))? 2: 0)
! 138: #define ismbhead(c) issjishead(c)
! 139: #define mbcharlen(c) (issjishead(c)? 2: 0)
! 140: #define MBMAXLEN 2
! 141: #endif
! 142:
! 143: /* Support for Chinese(BIG5) characters, by jou@nematic.ieo.nctu.edu.tw
! 144: modified by Wei He (hewei@mail.ied.ac.cn) */
! 145:
! 146: #if MY_CHARSET_CURRENT == MY_CHARSET_BIG5
! 147: #define USE_MB
! 148: #define USE_MB_IDENT
! 149: #define isbig5head(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xf9)
! 150: #define isbig5tail(c) ((0x40<=(uchar)(c) && (uchar)(c)<=0x7e) || \
! 151: (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
! 152: #define ismbchar(p, end) (isbig5head(*(p)) && (end)-(p)>1 && isbig5tail(*((p)+1))? 2: 0)
! 153: #define ismbhead(c) isbig5head(c)
! 154: #define mbcharlen(c) (isbig5head(c)? 2: 0)
! 155: #define MBMAXLEN 2
! 156: #
! 157: #undef USE_STRCOLL
! 158: #define USE_STRCOLL
! 159: #endif
! 160:
! 161: /* Support for Chinese(GB2312) characters, by Miles Tsai (net-bull@126.com)
! 162: modified by Wei He (hewei@mail.ied.ac.cn) */
! 163:
! 164: #if MY_CHARSET_CURRENT == MY_CHARSET_GB2312
! 165: #define USE_MB
! 166: #define USE_MB_IDENT
! 167: #define isgb2312head(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xf7)
! 168: #define isgb2312tail(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe)
! 169: #define ismbchar(p, end) (isgb2312head(*(p)) && (end)-(p)>1 && isgb2312tail(*((p)+1))? 2: 0)
! 170: #define ismbhead(c) isgb2312head(c)
! 171: #define mbcharlen(c) (isgb2312head(c)? 2:0)
! 172: #define MBMAXLEN 2
! 173: #endif
! 174:
! 175: /* Support for Chinese(GBK) characters, by hewei@mail.ied.ac.cn */
! 176:
! 177: #if MY_CHARSET_CURRENT == MY_CHARSET_GBK
! 178: #define USE_MB
! 179: #define USE_MB_IDENT
! 180: #define isgbkhead(c) (0x81<=(uchar)(c) && (uchar)(c)<=0xfe)
! 181: #define isgbktail(c) ((0x40<=(uchar)(c) && (uchar)(c)<=0x7e) || \
! 182: (0x80<=(uchar)(c) && (uchar)(c)<=0xfe))
! 183: #define ismbchar(p, end) (isgbkhead(*(p)) && (end)-(p)>1 && isgbktail(*((p)+1))? 2: 0)
! 184: #define ismbhead(c) isgbkhead(c)
! 185: #define mbcharlen(c) (isgbkhead(c)? 2:0)
! 186: #define MBMAXLEN 2
! 187: #undef USE_STRCOLL
! 188: #define USE_STRCOLL
! 189: #endif
! 190:
! 191: /* Define, how much will the string grow under strxfrm */
! 192: #if MY_CHARSET_CURRENT == MY_CHARSET_CZECH
! 193: #undef USE_STRCOLL
! 194: #define USE_STRCOLL
! 195: #endif
! 196: #if MY_CHARSET_CURRENT == MY_CHARSET_TIS620
! 197: #undef USE_STRCOLL
! 198: #define USE_STRCOLL
! 199: #define USE_TIS620
! 200: #include "t_ctype.h"
! 201: #endif
! 202:
! 203: /* Support for Korean(EUC_KR) characters, by powerm90@tinc.co.kr and mrpark@tinc.co.kr */
! 204: #if MY_CHARSET_CURRENT == MY_CHARSET_EUC_KR
! 205: #define USE_MB
! 206: #define USE_MB_IDENT
! 207: #define iseuc_kr(c) ((0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
! 208: #define ismbchar(p, end) ((*(uchar*)(p)<0x80)? 0:\
! 209: iseuc_kr(*(p)) && (end)-(p)>1 && iseuc_kr(*((p)+1))? 2:\
! 210: 0)
! 211: #define ismbhead(c) (iseuc_kr(c))
! 212: #define mbcharlen(c) (iseuc_kr(c) ? 2 : 0)
! 213: #define MBMAXLEN 2
! 214: #endif
! 215:
! 216: #ifdef USE_STRCOLL
! 217: extern uint MY_STRXFRM_MULTIPLY;
! 218: extern int my_strnxfrm(unsigned char *, unsigned char *, int, int);
! 219: extern int my_strnncoll(const unsigned char *, int, const unsigned char *, int);
! 220: extern int my_strxfrm(unsigned char *, unsigned char *, int);
! 221: extern int my_strcoll(const unsigned char *, const unsigned char *);
! 222: extern my_bool my_like_range(const char *ptr,uint ptr_length,pchar escape,
! 223: uint res_length, char *min_str,char *max_str,
! 224: uint *min_length,uint *max_length);
! 225: #endif
! 226:
! 227: #ifdef __cplusplus
! 228: }
! 229: #endif
! 230:
! 231: #endif /* _m_ctype_h */
E-mail: