home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / src / readline / chardefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  3.6 KB  |  129 lines

  1. /* chardefs.h -- changed by Bruno Haible, 22 September 1993 */
  2.  
  3. /* chardefs.h -- Character definitions for readline. */
  4. #ifndef _CHARDEFS_H_
  5. #define _CHARDEFS_H_
  6.  
  7. #ifndef savestring
  8. #define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
  9. #endif
  10.  
  11. #ifndef whitespace
  12. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  13. #endif
  14.  
  15. #ifdef CTRL
  16. #undef CTRL
  17. #endif
  18.  
  19. /* Define ISOLATIN if we are supporting all ISO Latin-1 characters. */
  20. #if defined(linux) || defined(_AIX)
  21. #  define ISOLATIN
  22. #endif
  23.  
  24. /* Define DOSCHARS if we are supporting all the MSDOS character set. */
  25. #if defined(__MSDOS__) || defined(__EMX__) || defined(COHERENT)
  26. #  define DOSCHARS
  27. #endif
  28.  
  29. /* Number of characters in character set. */
  30. #if defined(ISOLATIN) || defined(DOSCHARS)
  31. #  define NUMCHARS 256
  32. #else
  33. #  define NUMCHARS 128
  34. #endif
  35.  
  36. /* Some character stuff. */
  37. #define control_character_threshold 0x020   /* smaller than this is control */
  38. #define meta_character_threshold (NUMCHARS-1) /* larger than this is Meta. */
  39. #define control_character_bit 0x40        /* 0x000000, must be off. */
  40. #define meta_character_bit NUMCHARS        /* x0000000, must be on. */
  41.  
  42. #define CTRL(c) ((c) & (~control_character_bit))
  43. #define META(c) ((c) | meta_character_bit)
  44.  
  45. #define UNMETA(c) ((c) & (~meta_character_bit))
  46. #define UNCTRL(c) to_upper(((c)|control_character_bit))
  47.  
  48. #ifdef ISOLATIN
  49. #define lowercase_p(c) \
  50.   (((c) >= 'a' && (c) <= 'z') || ((c) >= 223 && (c) <= 255 && (c) != 247))
  51. #define uppercase_p(c) \
  52.   (((c) >= 'A' && (c) <= 'Z') || ((c) >= 192 && (c) <= 222 && (c) != 215))
  53. #define to_upper(c) \
  54.   ((c) >= 'a' && (c) <= 'z' ? (c) - 32 : \
  55.    (c) >= 224 && (c) <= 225 && (c) != 247 ? (c) - 32 : \
  56.    (c))
  57. #define to_lower(c) \
  58.   ((c) >= 'A' && (c) <= 'Z' ? (c) + 32 : \
  59.    (c) >= 192 && (c) <= 222 && (c) != 215 ? (c) + 32 : \
  60.    (c))
  61. #else
  62. #ifdef DOSCHARS
  63. #define lowercase_p(c) \
  64.   (((c) >= 'a' && (c) <= 'z')    \
  65.    || ((c) >= 129 && (c) <= 141) \
  66.    || ((c) == 145)               \
  67.    || ((c) >= 147 && (c) <= 152) \
  68.    || ((c) >= 160 && (c) <= 164))
  69. #define uppercase_p(c) \
  70.   (((c) >= 'A' && (c) <= 'Z')    \
  71.    || ((c) == 128)               \
  72.    || ((c) >= 142 && (c) <= 144) \
  73.    || ((c) == 146)               \
  74.    || ((c) >= 153 && (c) <= 154) \
  75.    || ((c) == 165))
  76. #define to_upper(c) \
  77.   ((c) >= 'a' && (c) <= 'z' ? (c) - 32 : \
  78.    (c) == 0x87 ? 0x80 : \
  79.    (c) == 0x81 ? 0x9A : \
  80.    (c) == 0x82 ? 0x90 : \
  81.    (c) == 0x84 ? 0x8E : \
  82.    (c) == 0x86 ? 0x8F : \
  83.    (c) == 0x91 ? 0x92 : \
  84.    (c) == 0x94 ? 0x99 : \
  85.    (c) == 0xA4 ? 0xA5 : \
  86.    (c))
  87. #define to_lower(c) \
  88.   ((c) >= 'A' && (c) <= 'Z' ? (c) + 32 : \
  89.    (c) == 0x80 ? 0x87 : \
  90.    (c) == 0x9A ? 0x81 : \
  91.    (c) == 0x90 ? 0x82 : \
  92.    (c) == 0x8E ? 0x84 : \
  93.    (c) == 0x8F ? 0x86 : \
  94.    (c) == 0x92 ? 0x91 : \
  95.    (c) == 0x99 ? 0x94 : \
  96.    (c) == 0xA5 ? 0xA4 : \
  97.    (c))
  98. #else
  99. #define lowercase_p(c) (((c) >= 'a' && (c) <= 'z'))
  100. #define uppercase_p(c) (((c) >= 'A' && (c) <= 'Z'))
  101. #define to_upper(c) ((c) >= 'a' && (c) <= 'z' ? (c) - 32 : (c))
  102. #define to_lower(c) ((c) >= 'A' && (c) <= 'Z' ? (c) + 32 : (c))
  103. #endif
  104. #endif
  105.  
  106. #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
  107. #define isletter(c) pure_alphabetic(c)
  108.  
  109. #ifndef to_upper
  110. #define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
  111. #define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
  112. #endif
  113.  
  114. #define CTRL_P(c) ((c) < control_character_threshold)
  115. #define META_P(c) ((c) > meta_character_threshold)
  116.  
  117. #ifndef CLISP /* avoid trouble when CLISP includes this file */
  118. #define NEWLINE '\n'
  119. #define RETURN CTRL('M')
  120. #define RUBOUT 0x07f
  121. #define TAB '\t'
  122. #define ABORT_CHAR CTRL('G')
  123. #define PAGE CTRL('L')
  124. #define SPACE 0x020
  125. #define ESC CTRL('[')
  126. #endif
  127.  
  128. #endif  /* _CHARDEFS_H_ */
  129.