home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6574.LZX / include / ctype.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-04  |  3.0 KB  |  111 lines

  1. /* Copyright (c) 1992-1993 SAS Institute, Inc., Cary, NC USA */
  2. /* All Rights Reserved. */
  3.  
  4.  
  5. /**
  6. *
  7. * This header file defines various ASCII character manipulation macros,
  8. * as follows:
  9. *
  10. *       isalpha(c)    non-zero if c is alpha
  11. *       isupper(c)    non-zero if c is upper case
  12. *       islower(c)    non-zero if c is lower case
  13. *       isdigit(c)    non-zero if c is a digit (0 to 9)
  14. *       isxdigit(c)   non-zero if c is a hexadecimal digit (0 to 9, A to F,
  15. *                   a to f)
  16. *       isspace(c)    non-zero if c is white space
  17. *       ispunct(c)    non-zero if c is punctuation
  18. *       isalnum(c)    non-zero if c is alpha or digit
  19. *       isprint(c)    non-zero if c is printable (including blank)
  20. *       isgraph(c)    non-zero if c is graphic (excluding blank)
  21. *       iscntrl(c)    non-zero if c is control character
  22. *       isascii(c)    non-zero if c is ASCII
  23. *       iscsym(c)     non-zero if valid character for C symbols
  24. *       iscsymf(c)    non-zero if valid first character for C symbols
  25. *
  26. **/
  27.  
  28. #undef isalnum
  29. #undef isalpha
  30. #undef iscntrl
  31. #undef isdigit
  32. #undef isgraph
  33. #undef islower
  34. #undef isprint
  35. #undef ispunct
  36. #undef isspace
  37. #undef isupper
  38. #undef isxdigit
  39. #undef tolower
  40. #undef toupper
  41.  
  42. extern int isalnum(int);
  43. extern int isalpha(int);
  44. extern int iscntrl(int);
  45. extern int isdigit(int);
  46. extern int isgraph(int);
  47. extern int islower(int);
  48. extern int isprint(int);
  49. extern int ispunct(int);
  50. extern int isspace(int);
  51. extern int isupper(int);
  52. extern int isxdigit(int);
  53.  
  54. extern int tolower(int);
  55. extern int toupper(int);
  56.  
  57. #define _U 1          /* upper case flag */
  58. #define _L 2          /* lower case flag */
  59. #define _N 4          /* number flag */
  60. #define _S 8          /* space flag */
  61. #define _P 16         /* punctuation flag */
  62. #define _C 32         /* control character flag */
  63. #define _B 64         /* blank flag */
  64. #define _X 128        /* hexadecimal flag */
  65.  
  66. extern char __ctype[];   /* character type table */
  67.  
  68. #define isalnum(c)      (__ctype[(c)+1] & (_U|_L|_N))
  69. #define isalpha(c)      (__ctype[(c)+1] & (_U|_L))
  70. #define iscntrl(c)      (__ctype[(c)+1] & _C)
  71. #define isdigit(c)      (__ctype[(c)+1] & _N)
  72. #define isgraph(c)      (__ctype[(c)+1] & (_P|_U|_L|_N))
  73. #define islower(c)      (__ctype[(c)+1] & _L)
  74. #define isprint(c)      (__ctype[(c)+1] & (_P|_U|_L|_N|_B))
  75. #define ispunct(c)      (__ctype[(c)+1] & _P)
  76. #define isspace(c)      (__ctype[(c)+1] & _S)
  77. #define isupper(c)      (__ctype[(c)+1] & _U)
  78. #define isxdigit(c)     (__ctype[(c)+1] & _X)
  79.  
  80. #define tolower(c)     (isupper(c) ? ((c)+('a'-'A')) : (c))
  81. #define toupper(c)     (islower(c) ? ((c)-('a'-'A')) : (c))
  82.  
  83. #ifndef _STRICT_ANSI
  84.  
  85. /****
  86. *
  87. *   Extensions to the ANSI standard.
  88. *
  89. *
  90. ****/
  91.  
  92. #undef isascii
  93. #undef iscsym
  94. #undef iscsymf
  95. #undef toascii
  96.  
  97. extern int isascii(int);
  98. extern int iscsym(int);
  99. extern int iscsymf(int);
  100.  
  101. extern int toascii(int);
  102.  
  103.  
  104. #define isascii(c)      ((unsigned)(c) <= 127)
  105. #define iscsym(c)       (isalnum(c)||(((c) & 127) == 0x5f))
  106. #define iscsymf(c)      (isalpha(c)||(((c) & 127) == 0x5f))
  107.  
  108. #define toascii(c)      ((c) & 127)
  109.  
  110. #endif /* _STRICT_ANSI */
  111.