annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/readline/chardefs.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* chardefs.h -- Character definitions for readline. */
jpayne@69 2
jpayne@69 3 /* Copyright (C) 1994-2021 Free Software Foundation, Inc.
jpayne@69 4
jpayne@69 5 This file is part of the GNU Readline Library (Readline), a library
jpayne@69 6 for reading lines of text with interactive input and history editing.
jpayne@69 7
jpayne@69 8 Readline is free software: you can redistribute it and/or modify
jpayne@69 9 it under the terms of the GNU General Public License as published by
jpayne@69 10 the Free Software Foundation, either version 3 of the License, or
jpayne@69 11 (at your option) any later version.
jpayne@69 12
jpayne@69 13 Readline is distributed in the hope that it will be useful,
jpayne@69 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
jpayne@69 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jpayne@69 16 GNU General Public License for more details.
jpayne@69 17
jpayne@69 18 You should have received a copy of the GNU General Public License
jpayne@69 19 along with Readline. If not, see <http://www.gnu.org/licenses/>.
jpayne@69 20 */
jpayne@69 21
jpayne@69 22 #ifndef _CHARDEFS_H_
jpayne@69 23 #define _CHARDEFS_H_
jpayne@69 24
jpayne@69 25 #include <ctype.h>
jpayne@69 26
jpayne@69 27 #if defined (HAVE_CONFIG_H)
jpayne@69 28 # if defined (HAVE_STRING_H)
jpayne@69 29 # include <string.h>
jpayne@69 30 # endif /* HAVE_STRING_H */
jpayne@69 31 # if defined (HAVE_STRINGS_H)
jpayne@69 32 # include <strings.h>
jpayne@69 33 # endif /* HAVE_STRINGS_H */
jpayne@69 34 #else
jpayne@69 35 # include <string.h>
jpayne@69 36 #endif /* !HAVE_CONFIG_H */
jpayne@69 37
jpayne@69 38 #ifndef whitespace
jpayne@69 39 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
jpayne@69 40 #endif
jpayne@69 41
jpayne@69 42 #ifdef CTRL
jpayne@69 43 # undef CTRL
jpayne@69 44 #endif
jpayne@69 45 #ifdef UNCTRL
jpayne@69 46 # undef UNCTRL
jpayne@69 47 #endif
jpayne@69 48
jpayne@69 49 /* Some character stuff. */
jpayne@69 50 #define control_character_threshold 0x020 /* Smaller than this is control. */
jpayne@69 51 #define control_character_mask 0x1f /* 0x20 - 1 */
jpayne@69 52 #define meta_character_threshold 0x07f /* Larger than this is Meta. */
jpayne@69 53 #define control_character_bit 0x40 /* 0x000000, must be off. */
jpayne@69 54 #define meta_character_bit 0x080 /* x0000000, must be on. */
jpayne@69 55 #define largest_char 255 /* Largest character value. */
jpayne@69 56
jpayne@69 57 #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
jpayne@69 58 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
jpayne@69 59
jpayne@69 60 #define CTRL(c) ((c) & control_character_mask)
jpayne@69 61 #define META(c) ((c) | meta_character_bit)
jpayne@69 62
jpayne@69 63 #define UNMETA(c) ((c) & (~meta_character_bit))
jpayne@69 64 #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
jpayne@69 65
jpayne@69 66 #ifndef UCHAR_MAX
jpayne@69 67 # define UCHAR_MAX 255
jpayne@69 68 #endif
jpayne@69 69 #ifndef CHAR_MAX
jpayne@69 70 # define CHAR_MAX 127
jpayne@69 71 #endif
jpayne@69 72
jpayne@69 73 /* use this as a proxy for C89 */
jpayne@69 74 #if defined (HAVE_STDLIB_H) && defined (HAVE_STRING_H)
jpayne@69 75 # define IN_CTYPE_DOMAIN(c) 1
jpayne@69 76 # define NON_NEGATIVE(c) 1
jpayne@69 77 #else
jpayne@69 78 # define IN_CTYPE_DOMAIN(c) ((c) >= 0 && (c) <= CHAR_MAX)
jpayne@69 79 # define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
jpayne@69 80 #endif
jpayne@69 81
jpayne@69 82 #if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus)
jpayne@69 83 # define isxdigit(c) (isdigit((unsigned char)(c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
jpayne@69 84 #endif
jpayne@69 85
jpayne@69 86 /* Some systems define these; we want our definitions. */
jpayne@69 87 #undef ISPRINT
jpayne@69 88
jpayne@69 89 /* Beware: these only work with single-byte ASCII characters. */
jpayne@69 90
jpayne@69 91 #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum ((unsigned char)c))
jpayne@69 92 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha ((unsigned char)c))
jpayne@69 93 #define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit ((unsigned char)c))
jpayne@69 94 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower ((unsigned char)c))
jpayne@69 95 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint ((unsigned char)c))
jpayne@69 96 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper ((unsigned char)c))
jpayne@69 97 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit ((unsigned char)c))
jpayne@69 98
jpayne@69 99 #define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
jpayne@69 100 #define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
jpayne@69 101 #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
jpayne@69 102
jpayne@69 103 #define _rl_alphabetic_p(c) (NON_NEGATIVE(c) && ISALNUM(c))
jpayne@69 104 #define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
jpayne@69 105
jpayne@69 106 #ifndef _rl_to_upper
jpayne@69 107 # define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)(c)) : (c))
jpayne@69 108 # define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)(c)) : (c))
jpayne@69 109 #endif
jpayne@69 110
jpayne@69 111 #ifndef _rl_digit_value
jpayne@69 112 # define _rl_digit_value(x) ((x) - '0')
jpayne@69 113 #endif
jpayne@69 114
jpayne@69 115 #ifndef _rl_isident
jpayne@69 116 # define _rl_isident(c) (ISALNUM(c) || (c) == '_')
jpayne@69 117 #endif
jpayne@69 118
jpayne@69 119 #ifndef ISOCTAL
jpayne@69 120 # define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
jpayne@69 121 #endif
jpayne@69 122 #define OCTVALUE(c) ((c) - '0')
jpayne@69 123
jpayne@69 124 #define HEXVALUE(c) \
jpayne@69 125 (((c) >= 'a' && (c) <= 'f') \
jpayne@69 126 ? (c)-'a'+10 \
jpayne@69 127 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
jpayne@69 128
jpayne@69 129 #ifndef NEWLINE
jpayne@69 130 #define NEWLINE '\n'
jpayne@69 131 #endif
jpayne@69 132
jpayne@69 133 #ifndef RETURN
jpayne@69 134 #define RETURN CTRL('M')
jpayne@69 135 #endif
jpayne@69 136
jpayne@69 137 #ifndef RUBOUT
jpayne@69 138 #define RUBOUT 0x7f
jpayne@69 139 #endif
jpayne@69 140
jpayne@69 141 #ifndef TAB
jpayne@69 142 #define TAB '\t'
jpayne@69 143 #endif
jpayne@69 144
jpayne@69 145 #ifdef ABORT_CHAR
jpayne@69 146 #undef ABORT_CHAR
jpayne@69 147 #endif
jpayne@69 148 #define ABORT_CHAR CTRL('G')
jpayne@69 149
jpayne@69 150 #ifdef PAGE
jpayne@69 151 #undef PAGE
jpayne@69 152 #endif
jpayne@69 153 #define PAGE CTRL('L')
jpayne@69 154
jpayne@69 155 #ifdef SPACE
jpayne@69 156 #undef SPACE
jpayne@69 157 #endif
jpayne@69 158 #define SPACE ' ' /* XXX - was 0x20 */
jpayne@69 159
jpayne@69 160 #ifdef ESC
jpayne@69 161 #undef ESC
jpayne@69 162 #endif
jpayne@69 163 #define ESC CTRL('[')
jpayne@69 164
jpayne@69 165 #endif /* _CHARDEFS_H_ */