X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=readline%2Fchardefs.h;h=e76c34b0c674fdaf76edc21e1b50a3f06692302f;hb=5fb776a6371f2122e891467a8fe9b4d7b8b5c6a4;hp=f7df2501e28f32db43adfa7b74076d6a2eaded10;hpb=67289b625ef9a57c2f08578dc9ac827a14a3883f;p=deliverable%2Fbinutils-gdb.git diff --git a/readline/chardefs.h b/readline/chardefs.h index f7df2501e2..e76c34b0c6 100644 --- a/readline/chardefs.h +++ b/readline/chardefs.h @@ -1,76 +1,129 @@ /* chardefs.h -- Character definitions for readline. */ -#ifndef _CHARDEFS_ -#define _CHARDEFS_ -#include +/* Copyright (C) 1994-2009 Free Software Foundation, Inc. -#if 0 -/* Getting the correct definition of HAVE_STRING_H is harder than just - declaring them ourselves. CYGNUS LOCAL. */ -#if defined (HAVE_STRING_H) -# include -#else -# include -#endif /* HAVE_STRING_H */ -#else /* not 0 */ -/* We don't worry about declaring functions where we don't use the return - value (e.g. strcpy) or which return int. */ -extern char *strrchr (); -#endif /* not 0 */ + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. -#ifndef savestring -#if 0 + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -/* CYGNUS LOCAL--this declaration loses if xmalloc has already been - declared as void *xmalloc (), as in GDB. The whole concept of - readline using xmalloc rather than just returning NULL when it runs - out of memory is questionable, but if we do want xmalloc we need a - better way to declare it (e.g. the client declares it, or the client - calls a rl_register_xmalloc function analagous to the way signal() - works. */ + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -extern char *xmalloc (); -#endif -# ifndef strcpy -extern char *strcpy (); -# endif -#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x)) -#endif + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#ifndef _CHARDEFS_H_ +#define _CHARDEFS_H_ + +#include + +#if defined (HAVE_CONFIG_H) +# if defined (HAVE_STRING_H) +# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H) +# include +# endif +# include +# endif /* HAVE_STRING_H */ +# if defined (HAVE_STRINGS_H) +# include +# endif /* HAVE_STRINGS_H */ +#else +# include +#endif /* !HAVE_CONFIG_H */ #ifndef whitespace #define whitespace(c) (((c) == ' ') || ((c) == '\t')) #endif #ifdef CTRL -#undef CTRL +# undef CTRL +#endif +#ifdef UNCTRL +# undef UNCTRL #endif /* Some character stuff. */ #define control_character_threshold 0x020 /* Smaller than this is control. */ +#define control_character_mask 0x1f /* 0x20 - 1 */ #define meta_character_threshold 0x07f /* Larger than this is Meta. */ #define control_character_bit 0x40 /* 0x000000, must be off. */ #define meta_character_bit 0x080 /* x0000000, must be on. */ #define largest_char 255 /* Largest character value. */ +#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0)) #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) -#define CTRL(c) ((c) & (~control_character_bit)) + +#define CTRL(c) ((c) & control_character_mask) #define META(c) ((c) | meta_character_bit) #define UNMETA(c) ((c) & (~meta_character_bit)) -#define UNCTRL(c) to_upper(((c)|control_character_bit)) +#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit)) -#define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) -#define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) +#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif -#define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) +#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) +# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) +#endif -#ifndef to_upper -#define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) -#define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) +#if defined (CTYPE_NON_ASCII) +# define NON_NEGATIVE(c) 1 +#else +# define NON_NEGATIVE(c) ((unsigned char)(c) == (c)) #endif -#define CTRL_P(c) ((c) < control_character_threshold) -#define META_P(c) ((c) > meta_character_threshold) +/* Some systems define these; we want our definitions. */ +#undef ISPRINT + +/* Beware: these only work with single-byte ASCII characters. */ + +#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c)) +#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) +#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) +#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c)) +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) +#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) +#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c)) + +#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c)) +#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c)) +#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') + +#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c)) +#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c)) + +#ifndef _rl_to_upper +# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c)) +# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c)) +#endif + +#ifndef _rl_digit_value +# define _rl_digit_value(x) ((x) - '0') +#endif + +#ifndef _rl_isident +# define _rl_isident(c) (ISALNUM(c) || (c) == '_') +#endif + +#ifndef ISOCTAL +# define ISOCTAL(c) ((c) >= '0' && (c) <= '7') +#endif +#define OCTVALUE(c) ((c) - '0') + +#define HEXVALUE(c) \ + (((c) >= 'a' && (c) <= 'f') \ + ? (c)-'a'+10 \ + : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') #ifndef NEWLINE #define NEWLINE '\n' @@ -81,7 +134,7 @@ extern char *strcpy (); #endif #ifndef RUBOUT -#define RUBOUT 0x07f +#define RUBOUT 0x7f #endif #ifndef TAB @@ -101,12 +154,11 @@ extern char *strcpy (); #ifdef SPACE #undef SPACE #endif -#define SPACE 0x020 +#define SPACE ' ' /* XXX - was 0x20 */ #ifdef ESC #undef ESC #endif - #define ESC CTRL('[') -#endif /* _CHARDEFS_ */ +#endif /* _CHARDEFS_H_ */