1 /* chardefs.h -- Character definitions for readline. */
3 /* Copyright (C) 1994 Free Software Foundation, Inc.
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
8 The GNU Readline Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2, or
11 (at your option) any later version.
13 The GNU Readline Library is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 The GNU General Public License is often shipped with GNU software, and
19 is generally kept in a file called COPYING or LICENSE. If you do not
20 have a copy of the license, write to the Free Software Foundation,
21 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
28 #if defined (HAVE_CONFIG_H)
29 # if defined (HAVE_STRING_H)
33 # endif /* HAVE_STRING_H */
36 #endif /* !HAVE_CONFIG_H */
39 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
46 /* Some character stuff. */
47 #define control_character_threshold 0x020 /* Smaller than this is control. */
48 #define control_character_mask 0x1f /* 0x20 - 1 */
49 #define meta_character_threshold 0x07f /* Larger than this is Meta. */
50 #define control_character_bit 0x40 /* 0x000000, must be off. */
51 #define meta_character_bit 0x080 /* x0000000, must be on. */
52 #define largest_char 255 /* Largest character value. */
54 #define CTRL_CHAR(c) ((c) < control_character_threshold && (c) >= 0)
55 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
57 #define CTRL(c) ((c) & control_character_mask)
58 #define META(c) ((c) | meta_character_bit)
60 #define UNMETA(c) ((c) & (~meta_character_bit))
61 #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
64 #define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
65 #define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
66 #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
69 #define _rl_lowercase_p(c) (islower(c))
70 #define _rl_uppercase_p(c) (isupper(c))
71 #define _rl_digit_p(x) (isdigit (x))
73 #define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c))
74 #define ALPHABETIC(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c))
77 # define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c))
78 # define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c))
82 # define _rl_to_upper(c) (islower(c) ? toupper(c) : (c))
83 # define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c))
86 #ifndef _rl_digit_value
87 #define _rl_digit_value(x) ((x) - '0')
95 #define RETURN CTRL('M')
109 #define ABORT_CHAR CTRL('G')
114 #define PAGE CTRL('L')
119 #define SPACE ' ' /* XXX - was 0x20 */
124 #define ESC CTRL('[')
127 #define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
129 #define OCTVALUE(c) ((c) - '0')
132 # define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
135 #define HEXVALUE(c) \
136 (((c) >= 'a' && (c) <= 'f') \
138 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
140 #endif /* _CHARDEFS_H_ */
This page took 0.03174 seconds and 4 git commands to generate.