1 /* chardefs.h -- Character definitions for readline. */
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)
14 #endif /* HAVE_STRING_H */
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 ();
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()
32 extern char *xmalloc ();
35 extern char *strcpy ();
37 #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
41 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
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. */
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)
59 #define UNMETA(c) ((c) & (~meta_character_bit))
60 #define UNCTRL(c) to_upper(((c)|control_character_bit))
62 #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
63 #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
65 #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
68 #define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
69 #define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
72 #define CTRL_P(c) ((c) < control_character_threshold)
73 #define META_P(c) ((c) > meta_character_threshold)
80 #define RETURN CTRL('M')
94 #define ABORT_CHAR CTRL('G')
99 #define PAGE CTRL('L')
110 #define ESC CTRL('[')
112 #endif /* _CHARDEFS_ */