home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / INC.PAK / CTYPE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  7.5 KB  |  288 lines

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