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