* chardefs.h: Only declare strrchr if it is not #define'd.
[deliverable/binutils-gdb.git] / readline / chardefs.h
1 /* chardefs.h -- Character definitions for readline. */
2 #ifndef _CHARDEFS_
3 #define _CHARDEFS_
4
5 #include <ctype.h>
6
7 #if 0
8 /* Getting the correct definition of HAVE_STRING_H is harder than just
9 declaring them ourselves. CYGNUS LOCAL. */
10 #if defined (HAVE_STRING_H)
11 # include <string.h>
12 #else
13 # include <strings.h>
14 #endif /* HAVE_STRING_H */
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 */
20
21 #ifndef savestring
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
32 extern char *xmalloc ();
33 #endif
34 # ifndef strcpy
35 extern char *strcpy ();
36 # endif
37 #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
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. */
49 #define control_character_threshold 0x020 /* Smaller than this is control. */
50 #define meta_character_threshold 0x07f /* Larger than this is Meta. */
51 #define control_character_bit 0x40 /* 0x000000, must be off. */
52 #define meta_character_bit 0x080 /* x0000000, must be on. */
53 #define largest_char 255 /* Largest character value. */
54
55 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
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
75 #ifndef NEWLINE
76 #define NEWLINE '\n'
77 #endif
78
79 #ifndef RETURN
80 #define RETURN CTRL('M')
81 #endif
82
83 #ifndef RUBOUT
84 #define RUBOUT 0x07f
85 #endif
86
87 #ifndef TAB
88 #define TAB '\t'
89 #endif
90
91 #ifdef ABORT_CHAR
92 #undef ABORT_CHAR
93 #endif
94 #define ABORT_CHAR CTRL('G')
95
96 #ifdef PAGE
97 #undef PAGE
98 #endif
99 #define PAGE CTRL('L')
100
101 #ifdef SPACE
102 #undef SPACE
103 #endif
104 #define SPACE 0x020
105
106 #ifdef ESC
107 #undef ESC
108 #endif
109
110 #define ESC CTRL('[')
111
112 #endif /* _CHARDEFS_ */
This page took 0.032985 seconds and 4 git commands to generate.