m_ctype.h
上传用户:jmzj888
上传日期:2007-01-02
资源大小:220k
文件大小:5k
- /* Copyright (C) 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
- For a more info consult the file COPYRIGHT distributed with this file */
- /*
- A better inplementation of the UNIX ctype(3) library.
- Notes: global.h should be included before ctype.h
- */
- #ifndef _m_ctype_h
- #define _m_ctype_h
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef WIN32
- #include <ctype.h>
- #endif
- /* Don't include std ctype.h when this is included */
- #define _CTYPE_H
- #define __CTYPE_H__
- #ifndef CTYPE_LIBRARY
- #define EXT extern
- #define D(x)
- #else
- #define EXT
- #define D(x) = x
- #endif
- #define _U 01 /* Upper case */
- #define _L 02 /* Lower case */
- #define _N 04 /* Numeral (digit) */
- #define _S 010 /* Spacing character */
- #define _P 020 /* Punctuation */
- #define _C 040 /* Control character */
- #define _B 0100 /* Blank */
- #define _X 0200 /* heXadecimal digit */
- extern uchar NEAR ctype_usa7[];
- extern uchar NEAR to_upper_usa7[],NEAR to_lower_usa7[],NEAR sort_order_usa7[];
- extern uchar NEAR ctype_swe7[];
- extern uchar NEAR to_upper_swe7[],NEAR to_lower_swe7[],NEAR sort_order_swe7[];
- extern uchar NEAR ctype_hp8[];
- extern uchar NEAR to_upper_hp8[],NEAR to_lower_hp8[],NEAR sort_order_hp8[];
- extern uchar NEAR ctype_dec8[];
- extern uchar NEAR to_upper_dec8[],NEAR to_lower_dec8[],NEAR sort_order_dec8[];
- extern uchar NEAR ctype_latin1[];
- extern uchar NEAR to_upper_latin1[],NEAR to_lower_latin1[],
- NEAR sort_order_latin1[];
- #if defined(USE_USA7BITCHARS) +
- defined(USE_SWE7BITCHARS) +
- defined(USE_DEC8BITCHARS) +
- defined(USE_HP8BITCHARS) +
- defined(USE_ISO_8859_1) +
- defined(USE_ISO_8859_2) +
- defined(MSDOS) != 1
- error "More than one USE_xxxnBITCHARS defined"
- #endif
- #if defined(USE_USA7BITCHARS) /* to_*_usa7 is also used directly by other programs */
- EXT uchar *my_ctype D(ctype_usa7);
- EXT uchar *my_to_lower D(to_lower_usa7);
- EXT uchar *my_to_upper D(to_upper_usa7);
- EXT uchar *my_sort_order D(sort_order_usa7);
- #elif defined(USE_SWE7BITCHARS)
- EXT uchar *my_ctype D(ctype_swe7);
- EXT uchar *my_to_upper D(to_upper_swe7);
- EXT uchar *my_to_lower D(to_lower_swe7);
- EXT uchar *my_sort_order D(sort_order_swe7);
- #elif defined(USE_HP8BITCHARS) /* use HPUX internal tables */
- EXT uchar *my_ctype D(ctype_hp8);
- EXT uchar *my_to_upper D(to_upper_hp8);
- EXT uchar *my_to_lower D(to_lower_hp8);
- EXT uchar *my_sort_order D(sort_order_hp8);
- #elif defined(USE_DEC8BITCHARS)
- EXT uchar *my_ctype D(ctype_dec8);
- EXT uchar *my_to_upper D(to_upper_dec8);
- EXT uchar *my_to_lower D(to_lower_dec8);
- EXT uchar *my_sort_order D(sort_order_dec8);
- #elif defined(USE_ISO_8859_1)
- EXT uchar *my_ctype D(ctype_latin1);
- EXT uchar *my_to_upper D(to_upper_latin1);
- EXT uchar *my_to_lower D(to_lower_latin1);
- EXT uchar *my_sort_order D(sort_order_latin1);
- #elif defined(USE_ISO_8859_2)
- EXT uchar *my_ctype D(ctype_ISO_8859_2);
- EXT uchar *my_to_upper D(to_upper_ISO_8859_2);
- EXT uchar *my_to_lower D(to_lower_ISO_8859_2);
- EXT uchar *my_sort_order D(sort_order_ISO_8859_2);
- #elif defined(MSDOS)
- #define my_ctype ctype
- #define my_to_upper to_upper
- #define my_to_lower to_lower
- #define my_sort_order sort_order
- extern uchar NEAR ctype[],NEAR to_lower[],NEAR to_upper[],NEAR sort_order[];
- #endif
- #ifndef WIN32
- #define _toupper(c) (char) my_to_upper[(uchar) (c)]
- #define _tolower(c) (char) my_to_lower[(uchar) (c)]
- #define toupper(c) (char) my_to_upper[(uchar) (c)]
- #define tolower(c) (char) my_to_lower[(uchar) (c)]
- #define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
- #define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
- #define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
- #define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _N)
- #define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
- #define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _N))
- #define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
- #define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _P)
- #define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
- #define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
- #define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
- #define isascii(c) (!((c) & ~0177))
- #define toascii(c) ((c) & 0177)
- #endif
- #ifdef ctype
- #undef ctype
- #endif /* ctype */
- /* These are always used */
- /* Some macros that should be cleaned up a little */
- #define isvar(c) (isalnum(c) || (c) == '_')
- #define isvar_start(c) (isalpha(c) || (c) == '_')
- #define tocntrl(c) ((c) & 31)
- #define toprint(c) ((c) | 64)
- /* Support for Chineze(BIG5) characters, by jou@nematic.ieo.nctu.edu.tw */
- #ifdef USE_BIG5CODE
- #define isbig5head(c) ((((char)c) >= 'xA1') && (((char)c) <= 'xF9'))
- #define isbig5tail(c) ((((char)c) >= 'x40')&&(((char)c) <= 'x7E'))
- || ((((char)c) >= 'xA1')&&(((char)c) <= 'xFE'))
- #define isbig5code(c,d) (((((char)c) >= 'xA1') && (((char)c) <= 'xF9'))
- && (((char)d) >= 'x40')&&(((char)d) <= 'x7E'))
- || ((((char)d) >= 'xA1')&&(((char)d) <= 'xFE')))
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif /* _m_ctype_h */