Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/readline/chardefs.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* chardefs.h -- Character definitions for readline. */
0002 
0003 /* Copyright (C) 1994-2021 Free Software Foundation, Inc.
0004 
0005    This file is part of the GNU Readline Library (Readline), a library
0006    for reading lines of text with interactive input and history editing.
0007 
0008    Readline is free software: you can redistribute it and/or modify
0009    it under the terms of the GNU General Public License as published by
0010    the Free Software Foundation, either version 3 of the License, or
0011    (at your option) any later version.
0012 
0013    Readline is distributed in the hope that it will be useful,
0014    but WITHOUT ANY WARRANTY; without even the implied warranty of
0015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016    GNU General Public License for more details.
0017 
0018    You should have received a copy of the GNU General Public License
0019    along with Readline.  If not, see <http://www.gnu.org/licenses/>.
0020 */
0021 
0022 #ifndef _CHARDEFS_H_
0023 #define _CHARDEFS_H_
0024 
0025 #include <ctype.h>
0026 
0027 #if defined (HAVE_CONFIG_H)
0028 #  if defined (HAVE_STRING_H)
0029 #    include <string.h>
0030 #  endif /* HAVE_STRING_H */
0031 #  if defined (HAVE_STRINGS_H)
0032 #    include <strings.h>
0033 #  endif /* HAVE_STRINGS_H */
0034 #else
0035 #  include <string.h>
0036 #endif /* !HAVE_CONFIG_H */
0037 
0038 #ifndef whitespace
0039 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
0040 #endif
0041 
0042 #ifdef CTRL
0043 #  undef CTRL
0044 #endif
0045 #ifdef UNCTRL
0046 #  undef UNCTRL
0047 #endif
0048 
0049 /* Some character stuff. */
0050 #define control_character_threshold 0x020   /* Smaller than this is control. */
0051 #define control_character_mask 0x1f     /* 0x20 - 1 */
0052 #define meta_character_threshold 0x07f      /* Larger than this is Meta. */
0053 #define control_character_bit 0x40      /* 0x000000, must be off. */
0054 #define meta_character_bit 0x080        /* x0000000, must be on. */
0055 #define largest_char 255            /* Largest character value. */
0056 
0057 #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
0058 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
0059 
0060 #define CTRL(c) ((c) & control_character_mask)
0061 #define META(c) ((c) | meta_character_bit)
0062 
0063 #define UNMETA(c) ((c) & (~meta_character_bit))
0064 #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
0065 
0066 #ifndef UCHAR_MAX
0067 #  define UCHAR_MAX 255
0068 #endif
0069 #ifndef CHAR_MAX
0070 #  define CHAR_MAX 127
0071 #endif
0072 
0073 /* use this as a proxy for C89 */
0074 #if defined (HAVE_STDLIB_H) && defined (HAVE_STRING_H)
0075 #  define IN_CTYPE_DOMAIN(c) 1
0076 #  define NON_NEGATIVE(c) 1
0077 #else
0078 #  define IN_CTYPE_DOMAIN(c) ((c) >= 0 && (c) <= CHAR_MAX)
0079 #  define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
0080 #endif
0081 
0082 #if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus)
0083 #  define isxdigit(c)   (isdigit((unsigned char)(c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
0084 #endif
0085 
0086 /* Some systems define these; we want our definitions. */
0087 #undef ISPRINT
0088 
0089 /* Beware:  these only work with single-byte ASCII characters. */
0090 
0091 #define ISALNUM(c)  (IN_CTYPE_DOMAIN (c) && isalnum ((unsigned char)c))
0092 #define ISALPHA(c)  (IN_CTYPE_DOMAIN (c) && isalpha ((unsigned char)c))
0093 #define ISDIGIT(c)  (IN_CTYPE_DOMAIN (c) && isdigit ((unsigned char)c))
0094 #define ISLOWER(c)  (IN_CTYPE_DOMAIN (c) && islower ((unsigned char)c))
0095 #define ISPRINT(c)  (IN_CTYPE_DOMAIN (c) && isprint ((unsigned char)c))
0096 #define ISUPPER(c)  (IN_CTYPE_DOMAIN (c) && isupper ((unsigned char)c))
0097 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit ((unsigned char)c))
0098 
0099 #define _rl_lowercase_p(c)  (NON_NEGATIVE(c) && ISLOWER(c))
0100 #define _rl_uppercase_p(c)  (NON_NEGATIVE(c) && ISUPPER(c))
0101 #define _rl_digit_p(c)      ((c) >= '0' && (c) <= '9')
0102 
0103 #define _rl_alphabetic_p(c) (NON_NEGATIVE(c) && ISALNUM(c))
0104 #define _rl_pure_alphabetic(c)  (NON_NEGATIVE(c) && ISALPHA(c))
0105 
0106 #ifndef _rl_to_upper
0107 #  define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)(c)) : (c))
0108 #  define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)(c)) : (c))
0109 #endif
0110 
0111 #ifndef _rl_digit_value
0112 #  define _rl_digit_value(x) ((x) - '0')
0113 #endif
0114 
0115 #ifndef _rl_isident
0116 #  define _rl_isident(c) (ISALNUM(c) || (c) == '_')
0117 #endif
0118 
0119 #ifndef ISOCTAL
0120 #  define ISOCTAL(c)    ((c) >= '0' && (c) <= '7')
0121 #endif
0122 #define OCTVALUE(c) ((c) - '0')
0123 
0124 #define HEXVALUE(c) \
0125   (((c) >= 'a' && (c) <= 'f') \
0126     ? (c)-'a'+10 \
0127     : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
0128 
0129 #ifndef NEWLINE
0130 #define NEWLINE '\n'
0131 #endif
0132 
0133 #ifndef RETURN
0134 #define RETURN CTRL('M')
0135 #endif
0136 
0137 #ifndef RUBOUT
0138 #define RUBOUT 0x7f
0139 #endif
0140 
0141 #ifndef TAB
0142 #define TAB '\t'
0143 #endif
0144 
0145 #ifdef ABORT_CHAR
0146 #undef ABORT_CHAR
0147 #endif
0148 #define ABORT_CHAR CTRL('G')
0149 
0150 #ifdef PAGE
0151 #undef PAGE
0152 #endif
0153 #define PAGE CTRL('L')
0154 
0155 #ifdef SPACE
0156 #undef SPACE
0157 #endif
0158 #define SPACE ' '   /* XXX - was 0x20 */
0159 
0160 #ifdef ESC
0161 #undef ESC
0162 #endif
0163 #define ESC CTRL('[')
0164 
0165 #endif  /* _CHARDEFS_H_ */