home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / CTYPE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  7.7 KB  |  295 lines

  1. /*  ctype.h
  2.  
  3.     Defines the locale aware ctype macros.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 6.0
  9.  *
  10.  *      Copyright (c) 1987, 1993 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. #ifndef __CTYPE_H
  16. #define __CTYPE_H
  17.  
  18. #if !defined(___DEFS_H)
  19. #include <_defs.h>
  20. #endif
  21.  
  22. #if !defined(__FLAT__)
  23.  
  24. #ifndef _SIZE_T
  25. #define _SIZE_T
  26. typedef unsigned size_t;
  27. #endif
  28.  
  29. extern unsigned char _Cdecl _ctype[ 257 ];
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. int _CType isalnum (int __c);
  35. int _CType isalpha (int __c);
  36. int _CType iscntrl (int __c);
  37. int _CType isdigit (int __c);
  38. int _CType isgraph (int __c);
  39. int _CType islower (int __c);
  40. int _CType isprint (int __c);
  41. int _CType ispunct (int __c);
  42. int _CType isspace (int __c);
  43. int _CType isupper (int __c);
  44. int _CType isxdigit(int __c);
  45. int _CType isascii (int __c);
  46.  
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50.  
  51.  
  52. /* character classes */
  53.  
  54. #define _IS_SP     1           /* space */
  55. #define _IS_DIG    2           /* digit */
  56. #define _IS_UPP    4           /* upper case */
  57. #define _IS_LOW    8           /* lower case */
  58. #define _IS_HEX   16           /* [0..9] or [A-F] or [a-f] */
  59. #define _IS_CTL   32           /* control */
  60. #define _IS_PUN   64           /* punctuation */
  61. #define _IS_BLK  128           /* blank */
  62.  
  63. #define _IS_ALPHA    (_IS_UPP | _IS_LOW)
  64. #define _IS_ALNUM    (_IS_DIG | _IS_ALPHA)
  65. #define _IS_GRAPH    (_IS_ALNUM | _IS_HEX | _IS_PUN)
  66.  
  67. #ifndef __USELOCALES__
  68.  
  69. /* C locale character classification macros */
  70.  
  71. #define isalnum(c)   (_ctype[ (c)+1 ] & (_IS_ALNUM))
  72.                      
  73. #define isalpha(c)   (_ctype[ (c)+1 ] & (_IS_ALPHA))
  74.                      
  75. #define iscntrl(c)   (_ctype[ (c)+1 ] & (_IS_CTL))
  76.                      
  77. #define isdigit(c)   (_ctype[ (c)+1 ] & (_IS_DIG))
  78.                      
  79. #define isgraph(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH))
  80.                      
  81. #define islower(c)   (_ctype[ (c)+1 ] & (_IS_LOW))
  82.                      
  83. #define isprint(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH | _IS_BLK))
  84.                      
  85. #define ispunct(c)   (_ctype[ (c)+1 ] & (_IS_PUN))
  86.                      
  87. #define isspace(c)   (_ctype[ (c)+1 ] & (_IS_SP))
  88.                      
  89. #define isupper(c)   (_ctype[ (c)+1 ] & (_IS_UPP))
  90.                      
  91. #define isxdigit(c)  (_ctype[ (c)+1 ] & (_IS_HEX))
  92.  
  93. #endif /* __USELOCALES__ */
  94.  
  95. #define isascii(c)  ((unsigned)(c) < 128)
  96. #define toascii(c)  ((c) & 0x7f)
  97.  
  98. #ifdef __cplusplus
  99. extern "C" {
  100. #endif
  101.  
  102. int _CType tolower(int __ch);
  103. int _CType _ltolower(int __ch);
  104. int _CType toupper(int __ch);
  105. int _CType _ltoupper(int __ch);
  106.  
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110.  
  111. #if !__STDC__
  112. #define _toupper(c) ((c) + 'A' - 'a')
  113. #define _tolower(c) ((c) + 'a' - 'A')
  114. #endif
  115.  
  116. #if defined( __USELOCALES__ )
  117.  
  118. #define toupper    _ltoupper
  119. #define tolower    _ltolower
  120.  
  121. #endif
  122.  
  123. #else  /* defined __FLAT__  */
  124.  
  125. #ifdef __OS2__
  126.  
  127. #define _IS_SP  1           /* is space */
  128. #define _IS_DIG 2           /* is digit indicator */
  129. #define _IS_UPP 4           /* is upper case */
  130. #define _IS_LOW 8           /* is lower case */
  131. #define _IS_HEX 16          /* [0..9] or [A-F] or [a-f] */
  132. #define _IS_CTL 32          /* Control */
  133. #define _IS_PUN 64          /* punctuation */
  134.  
  135. extern  char _RTLENTRY _EXPDATA _ctype[];    /* Character type array */
  136.  
  137. #ifdef __cplusplus
  138. extern "C" {
  139. #endif
  140. int _RTLENTRY _EXPFUNC isalnum (int __c);
  141. int _RTLENTRY _EXPFUNC isalpha (int __c);
  142. int _RTLENTRY _EXPFUNC iscntrl (int __c);
  143. int _RTLENTRY _EXPFUNC isdigit (int __c);
  144. int _RTLENTRY _EXPFUNC isgraph (int __c);
  145. int _RTLENTRY _EXPFUNC islower (int __c);
  146. int _RTLENTRY _EXPFUNC isprint (int __c);
  147. int _RTLENTRY _EXPFUNC ispunct (int __c);
  148. int _RTLENTRY _EXPFUNC isspace (int __c);
  149. int _RTLENTRY _EXPFUNC isupper (int __c);
  150. int _RTLENTRY _EXPFUNC isxdigit(int __c);
  151.  
  152. int _RTLENTRY _EXPFUNC isascii (int __c);
  153.  
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157.  
  158. #define isalnum(c)  (_ctype[(c) + 1] & (_IS_DIG | _IS_UPP | _IS_LOW))
  159. #define isalpha(c)  (_ctype[(c) + 1] & (_IS_UPP | _IS_LOW))
  160. #define iscntrl(c)  (_ctype[(c) + 1] & _IS_CTL)
  161. #define isdigit(c)  (_ctype[(c) + 1] & _IS_DIG)
  162. #define isgraph(c)  ((c) >= 0x21 && (c) <= 0x7e)
  163. #define islower(c)  (_ctype[(c) + 1] & _IS_LOW)
  164. #define isprint(c)  ((c) >= 0x20 && (c) <= 0x7e)
  165. #define ispunct(c)  (_ctype[(c) + 1] & _IS_PUN)
  166. #define isspace(c)  (_ctype[(c) + 1] & _IS_SP)
  167. #define isupper(c)  (_ctype[(c) + 1] & _IS_UPP)
  168. #define isxdigit(c) (_ctype[(c) + 1] & (_IS_DIG | _IS_HEX))
  169.  
  170. #define isascii(c)  ((unsigned)(c) < 128)
  171. #define toascii(c)  ((c) & 0x7f)
  172.  
  173. #if !defined(__STDC__)  /* NON-ANSI */
  174. #define _toupper(c) ((c) + 'A' - 'a')
  175. #define _tolower(c) ((c) + 'a' - 'A')
  176. #endif
  177.  
  178. #ifdef __cplusplus
  179. extern "C" {
  180. #endif
  181. int _RTLENTRYF _EXPFUNC tolower(int __ch);
  182. int _RTLENTRYF _EXPFUNC toupper(int __ch);
  183. #ifdef __cplusplus
  184. }
  185. #endif
  186.  
  187. #else /* not __OS2__ */
  188.  
  189. #ifndef _SIZE_T
  190. #define _SIZE_T
  191. typedef unsigned size_t;
  192. #endif
  193.  
  194. extern unsigned char _RTLENTRY _EXPDATA _ctype[ 257 ];
  195. extern unsigned char _RTLENTRY _EXPDATA _lower[ 256 ];
  196. extern unsigned char _RTLENTRY _EXPDATA _upper[ 256 ];
  197.  
  198. #ifdef __cplusplus
  199. extern "C" {
  200. #endif
  201. int _RTLENTRY _EXPFUNC isalnum (int __c);
  202. int _RTLENTRY _EXPFUNC isalpha (int __c);
  203. int _RTLENTRY _EXPFUNC iscntrl (int __c);
  204. int _RTLENTRY _EXPFUNC isdigit (int __c);
  205. int _RTLENTRY _EXPFUNC isgraph (int __c);
  206. int _RTLENTRY _EXPFUNC islower (int __c);
  207. int _RTLENTRY _EXPFUNC isprint (int __c);
  208. int _RTLENTRY _EXPFUNC ispunct (int __c);
  209. int _RTLENTRY _EXPFUNC isspace (int __c);
  210. int _RTLENTRY _EXPFUNC isupper (int __c);
  211. int _RTLENTRY _EXPFUNC isxdigit(int __c);
  212. int _RTLENTRY _EXPFUNC isascii (int __c);
  213.  
  214. #ifdef __cplusplus
  215. }
  216. #endif
  217.  
  218. /* character classes */
  219.  
  220. #define _IS_SP     1           /* space */
  221. #define _IS_DIG    2           /* digit */
  222. #define _IS_UPP    4           /* upper case */
  223. #define _IS_LOW    8           /* lower case */
  224. #define _IS_HEX   16           /* [0..9] or [A-F] or [a-f] */
  225. #define _IS_CTL   32           /* control */
  226. #define _IS_PUN   64           /* punctuation */
  227. #define _IS_BLK  128           /* blank */
  228.  
  229. #define _IS_ALPHA    (_IS_UPP | _IS_LOW)
  230. #define _IS_ALNUM    (_IS_DIG | _IS_ALPHA)
  231. #define _IS_GRAPH    (_IS_ALNUM | _IS_HEX | _IS_PUN)
  232.  
  233. #ifndef __USELOCALES__
  234.  
  235. /* C locale character classification macros */
  236.  
  237. #define isalnum(c)   (_ctype[ (c)+1 ] & (_IS_ALNUM))
  238.                      
  239. #define isalpha(c)   (_ctype[ (c)+1 ] & (_IS_ALPHA))
  240.                      
  241. #define iscntrl(c)   (_ctype[ (c)+1 ] & (_IS_CTL))
  242.                      
  243. #define isdigit(c)   (_ctype[ (c)+1 ] & (_IS_DIG))
  244.                      
  245. #define isgraph(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH))
  246.                      
  247. #define islower(c)   (_ctype[ (c)+1 ] & (_IS_LOW))
  248.                      
  249. #define isprint(c)   (_ctype[ (c)+1 ] & (_IS_GRAPH | _IS_BLK))
  250.                      
  251. #define ispunct(c)   (_ctype[ (c)+1 ] & (_IS_PUN))
  252.                      
  253. #define isspace(c)   (_ctype[ (c)+1 ] & (_IS_SP))
  254.                      
  255. #define isupper(c)   (_ctype[ (c)+1 ] & (_IS_UPP))
  256.                      
  257. #define isxdigit(c)  (_ctype[ (c)+1 ] & (_IS_HEX))
  258.  
  259. #endif /* __USELOCALES__ */
  260.  
  261. #define isascii(c)  ((unsigned)(c) < 128)
  262. #define toascii(c)  ((c) & 0x7f)
  263.  
  264. #ifdef __cplusplus
  265. extern "C" {
  266. #endif
  267.  
  268. int _RTLENTRY _EXPFUNC tolower(int __ch);
  269. int _RTLENTRY _EXPFUNC _ltolower(int __ch);
  270. int _RTLENTRY _EXPFUNC toupper(int __ch);
  271. int _RTLENTRY _EXPFUNC _ltoupper(int __ch);
  272.  
  273. #if !__STDC__             /* NON-ANSI */
  274. #define _toupper(c) ((c) + 'A' - 'a')
  275. #define _tolower(c) ((c) + 'a' - 'A')
  276. #endif
  277.  
  278.  
  279. #ifdef __cplusplus
  280. }
  281. #endif
  282.  
  283. #if defined( __USELOCALES__ )
  284.  
  285. #define toupper    _ltoupper
  286. #define tolower    _ltolower
  287.  
  288. #endif
  289.  
  290. #endif /* __OS2__   */
  291.  
  292. #endif /* __FLAT__  */
  293.  
  294. #endif /* __CTYPE_H */
  295.