1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 10 * the permission of UNIX System Laboratories, Inc. 11 * 12 * This code is derived from software contributed to Berkeley by 13 * Paul Borman at Krystal Technologies. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * 3. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 */ 39 40 #include <ctype.h> 41 42 #undef digittoint 43 int 44 digittoint(int c) 45 { 46 return (__sbmaskrune(c, 0xFF)); 47 } 48 49 #undef isalnum 50 int 51 isalnum(int c) 52 { 53 return (__sbistype(c, _CTYPE_A|_CTYPE_N)); 54 } 55 56 #undef isalpha 57 int 58 isalpha(int c) 59 { 60 return (__sbistype(c, _CTYPE_A)); 61 } 62 63 #undef isascii 64 int 65 isascii(int c) 66 { 67 return ((c & ~0x7F) == 0); 68 } 69 70 #undef isblank 71 int 72 isblank(int c) 73 { 74 return (__sbistype(c, _CTYPE_B)); 75 } 76 77 #undef iscntrl 78 int 79 iscntrl(int c) 80 { 81 return (__sbistype(c, _CTYPE_C)); 82 } 83 84 #undef isdigit 85 int 86 isdigit(int c) 87 { 88 return (__isctype(c, _CTYPE_D)); 89 } 90 91 #undef isgraph 92 int 93 isgraph(int c) 94 { 95 return (__sbistype(c, _CTYPE_G)); 96 } 97 98 #undef ishexnumber 99 int 100 ishexnumber(int c) 101 { 102 return (__sbistype(c, _CTYPE_X)); 103 } 104 105 #undef isideogram 106 int 107 isideogram(int c) 108 { 109 return (__sbistype(c, _CTYPE_I)); 110 } 111 112 #undef islower 113 int 114 islower(int c) 115 { 116 return (__sbistype(c, _CTYPE_L)); 117 } 118 119 #undef isnumber 120 int 121 isnumber(int c) 122 { 123 return (__sbistype(c, _CTYPE_N)); 124 } 125 126 #undef isphonogram 127 int 128 isphonogram(int c) 129 { 130 return (__sbistype(c, _CTYPE_Q)); 131 } 132 133 #undef isprint 134 int 135 isprint(int c) 136 { 137 return (__sbistype(c, _CTYPE_R)); 138 } 139 140 #undef ispunct 141 int 142 ispunct(int c) 143 { 144 return (__sbistype(c, _CTYPE_P)); 145 } 146 147 #undef isrune 148 int 149 isrune(int c) 150 { 151 return (__sbistype(c, 0xFFFFFF00L)); 152 } 153 154 #undef isspace 155 int 156 isspace(int c) 157 { 158 return (__sbistype(c, _CTYPE_S)); 159 } 160 161 #undef isspecial 162 int 163 isspecial(int c) 164 { 165 return (__sbistype(c, _CTYPE_T)); 166 } 167 168 #undef isupper 169 int 170 isupper(int c) 171 { 172 return (__sbistype(c, _CTYPE_U)); 173 } 174 175 #undef isxdigit 176 int 177 isxdigit(int c) 178 { 179 return (__isctype(c, _CTYPE_X)); 180 } 181 182 #undef toascii 183 int 184 toascii(int c) 185 { 186 return (c & 0x7F); 187 } 188 189 #undef tolower 190 int 191 tolower(int c) 192 { 193 return (__sbtolower(c)); 194 } 195 196 #undef toupper 197 int 198 toupper(int c) 199 { 200 return (__sbtoupper(c)); 201 } 202 203