Debian Codegraph @

libsrc/readline/chardefs.h

raw
1 /* chardefs.h -- Character definitions for readline. */
2
3 /* Copyright (C) 1994 Free Software Foundation, Inc.
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
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 1, or
11 (at your option) any later version.
12
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.
17
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 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23 #ifndef _CHARDEFS_H
24 #define _CHARDEFS_H
25
26 #include <ctype.h>
27
28 #if defined (HAVE_STRING_H)
29 # include <string.h>
30 #else
31 # include <strings.h>
32 #endif /* HAVE_STRING_H */
33
34 #ifndef whitespace
35 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
36 #endif
37
38 #ifdef CTRL
39 #undef CTRL
40 #endif
41
42 /* Some character stuff. */
43 #define control_character_threshold 0x020 /* Smaller than this is control. */
44 #define meta_character_threshold 0x07f /* Larger than this is Meta. */
45 #define control_character_bit 0x40 /* 0x000000, must be off. */
46 #define meta_character_bit 0x080 /* x0000000, must be on. */
47 #define largest_char 255 /* Largest character value. */
48
49 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
50 #define CTRL(c) ((c) & (~control_character_bit))
51 #define META(c) ((c) | meta_character_bit)
52
53 #define UNMETA(c) ((c) & (~meta_character_bit))
54 #define UNCTRL(c) to_upper(((c)|control_character_bit))
55
56 /* Old versions
57 #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
58 #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
59 */
60
61 #define lowercase_p(c) (islower(c))
62 #define uppercase_p(c) (isupper(c))
63
64 #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
65
66 /* Old versions
67 # define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
68 # define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
69 */
70
71 #ifndef to_upper
72 # define to_upper(c) (islower(c) ? toupper(c) : (c))
73 # define to_lower(c) (isupper(c) ? tolower(c) : (c))
74 #endif
75
76 #define CTRL_P(c) ((c) < control_character_threshold)
77 #define META_P(c) ((c) > meta_character_threshold)
78
79 #ifndef digit_value
80 #define digit_value(x) ((x) - '0')
81 #endif
82
83 #ifndef NEWLINE
84 #define NEWLINE '\n'
85 #endif
86
87 #ifndef RETURN
88 #define RETURN CTRL('M')
89 #endif
90
91 #ifndef RUBOUT
92 #define RUBOUT 0x7f
93 #endif
94
95 #ifndef TAB
96 #define TAB '\t'
97 #endif
98
99 #ifdef ABORT_CHAR
100 #undef ABORT_CHAR
101 #endif
102 #define ABORT_CHAR CTRL('G')
103
104 #ifdef PAGE
105 #undef PAGE
106 #endif
107 #define PAGE CTRL('L')
108
109 #ifdef SPACE
110 #undef SPACE
111 #endif
112 #define SPACE ' ' /* XXX - was 0x20 */
113
114 #ifdef ESC
115 #undef ESC
116 #endif
117
118 #define ESC CTRL('[')
119
120 #endif /* _CHARDEFS_H */