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)
30 # if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
34 # endif /* HAVE_STRING_H */
35 # if defined (HAVE_STRINGS_H)
37 # endif /* HAVE_STRINGS_H */
40 #endif /* !HAVE_CONFIG_H */
43 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
53 /* Some character stuff. */
54 #define control_character_threshold 0x020 /* Smaller than this is control. */
55 #define control_character_mask 0x1f /* 0x20 - 1 */
56 #define meta_character_threshold 0x07f /* Larger than this is Meta. */
57 #define control_character_bit 0x40 /* 0x000000, must be off. */
58 #define meta_character_bit 0x080 /* x0000000, must be on. */
59 #define largest_char 255 /* Largest character value. */
61 #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
62 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
64 #define CTRL(c) ((c) & control_character_mask)
65 #define META(c) ((c) | meta_character_bit)
67 #define UNMETA(c) ((c) & (~meta_character_bit))
68 #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
70 #if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
71 # define IN_CTYPE_DOMAIN(c) 1
73 # define IN_CTYPE_DOMAIN(c) isascii(c)
76 #if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
77 # define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
80 #define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
82 /* Some systems define these; we want our definitions. */
85 #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
86 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
87 #define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
88 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
89 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
90 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
91 #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
93 #define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
94 #define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
95 #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
97 #define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
98 #define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
101 # define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
102 # define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
105 #ifndef _rl_digit_value
106 # define _rl_digit_value(x) ((x) - '0')
110 # define _rl_isident(c) (ISALNUM(c) || (c) == '_')
114 # define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
116 #define OCTVALUE(c) ((c) - '0')
118 #define HEXVALUE(c) \
119 (((c) >= 'a' && (c) <= 'f') \
121 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
128 #define RETURN CTRL('M')
142 #define ABORT_CHAR CTRL('G')
147 #define PAGE CTRL('L')
152 #define SPACE ' ' /* XXX - was 0x20 */
157 #define ESC CTRL('[')
159 #endif /* _CHARDEFS_H_ */
This page took 0.038731 seconds and 4 git commands to generate.