1 /* 2 * Copyright (c) 1989 The Regents of the University of California. 3 * All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35 #if defined(LIBC_SCCS) && !defined(lint) 36 static char rcsid[] = "$OpenBSD: isctype.c,v 1.9 2003/06/10 22:00:31 millert Exp $"; 37 #endif /* LIBC_SCCS and not lint */ 38 39 #define _ANSI_LIBRARY 40 #include <ctype.h> 41 #include <stdio.h> 42 43 #undef isalnum 44 int 45 isalnum(c) 46 int c; 47 { 48 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L|_N))); 49 } 50 51 #undef isalpha 52 int 53 isalpha(c) 54 int c; 55 { 56 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L))); 57 } 58 59 #undef isblank 60 int 61 isblank(c) 62 int c; 63 { 64 return (c == ' ' || c == '\t'); 65 } 66 67 #undef iscntrl 68 int 69 iscntrl(c) 70 int c; 71 { 72 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _C)); 73 } 74 75 #undef isdigit 76 int 77 isdigit(c) 78 int c; 79 { 80 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _N)); 81 } 82 83 #undef isgraph 84 int 85 isgraph(c) 86 int c; 87 { 88 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N))); 89 } 90 91 #undef islower 92 int 93 islower(c) 94 int c; 95 { 96 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _L)); 97 } 98 99 #undef isprint 100 int 101 isprint(c) 102 int c; 103 { 104 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N|_B))); 105 } 106 107 #undef ispunct 108 int 109 ispunct(c) 110 int c; 111 { 112 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _P)); 113 } 114 115 #undef isspace 116 int 117 isspace(c) 118 int c; 119 { 120 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _S)); 121 } 122 123 #undef isupper 124 int 125 isupper(c) 126 int c; 127 { 128 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _U)); 129 } 130 131 #undef isxdigit 132 int 133 isxdigit(c) 134 int c; 135 { 136 return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_N|_X))); 137 } 138 139 #undef isascii 140 int 141 isascii(c) 142 int c; 143 { 144 return ((unsigned int)c <= 0177); 145 } 146 147 #undef toascii 148 int 149 toascii(c) 150 int c; 151 { 152 return (c & 0177); 153 } 154 155 #undef _toupper 156 int 157 _toupper(c) 158 int c; 159 { 160 return (c - 'a' + 'A'); 161 } 162 163 #undef _tolower 164 int 165 _tolower(c) 166 int c; 167 { 168 return (c - 'A' + 'a'); 169 } 170