1/* chardefs.h -- Character definitions for readline. */ 2 3/* Copyright (C) 1994 Free Software Foundation, Inc. 4 5 This file is part of the GNU Readline Library, a library for 6 reading lines of text with interactive input and history editing. 7 8 The GNU Readline Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2, or 11 (at your option) any later version. 12 13 The GNU Readline Library is distributed in the hope that it will be 14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 The GNU General Public License is often shipped with GNU software, and 19 is generally kept in a file called COPYING or LICENSE. If you do not 20 have a copy of the license, write to the Free Software Foundation, 21 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 22 23#ifndef _CHARDEFS_H_ 24#define _CHARDEFS_H_ 25 26#include <ctype.h> 27 28#if defined (HAVE_CONFIG_H) 29# if defined (HAVE_STRING_H) 30# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H) 31# include <memory.h> 32# endif 33# include <string.h> 34# endif /* HAVE_STRING_H */ 35# if defined (HAVE_STRINGS_H) 36# include <strings.h> 37# endif /* HAVE_STRINGS_H */ 38#else 39# include <string.h> 40#endif /* !HAVE_CONFIG_H */ 41 42#ifndef whitespace 43#define whitespace(c) (((c) == ' ') || ((c) == '\t')) 44#endif 45 46#ifdef CTRL 47# undef CTRL 48#endif 49#ifdef UNCTRL 50# undef UNCTRL 51#endif 52 53/* Some character stuff. */ 54#define control_character_threshold 0x020 /* Smaller than this is control. */ 55#define control_character_mask 0x1f /* 0x20 - 1 */ 56#define meta_character_threshold 0x07f /* Larger than this is Meta. */ 57#define control_character_bit 0x40 /* 0x000000, must be off. */ 58#define meta_character_bit 0x080 /* x0000000, must be on. */ 59#define largest_char 255 /* Largest character value. */ 60 61#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0)) 62#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) 63 64#define CTRL(c) ((c) & control_character_mask) 65#define META(c) ((c) | meta_character_bit) 66 67#define UNMETA(c) ((c) & (~meta_character_bit)) 68#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit)) 69 70#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII)) 71# define IN_CTYPE_DOMAIN(c) 1 72#else 73# define IN_CTYPE_DOMAIN(c) isascii(c) 74#endif 75 76#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) 77# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) 78#endif 79 80#if defined (CTYPE_NON_ASCII) 81# define NON_NEGATIVE(c) 1 82#else 83# define NON_NEGATIVE(c) ((unsigned char)(c) == (c)) 84#endif 85 86/* Some systems define these; we want our definitions. */ 87#undef ISPRINT 88
| 1/* chardefs.h -- Character definitions for readline. */ 2 3/* Copyright (C) 1994 Free Software Foundation, Inc. 4 5 This file is part of the GNU Readline Library, a library for 6 reading lines of text with interactive input and history editing. 7 8 The GNU Readline Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2, or 11 (at your option) any later version. 12 13 The GNU Readline Library is distributed in the hope that it will be 14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 The GNU General Public License is often shipped with GNU software, and 19 is generally kept in a file called COPYING or LICENSE. If you do not 20 have a copy of the license, write to the Free Software Foundation, 21 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 22 23#ifndef _CHARDEFS_H_ 24#define _CHARDEFS_H_ 25 26#include <ctype.h> 27 28#if defined (HAVE_CONFIG_H) 29# if defined (HAVE_STRING_H) 30# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H) 31# include <memory.h> 32# endif 33# include <string.h> 34# endif /* HAVE_STRING_H */ 35# if defined (HAVE_STRINGS_H) 36# include <strings.h> 37# endif /* HAVE_STRINGS_H */ 38#else 39# include <string.h> 40#endif /* !HAVE_CONFIG_H */ 41 42#ifndef whitespace 43#define whitespace(c) (((c) == ' ') || ((c) == '\t')) 44#endif 45 46#ifdef CTRL 47# undef CTRL 48#endif 49#ifdef UNCTRL 50# undef UNCTRL 51#endif 52 53/* Some character stuff. */ 54#define control_character_threshold 0x020 /* Smaller than this is control. */ 55#define control_character_mask 0x1f /* 0x20 - 1 */ 56#define meta_character_threshold 0x07f /* Larger than this is Meta. */ 57#define control_character_bit 0x40 /* 0x000000, must be off. */ 58#define meta_character_bit 0x080 /* x0000000, must be on. */ 59#define largest_char 255 /* Largest character value. */ 60 61#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0)) 62#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) 63 64#define CTRL(c) ((c) & control_character_mask) 65#define META(c) ((c) | meta_character_bit) 66 67#define UNMETA(c) ((c) & (~meta_character_bit)) 68#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit)) 69 70#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII)) 71# define IN_CTYPE_DOMAIN(c) 1 72#else 73# define IN_CTYPE_DOMAIN(c) isascii(c) 74#endif 75 76#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) 77# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) 78#endif 79 80#if defined (CTYPE_NON_ASCII) 81# define NON_NEGATIVE(c) 1 82#else 83# define NON_NEGATIVE(c) ((unsigned char)(c) == (c)) 84#endif 85 86/* Some systems define these; we want our definitions. */ 87#undef ISPRINT 88
|
89#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c)) 90#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) 91#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) 92#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c)) 93#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) 94#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) 95#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c)) 96 97#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c)) 98#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c)) 99#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') 100 101#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c)) 102#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c)) 103 104#ifndef _rl_to_upper 105# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c)) 106# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c)) 107#endif 108 109#ifndef _rl_digit_value 110# define _rl_digit_value(x) ((x) - '0') 111#endif 112 113#ifndef _rl_isident 114# define _rl_isident(c) (ISALNUM(c) || (c) == '_') 115#endif 116 117#ifndef ISOCTAL 118# define ISOCTAL(c) ((c) >= '0' && (c) <= '7') 119#endif 120#define OCTVALUE(c) ((c) - '0') 121 122#define HEXVALUE(c) \ 123 (((c) >= 'a' && (c) <= 'f') \ 124 ? (c)-'a'+10 \ 125 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') 126 127#ifndef NEWLINE 128#define NEWLINE '\n' 129#endif 130 131#ifndef RETURN 132#define RETURN CTRL('M') 133#endif 134 135#ifndef RUBOUT 136#define RUBOUT 0x7f 137#endif 138 139#ifndef TAB 140#define TAB '\t' 141#endif 142 143#ifdef ABORT_CHAR 144#undef ABORT_CHAR 145#endif 146#define ABORT_CHAR CTRL('G') 147 148#ifdef PAGE 149#undef PAGE 150#endif 151#define PAGE CTRL('L') 152 153#ifdef SPACE 154#undef SPACE 155#endif 156#define SPACE ' ' /* XXX - was 0x20 */ 157 158#ifdef ESC 159#undef ESC 160#endif 161#define ESC CTRL('[') 162 163#endif /* _CHARDEFS_H_ */
| 91#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c)) 92#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) 93#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) 94#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c)) 95#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) 96#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) 97#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c)) 98 99#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c)) 100#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c)) 101#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') 102 103#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c)) 104#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c)) 105 106#ifndef _rl_to_upper 107# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c)) 108# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c)) 109#endif 110 111#ifndef _rl_digit_value 112# define _rl_digit_value(x) ((x) - '0') 113#endif 114 115#ifndef _rl_isident 116# define _rl_isident(c) (ISALNUM(c) || (c) == '_') 117#endif 118 119#ifndef ISOCTAL 120# define ISOCTAL(c) ((c) >= '0' && (c) <= '7') 121#endif 122#define OCTVALUE(c) ((c) - '0') 123 124#define HEXVALUE(c) \ 125 (((c) >= 'a' && (c) <= 'f') \ 126 ? (c)-'a'+10 \ 127 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') 128 129#ifndef NEWLINE 130#define NEWLINE '\n' 131#endif 132 133#ifndef RETURN 134#define RETURN CTRL('M') 135#endif 136 137#ifndef RUBOUT 138#define RUBOUT 0x7f 139#endif 140 141#ifndef TAB 142#define TAB '\t' 143#endif 144 145#ifdef ABORT_CHAR 146#undef ABORT_CHAR 147#endif 148#define ABORT_CHAR CTRL('G') 149 150#ifdef PAGE 151#undef PAGE 152#endif 153#define PAGE CTRL('L') 154 155#ifdef SPACE 156#undef SPACE 157#endif 158#define SPACE ' ' /* XXX - was 0x20 */ 159 160#ifdef ESC 161#undef ESC 162#endif 163#define ESC CTRL('[') 164 165#endif /* _CHARDEFS_H_ */
|