* signals.c (_rl_block_sigwinch, _rl_release_sigwinch): Add
[deliverable/binutils-gdb.git] / readline / chardefs.h
CommitLineData
d60d9f65
SS
1/* chardefs.h -- Character definitions for readline. */
2
cc88a640 3/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
d60d9f65 4
cc88a640
JK
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.
d60d9f65 7
cc88a640
JK
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
d60d9f65
SS
11 (at your option) any later version.
12
cc88a640
JK
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
d60d9f65
SS
16 GNU General Public License for more details.
17
cc88a640
JK
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*/
d60d9f65
SS
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)
9255ee31
EZ
29# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
30# include <memory.h>
31# endif
d60d9f65 32# include <string.h>
d60d9f65 33# endif /* HAVE_STRING_H */
9255ee31
EZ
34# if defined (HAVE_STRINGS_H)
35# include <strings.h>
36# endif /* HAVE_STRINGS_H */
d60d9f65
SS
37#else
38# include <string.h>
39#endif /* !HAVE_CONFIG_H */
40
41#ifndef whitespace
42#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
43#endif
44
45#ifdef CTRL
9255ee31
EZ
46# undef CTRL
47#endif
48#ifdef UNCTRL
49# undef UNCTRL
d60d9f65
SS
50#endif
51
52/* Some character stuff. */
53#define control_character_threshold 0x020 /* Smaller than this is control. */
54#define control_character_mask 0x1f /* 0x20 - 1 */
55#define meta_character_threshold 0x07f /* Larger than this is Meta. */
56#define control_character_bit 0x40 /* 0x000000, must be off. */
57#define meta_character_bit 0x080 /* x0000000, must be on. */
58#define largest_char 255 /* Largest character value. */
59
9255ee31 60#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
d60d9f65
SS
61#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
62
63#define CTRL(c) ((c) & control_character_mask)
64#define META(c) ((c) | meta_character_bit)
65
66#define UNMETA(c) ((c) & (~meta_character_bit))
67#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
68
9255ee31
EZ
69#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
70# define IN_CTYPE_DOMAIN(c) 1
71#else
72# define IN_CTYPE_DOMAIN(c) isascii(c)
73#endif
74
75#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
76# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
77#endif
78
5bdf8622
DJ
79#if defined (CTYPE_NON_ASCII)
80# define NON_NEGATIVE(c) 1
81#else
82# define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
83#endif
9255ee31
EZ
84
85/* Some systems define these; we want our definitions. */
86#undef ISPRINT
d60d9f65 87
5bdf8622
DJ
88/* Beware: these only work with single-byte ASCII characters. */
89
9255ee31
EZ
90#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
91#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
92#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
93#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
94#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
95#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
96#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
d60d9f65 97
9255ee31
EZ
98#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
99#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
100#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
d60d9f65 101
9255ee31
EZ
102#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
103#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
d60d9f65
SS
104
105#ifndef _rl_to_upper
9255ee31
EZ
106# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
107# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
d60d9f65
SS
108#endif
109
110#ifndef _rl_digit_value
9255ee31
EZ
111# define _rl_digit_value(x) ((x) - '0')
112#endif
113
114#ifndef _rl_isident
115# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
d60d9f65
SS
116#endif
117
9255ee31
EZ
118#ifndef ISOCTAL
119# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
120#endif
121#define OCTVALUE(c) ((c) - '0')
122
123#define HEXVALUE(c) \
124 (((c) >= 'a' && (c) <= 'f') \
125 ? (c)-'a'+10 \
126 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
127
d60d9f65
SS
128#ifndef NEWLINE
129#define NEWLINE '\n'
130#endif
131
132#ifndef RETURN
133#define RETURN CTRL('M')
134#endif
135
136#ifndef RUBOUT
137#define RUBOUT 0x7f
138#endif
139
140#ifndef TAB
141#define TAB '\t'
142#endif
143
144#ifdef ABORT_CHAR
145#undef ABORT_CHAR
146#endif
147#define ABORT_CHAR CTRL('G')
148
149#ifdef PAGE
150#undef PAGE
151#endif
152#define PAGE CTRL('L')
153
154#ifdef SPACE
155#undef SPACE
156#endif
157#define SPACE ' ' /* XXX - was 0x20 */
158
159#ifdef ESC
160#undef ESC
161#endif
162#define ESC CTRL('[')
163
d60d9f65 164#endif /* _CHARDEFS_H_ */
This page took 0.525224 seconds and 4 git commands to generate.