00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _CHARDEFS_H_
00024 #define _CHARDEFS_H_
00025
00026 #include <ctype.h>
00027
00028 #if defined (HAVE_CONFIG_H)
00029 # if defined (HAVE_STRING_H)
00030 # if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
00031 # include <memory.h>
00032 # endif
00033 # include <string.h>
00034 # endif
00035 # if defined (HAVE_STRINGS_H)
00036 # include <strings.h>
00037 # endif
00038 #else
00039 # include <string.h>
00040 #endif
00041
00042 #ifndef whitespace
00043 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
00044 #endif
00045
00046 #ifdef CTRL
00047 # undef CTRL
00048 #endif
00049 #ifdef UNCTRL
00050 # undef UNCTRL
00051 #endif
00052
00053
00054 #define control_character_threshold 0x020
00055 #define control_character_mask 0x1f
00056 #define meta_character_threshold 0x07f
00057 #define control_character_bit 0x40
00058 #define meta_character_bit 0x080
00059 #define largest_char 255
00060
00061 #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
00062 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
00063
00064 #define CTRL(c) ((c) & control_character_mask)
00065 #define META(c) ((c) | meta_character_bit)
00066
00067 #define UNMETA(c) ((c) & (~meta_character_bit))
00068 #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
00069
00070 #if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
00071 # define IN_CTYPE_DOMAIN(c) 1
00072 #else
00073 # define IN_CTYPE_DOMAIN(c) isascii(c)
00074 #endif
00075
00076 #if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
00077 # define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
00078 #endif
00079
00080 #if defined (CTYPE_NON_ASCII)
00081 # define NON_NEGATIVE(c) 1
00082 #else
00083 # define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
00084 #endif
00085
00086
00087 #undef ISPRINT
00088
00089
00090
00091 #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
00092 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
00093 #define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
00094 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
00095 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
00096 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
00097 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
00098
00099 #define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
00100 #define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
00101 #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
00102
00103 #define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
00104 #define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
00105
00106 #ifndef _rl_to_upper
00107 # define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
00108 # define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
00109 #endif
00110
00111 #ifndef _rl_digit_value
00112 # define _rl_digit_value(x) ((x) - '0')
00113 #endif
00114
00115 #ifndef _rl_isident
00116 # define _rl_isident(c) (ISALNUM(c) || (c) == '_')
00117 #endif
00118
00119 #ifndef ISOCTAL
00120 # define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
00121 #endif
00122 #define OCTVALUE(c) ((c) - '0')
00123
00124 #define HEXVALUE(c) \
00125 (((c) >= 'a' && (c) <= 'f') \
00126 ? (c)-'a'+10 \
00127 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
00128
00129 #ifndef NEWLINE
00130 #define NEWLINE '\n'
00131 #endif
00132
00133 #ifndef RETURN
00134 #define RETURN CTRL('M')
00135 #endif
00136
00137 #ifndef RUBOUT
00138 #define RUBOUT 0x7f
00139 #endif
00140
00141 #ifndef TAB
00142 #define TAB '\t'
00143 #endif
00144
00145 #ifdef ABORT_CHAR
00146 #undef ABORT_CHAR
00147 #endif
00148 #define ABORT_CHAR CTRL('G')
00149
00150 #ifdef PAGE
00151 #undef PAGE
00152 #endif
00153 #define PAGE CTRL('L')
00154
00155 #ifdef SPACE
00156 #undef SPACE
00157 #endif
00158 #define SPACE ' '
00159
00160 #ifdef ESC
00161 #undef ESC
00162 #endif
00163 #define ESC CTRL('[')
00164
00165 #endif