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