Commit | Line | Data |
---|---|---|
bd5635a1 RP |
1 | /* chardefs.h -- Character definitions for readline. */ |
2 | #ifndef _CHARDEFS_ | |
5e98bbab PB |
3 | #define _CHARDEFS_ |
4 | ||
5 | #include <ctype.h> | |
6 | ||
67289b62 JK |
7 | #if 0 |
8 | /* Getting the correct definition of HAVE_STRING_H is harder than just | |
9 | declaring them ourselves. CYGNUS LOCAL. */ | |
5e98bbab PB |
10 | #if defined (HAVE_STRING_H) |
11 | # include <string.h> | |
12 | #else | |
13 | # include <strings.h> | |
14 | #endif /* HAVE_STRING_H */ | |
67289b62 JK |
15 | #else /* not 0 */ |
16 | /* We don't worry about declaring functions where we don't use the return | |
17 | value (e.g. strcpy) or which return int. */ | |
18 | extern char *strrchr (); | |
19 | #endif /* not 0 */ | |
bd5635a1 RP |
20 | |
21 | #ifndef savestring | |
5bac8022 JK |
22 | #if 0 |
23 | ||
24 | /* CYGNUS LOCAL--this declaration loses if xmalloc has already been | |
25 | declared as void *xmalloc (), as in GDB. The whole concept of | |
26 | readline using xmalloc rather than just returning NULL when it runs | |
27 | out of memory is questionable, but if we do want xmalloc we need a | |
28 | better way to declare it (e.g. the client declares it, or the client | |
29 | calls a rl_register_xmalloc function analagous to the way signal() | |
30 | works. */ | |
31 | ||
5e98bbab | 32 | extern char *xmalloc (); |
5bac8022 | 33 | #endif |
5e98bbab PB |
34 | # ifndef strcpy |
35 | extern char *strcpy (); | |
36 | # endif | |
37 | #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x)) | |
bd5635a1 RP |
38 | #endif |
39 | ||
40 | #ifndef whitespace | |
41 | #define whitespace(c) (((c) == ' ') || ((c) == '\t')) | |
42 | #endif | |
43 | ||
44 | #ifdef CTRL | |
45 | #undef CTRL | |
46 | #endif | |
47 | ||
48 | /* Some character stuff. */ | |
5e98bbab PB |
49 | #define control_character_threshold 0x020 /* Smaller than this is control. */ |
50 | #define meta_character_threshold 0x07f /* Larger than this is Meta. */ | |
bd5635a1 RP |
51 | #define control_character_bit 0x40 /* 0x000000, must be off. */ |
52 | #define meta_character_bit 0x080 /* x0000000, must be on. */ | |
5e98bbab | 53 | #define largest_char 255 /* Largest character value. */ |
bd5635a1 | 54 | |
5e98bbab | 55 | #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) |
bd5635a1 RP |
56 | #define CTRL(c) ((c) & (~control_character_bit)) |
57 | #define META(c) ((c) | meta_character_bit) | |
58 | ||
59 | #define UNMETA(c) ((c) & (~meta_character_bit)) | |
60 | #define UNCTRL(c) to_upper(((c)|control_character_bit)) | |
61 | ||
62 | #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) | |
63 | #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) | |
64 | ||
65 | #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) | |
66 | ||
67 | #ifndef to_upper | |
68 | #define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) | |
69 | #define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) | |
70 | #endif | |
71 | ||
72 | #define CTRL_P(c) ((c) < control_character_threshold) | |
73 | #define META_P(c) ((c) > meta_character_threshold) | |
74 | ||
5e98bbab | 75 | #ifndef NEWLINE |
bd5635a1 | 76 | #define NEWLINE '\n' |
5e98bbab PB |
77 | #endif |
78 | ||
79 | #ifndef RETURN | |
bd5635a1 | 80 | #define RETURN CTRL('M') |
5e98bbab PB |
81 | #endif |
82 | ||
83 | #ifndef RUBOUT | |
bd5635a1 | 84 | #define RUBOUT 0x07f |
5e98bbab PB |
85 | #endif |
86 | ||
87 | #ifndef TAB | |
bd5635a1 | 88 | #define TAB '\t' |
5e98bbab PB |
89 | #endif |
90 | ||
91 | #ifdef ABORT_CHAR | |
92 | #undef ABORT_CHAR | |
93 | #endif | |
bd5635a1 | 94 | #define ABORT_CHAR CTRL('G') |
5e98bbab PB |
95 | |
96 | #ifdef PAGE | |
97 | #undef PAGE | |
98 | #endif | |
bd5635a1 | 99 | #define PAGE CTRL('L') |
5e98bbab PB |
100 | |
101 | #ifdef SPACE | |
102 | #undef SPACE | |
103 | #endif | |
bd5635a1 | 104 | #define SPACE 0x020 |
5e98bbab PB |
105 | |
106 | #ifdef ESC | |
107 | #undef ESC | |
108 | #endif | |
109 | ||
bd5635a1 RP |
110 | #define ESC CTRL('[') |
111 | ||
112 | #endif /* _CHARDEFS_ */ |