1 /* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Paul Borman at Krystal Technologies. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)ctype.h 8.1 (Berkeley) 06/06/93 11 */ 12 13 #ifndef _CTYPE_H_ 14 #define _CTYPE_H_ 15 16 #ifndef _ANSI_SOURCE 17 #include <runetype.h> 18 #endif 19 20 #define _A 0x00000100L /* Alpha */ 21 #define _C 0x00000200L /* Control */ 22 #define _D 0x00000400L /* Digit */ 23 #define _G 0x00000800L /* Graph */ 24 #define _L 0x00001000L /* Lower */ 25 #define _P 0x00002000L /* Punct */ 26 #define _S 0x00004000L /* Space */ 27 #define _U 0x00008000L /* Upper */ 28 #define _X 0x00010000L /* X digit */ 29 #define _B 0x00020000L /* Blank */ 30 #define _R 0x00040000L /* Print */ 31 #define _I 0x00080000L /* Ideogram */ 32 #define _T 0x00100000L /* Special */ 33 #define _Q 0x00200000L /* Phonogram */ 34 35 #define isalnum(c) __istype((c), (_A|_D)) 36 #define isalpha(c) __istype((c), _A) 37 #define iscntrl(c) __istype((c), _C) 38 #define isdigit(c) __isctype((c), _D) /* ANSI -- locale independent */ 39 #define isgraph(c) __istype((c), _G) 40 #define islower(c) __istype((c), _L) 41 #define isprint(c) __istype((c), _R) 42 #define ispunct(c) __istype((c), _P) 43 #define isspace(c) __istype((c), _S) 44 #define isupper(c) __istype((c), _U) 45 #define isxdigit(c) __isctype((c), _X) /* ANSI -- locale independent */ 46 47 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 48 #define isascii(c) ((c & ~0x7F) == 0) 49 #define toascii(c) ((c) & 0x7F) 50 #define digittoint(c) __istype((c), 0xFF) 51 #define isideogram(c) __istype((c), _I) 52 #define isphonogram(c) __istype((c), _T) 53 #define isspecial(c) __istype((c), _Q) 54 #define isblank(c) __istype((c), _B) 55 #define isrune(c) __istype((c), 0xFFFFFF00L) 56 #define isnumber(c) __istype((c), _D) 57 #define ishexnumber(c) __istype((c), _X) 58 #endif 59 60 /* See comments in <machine/ansi.h> about _BSD_RUNE_T_. */ 61 __BEGIN_DECLS 62 unsigned long ___runetype __P((_BSD_RUNE_T_)); 63 _BSD_RUNE_T_ ___tolower __P((_BSD_RUNE_T_)); 64 _BSD_RUNE_T_ ___toupper __P((_BSD_RUNE_T_)); 65 __END_DECLS 66 67 /* 68 * If your compiler supports prototypes and inline functions, 69 * #define _USE_CTYPE_INLINE_. Otherwise, use the C library 70 * functions. 71 */ 72 #if !defined(_USE_CTYPE_CLIBRARY_) && defined(__GNUC__) || defined(__cplusplus) 73 #define _USE_CTYPE_INLINE_ 1 74 #endif 75 76 #if defined(_USE_CTYPE_INLINE_) 77 static inline int 78 __istype(_BSD_RUNE_T_ c, unsigned long f) 79 { 80 return((((c & _CRMASK) ? ___runetype(c) : 81 _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0); 82 } 83 84 static inline int 85 __isctype(_BSD_RUNE_T_ c, unsigned long f) 86 { 87 return((((c & _CRMASK) ? 0 : 88 _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0); 89 } 90 91 /* _ANSI_LIBRARY is defined by lib/libc/gen/isctype.c. */ 92 #if !defined(_ANSI_LIBRARY) 93 static inline _BSD_RUNE_T_ 94 toupper(_BSD_RUNE_T_ c) 95 { 96 return((c & _CRMASK) ? 97 ___toupper(c) : _CurrentRuneLocale->mapupper[c]); 98 } 99 100 static inline _BSD_RUNE_T_ 101 tolower(_BSD_RUNE_T_ c) 102 { 103 return((c & _CRMASK) ? 104 ___tolower(c) : _CurrentRuneLocale->maplower[c]); 105 } 106 #endif /* !_ANSI_LIBRARY */ 107 108 #else /* !_USE_CTYPE_INLINE_ */ 109 110 __BEGIN_DECLS 111 int __istype __P((_BSD_RUNE_T_, unsigned long)); 112 int __isctype __P((_BSD_RUNE_T_, unsigned long)); 113 _BSD_RUNE_T_ toupper __P((_BSD_RUNE_T_)); 114 _BSD_RUNE_T_ tolower __P((_BSD_RUNE_T_)); 115 __END_DECLS 116 #endif /* _USE_CTYPE_INLINE_ */ 117 118 #endif /* !_CTYPE_H_ */ 119