home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / readline / chardefs.h next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  4.0 KB  |  148 lines

  1. /* chardefs.h -- Character definitions for readline. */
  2.  
  3. /* Copyright (C) 1994 Free Software Foundation, Inc.
  4.  
  5.    This file is part of the GNU Readline Library, a library for
  6.    reading lines of text with interactive input and history editing.
  7.  
  8.    The GNU Readline Library is free software; you can redistribute it
  9.    and/or modify it under the terms of the GNU General Public License
  10.    as published by the Free Software Foundation; either version 2, or
  11.    (at your option) any later version.
  12.  
  13.    The GNU Readline Library is distributed in the hope that it will be
  14.    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15.    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    The GNU General Public License is often shipped with GNU software, and
  19.    is generally kept in a file called COPYING or LICENSE.  If you do not
  20.    have a copy of the license, write to the Free Software Foundation,
  21.    59 Temple Place, Suite 330, Boston, MA 02111 USA. */
  22.  
  23. #ifndef _CHARDEFS_H_
  24. #define _CHARDEFS_H_
  25.  
  26. #include <ctype.h>
  27.  
  28. #if defined (HAVE_CONFIG_H)
  29. #  if defined (HAVE_STRING_H)
  30. #    include <string.h>
  31. #  else
  32. #    include <strings.h>
  33. #  endif /* HAVE_STRING_H */
  34. #else
  35. #  include <string.h>
  36. #endif /* !HAVE_CONFIG_H */
  37.  
  38. #ifndef whitespace
  39. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  40. #endif
  41.  
  42. #ifdef CTRL
  43. #undef CTRL
  44. #endif
  45.  
  46. /* Some character stuff. */
  47. #define control_character_threshold 0x020   /* Smaller than this is control. */
  48. #define control_character_mask 0x1f        /* 0x20 - 1 */
  49. #define control_character_bit 0x40        /* 0x000000, must be off. */
  50.  
  51. #ifndef __MINGW32__
  52. #define meta_character_threshold 0x07f        /* Larger than this is Meta. */
  53. #define meta_character_bit 0x080        /* x0000000, must be on. */
  54. #define largest_char 255            /* Largest character value. */
  55. #else
  56. #define meta_character_threshold 0x0ff        /* Larger than this is Meta. */
  57. #define meta_character_bit 0x100        /* x0000000, must be on. */
  58. #define largest_char 0x1ff            /* Largest character value. */
  59. #endif
  60.  
  61. #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
  62. #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
  63.  
  64. #define CTRL(c) ((c) & control_character_mask)
  65. #define META(c) ((c) | meta_character_bit)
  66.  
  67. #define UNMETA(c) ((c) & (~meta_character_bit))
  68. #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
  69.  
  70. /* Old versions
  71. #define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
  72. #define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
  73. #define _rl_digit_p(c)  ((c) >= '0' && (c) <= '9')
  74. */
  75.  
  76. #define _rl_lowercase_p(c) (islower(c))
  77. #define _rl_uppercase_p(c) (isupper(c))
  78. #define _rl_digit_p(x)  (isdigit (x))
  79.  
  80. #define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c))
  81. #define ALPHABETIC(c)    (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c))
  82.  
  83. /* Old versions
  84. #  define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c))
  85. #  define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c))
  86. */
  87.  
  88. #ifndef _rl_to_upper
  89. #  define _rl_to_upper(c) (islower(c) ? toupper(c) : (c))
  90. #  define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c))
  91. #endif
  92.  
  93. #ifndef _rl_digit_value
  94. #define _rl_digit_value(x) ((x) - '0')
  95. #endif
  96.  
  97. #ifndef NEWLINE
  98. #define NEWLINE '\n'
  99. #endif
  100.  
  101. #ifndef RETURN
  102. #define RETURN CTRL('M')
  103. #endif
  104.  
  105. #ifndef RUBOUT
  106. #define RUBOUT 0x7f
  107. #endif
  108.  
  109. #ifndef TAB
  110. #define TAB '\t'
  111. #endif
  112.  
  113. #ifdef ABORT_CHAR
  114. #undef ABORT_CHAR
  115. #endif
  116. #define ABORT_CHAR CTRL('G')
  117.  
  118. #ifdef PAGE
  119. #undef PAGE
  120. #endif
  121. #define PAGE CTRL('L')
  122.  
  123. #ifdef SPACE
  124. #undef SPACE
  125. #endif
  126. #define SPACE ' '    /* XXX - was 0x20 */
  127.  
  128. #ifdef ESC
  129. #undef ESC
  130. #endif
  131. #define ESC CTRL('[')
  132.  
  133. #ifndef ISOCTAL
  134. #define ISOCTAL(c)      ((c) >= '0' && (c) <= '7')
  135. #endif
  136. #define OCTVALUE(c)     ((c) - '0')
  137.  
  138. #ifndef isxdigit
  139. #  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
  140. #endif
  141.  
  142. #define HEXVALUE(c) \
  143.   (((c) >= 'a' && (c) <= 'f') \
  144.       ? (c)-'a'+10 \
  145.       : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
  146.  
  147. #endif  /* _CHARDEFS_H_ */
  148.