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