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