home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / LATTIC_3.LZH / HEADERS / CTYPE.H < prev    next >
C/C++ Source or Header  |  1990-09-24  |  2KB  |  67 lines

  1. /*
  2.  * ctype.h - character typing macros
  3.  *
  4.  * Started 5/9/89 Alex G. Kiernan, based on Lattice source
  5.  *
  6.  * Copyright (c) 1989 HiSoft and Lattice, Inc.
  7.  */
  8.  
  9. #ifndef _CTYPE_H
  10. #define _CTYPE_H
  11.  
  12. #include <fctype.h>
  13.  
  14. /*
  15.  *
  16.  * This header file defines various ASCII character manipulation macros,
  17.  * as follows:
  18.  *
  19.  *        isalpha(c)        non-zero if c is alpha
  20.  *        isupper(c)        non-zero if c is upper case
  21.  *        islower(c)        non-zero if c is lower case
  22.  *        isdigit(c)        non-zero if c is a digit (0 to 9)
  23.  *        isxdigit(c)        non-zero if c is a hexadecimal digit (0 to 9, A to F,
  24.  *                        a to f)
  25.  *        isspace(c)        non-zero if c is white space
  26.  *        ispunct(c)        non-zero if c is punctuation
  27.  *        isalnum(c)        non-zero if c is alpha or digit
  28.  *        isprint(c)        non-zero if c is printable (including blank)
  29.  *        isgraph(c)        non-zero if c is graphic (excluding blank)
  30.  *        iscntrl(c)        non-zero if c is control character
  31.  *        isascii(c)        non-zero if c is ASCII
  32.  *        iscsym(c)        non-zero if valid character for C symbols
  33.  *        iscsymf(c)        non-zero if valid first character for C symbols
  34.  *
  35.  */
  36.  
  37. #define _U 1            /* upper case flag */
  38. #define _L 2            /* lower case flag */
  39. #define _N 4            /* number flag */
  40. #define _S 8            /* space flag */
  41. #define _P 16            /* punctuation flag */
  42. #define _C 32            /* control character flag */
  43. #define _B 64            /* blank flag */
  44. #define _X 128            /* hexadecimal flag */
  45.  
  46. extern char _ctype[257];    /* character type table */
  47.  
  48. #define isalpha(c)        (_ctype[(c)+1]&(_U|_L))
  49. #define isupper(c)        (_ctype[(c)+1]&_U)
  50. #define islower(c)        (_ctype[(c)+1]&_L)
  51. #define isdigit(c)        (_ctype[(c)+1]&_N)
  52. #define isxdigit(c)     (_ctype[(c)+1]&_X)
  53. #define isspace(c)        (_ctype[(c)+1]&_S)
  54. #define ispunct(c)        (_ctype[(c)+1]&_P)
  55. #define isalnum(c)        (_ctype[(c)+1]&(_U|_L|_N))
  56. #define isprint(c)        (_ctype[(c)+1]&(_P|_U|_L|_N|_B))
  57. #define isgraph(c)        (_ctype[(c)+1]&(_P|_U|_L|_N))
  58. #define iscntrl(c)        (_ctype[(c)+1]&_C)
  59. #define isascii(c)        ((unsigned)(c)<=127)
  60. #define iscsym(c)        (isalnum(c)||(((c)&127)==0x5f))
  61. #define iscsymf(c)        (isalpha(c)||(((c)&127)==0x5f))
  62.  
  63. #define _toupper(c)        ((c)-'a'+'A')
  64. #define _tolower(c)        ((c)+'a'-'A')
  65. #define toascii(c)        ((c)&127)
  66. #endif
  67.