Home | History | Annotate | Download | only in iso
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*	Copyright (c) 1988 AT&T	*/
     23 /*	  All Rights Reserved  	*/
     24 
     25 
     26 /*
     27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
     28  * Use is subject to license terms.
     29  */
     30 
     31 /*
     32  * An application should not include this header directly.  Instead it
     33  * should be included only through the inclusion of other Sun headers.
     34  *
     35  * The contents of this header is limited to identifiers specified in the
     36  * C Standard.  Any new identifiers specified in future amendments to the
     37  * C Standard must be placed in this header.  If these new identifiers
     38  * are required to also be in the C++ Standard "std" namespace, then for
     39  * anything other than macro definitions, corresponding "using" directives
     40  * must also be added to <ctype.h>.
     41  */
     42 
     43 #ifndef _ISO_CTYPE_ISO_H
     44 #define	_ISO_CTYPE_ISO_H
     45 
     46 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     47 
     48 #include <sys/feature_tests.h>
     49 
     50 #ifdef	__cplusplus
     51 extern "C" {
     52 #endif
     53 
     54 #define	_U	0x00000001	/* Upper case */
     55 #define	_L	0x00000002	/* Lower case */
     56 #define	_N	0x00000004	/* Numeral (digit) */
     57 #define	_S	0x00000008	/* Spacing character */
     58 #define	_P	0x00000010	/* Punctuation */
     59 #define	_C	0x00000020	/* Control character */
     60 #define	_B	0x00000040	/* Blank */
     61 #define	_X	0x00000080	/* heXadecimal digit */
     62 
     63 #define	_ISUPPER	_U
     64 #define	_ISLOWER	_L
     65 #define	_ISDIGIT	_N
     66 #define	_ISSPACE	_S
     67 #define	_ISPUNCT	_P
     68 #define	_ISCNTRL	_C
     69 #define	_ISBLANK	_B
     70 #define	_ISXDIGIT	_X
     71 #define	_ISGRAPH	0x00002000
     72 #define	_ISALPHA	0x00004000
     73 #define	_ISPRINT	0x00008000
     74 #define	_ISALNUM	(_ISALPHA | _ISDIGIT)
     75 
     76 
     77 #if defined(__STDC__)
     78 
     79 #if __cplusplus < 199711L  /* Use inline functions instead for ANSI C++ */
     80 
     81 extern int isalnum(int);
     82 extern int isalpha(int);
     83 extern int iscntrl(int);
     84 extern int isdigit(int);
     85 extern int isgraph(int);
     86 extern int islower(int);
     87 extern int isprint(int);
     88 extern int ispunct(int);
     89 extern int isspace(int);
     90 extern int isupper(int);
     91 extern int isxdigit(int);
     92 
     93 #endif /* __cplusplus < 199711L */
     94 
     95 #if __cplusplus >= 199711L
     96 namespace std {
     97 #endif
     98 
     99 extern int tolower(int);
    100 extern int toupper(int);
    101 
    102 #if __cplusplus >= 199711L
    103 } /* end of namespace std */
    104 #endif
    105 
    106 extern unsigned char	__ctype[];
    107 extern unsigned int	*__ctype_mask;
    108 extern int		*__trans_upper;
    109 extern int		*__trans_lower;
    110 
    111 #if !defined(__lint)
    112 
    113 #if __cplusplus >= 199711L
    114 namespace std {
    115 
    116 #if defined(__XPG4_CHAR_CLASS__) || defined(_XPG4)
    117 
    118 inline int isalpha(int c) { return (__ctype_mask[c] & _ISALPHA); }
    119 inline int isupper(int c) { return (__ctype_mask[c] & _ISUPPER); }
    120 inline int islower(int c) { return (__ctype_mask[c] & _ISLOWER); }
    121 inline int isdigit(int c) { return (__ctype_mask[c] & _ISDIGIT); }
    122 inline int isxdigit(int c) { return (__ctype_mask[c] & _ISXDIGIT); }
    123 inline int isalnum(int c) { return (__ctype_mask[c] & _ISALNUM); }
    124 inline int isspace(int c) { return (__ctype_mask[c] & _ISSPACE); }
    125 inline int ispunct(int c) { return (__ctype_mask[c] & _ISPUNCT); }
    126 inline int isprint(int c) { return (__ctype_mask[c] & _ISPRINT); }
    127 inline int isgraph(int c) { return (__ctype_mask[c] & _ISGRAPH); }
    128 inline int iscntrl(int c) { return (__ctype_mask[c] & _ISCNTRL); }
    129 #else
    130 inline int isalpha(int c) { return ((__ctype + 1)[c] & (_U | _L)); }
    131 inline int isupper(int c) { return ((__ctype + 1)[c] & _U); }
    132 inline int islower(int c) { return ((__ctype + 1)[c] & _L); }
    133 inline int isdigit(int c) { return ((__ctype + 1)[c] & _N); }
    134 inline int isxdigit(int c) { return ((__ctype + 1)[c] & _X); }
    135 inline int isalnum(int c) { return ((__ctype + 1)[c] & (_U | _L | _N)); }
    136 inline int isspace(int c) { return ((__ctype + 1)[c] & _S); }
    137 inline int ispunct(int c) { return ((__ctype + 1)[c] & _P); }
    138 inline int isprint(int c) {
    139 	return ((__ctype + 1)[c] & (_P | _U | _L | _N | _B)); }
    140 inline int isgraph(int c) { return ((__ctype + 1)[c] & (_P | _U | _L | _N)); }
    141 inline int iscntrl(int c) { return ((__ctype + 1)[c] & _C); }
    142 #endif  /* defined(__XPG4_CHAR_CLASS__) || defined(_XPG4) */
    143 
    144 } /* end of namespace std */
    145 
    146 #else /* __cplusplus >= 199711L */
    147 
    148 #if defined(__XPG4_CHAR_CLASS__) || defined(_XPG4)
    149 #define	isalpha(c)	(__ctype_mask[(int)(c)] & _ISALPHA)
    150 #define	isupper(c)	(__ctype_mask[(int)(c)] & _ISUPPER)
    151 #define	islower(c)	(__ctype_mask[(int)(c)] & _ISLOWER)
    152 #define	isdigit(c)	(__ctype_mask[(int)(c)] & _ISDIGIT)
    153 #define	isxdigit(c)	(__ctype_mask[(int)(c)] & _ISXDIGIT)
    154 #define	isalnum(c)	(__ctype_mask[(int)(c)] & _ISALNUM)
    155 #define	isspace(c)	(__ctype_mask[(int)(c)] & _ISSPACE)
    156 #define	ispunct(c)	(__ctype_mask[(int)(c)] & _ISPUNCT)
    157 #define	isprint(c)	(__ctype_mask[(int)(c)] & _ISPRINT)
    158 #define	isgraph(c)	(__ctype_mask[(int)(c)] & _ISGRAPH)
    159 #define	iscntrl(c)	(__ctype_mask[(int)(c)] & _ISCNTRL)
    160 #else
    161 #define	isalpha(c)	((__ctype + 1)[(int)(c)] & (_U | _L))
    162 #define	isupper(c)	((__ctype + 1)[(int)(c)] & _U)
    163 #define	islower(c)	((__ctype + 1)[(int)(c)] & _L)
    164 #define	isdigit(c)	((__ctype + 1)[(int)(c)] & _N)
    165 #define	isxdigit(c)	((__ctype + 1)[(int)(c)] & _X)
    166 #define	isalnum(c)	((__ctype + 1)[(int)(c)] & (_U | _L | _N))
    167 #define	isspace(c)	((__ctype + 1)[(int)(c)] & _S)
    168 #define	ispunct(c)	((__ctype + 1)[(int)(c)] & _P)
    169 #define	isprint(c)	((__ctype + 1)[(int)(c)] & (_P | _U | _L | _N | _B))
    170 #define	isgraph(c)	((__ctype + 1)[(int)(c)] & (_P | _U | _L | _N))
    171 #define	iscntrl(c)	((__ctype + 1)[(int)(c)] & _C)
    172 
    173 #endif  /* defined(__XPG4_CHAR_CLASS__) || defined(_XPG4) */
    174 
    175 #endif	/* __cplusplus >= 199711L */
    176 
    177 #endif	/* !defined(__lint) */
    178 
    179 #else	/* defined(__STDC__) */
    180 
    181 extern unsigned char	_ctype[];
    182 
    183 #if !defined(__lint)
    184 
    185 #define	isalpha(c)	((_ctype + 1)[(int)(c)] & (_U | _L))
    186 #define	isupper(c)	((_ctype + 1)[(int)(c)] & _U)
    187 #define	islower(c)	((_ctype + 1)[(int)(c)] & _L)
    188 #define	isdigit(c)	((_ctype + 1)[(int)(c)] & _N)
    189 #define	isxdigit(c)	((_ctype + 1)[(int)(c)] & _X)
    190 #define	isalnum(c)	((_ctype + 1)[(int)(c)] & (_U | _L | _N))
    191 #define	isspace(c)	((_ctype + 1)[(int)(c)] & _S)
    192 #define	ispunct(c)	((_ctype + 1)[(int)(c)] & _P)
    193 #define	isprint(c)	((_ctype + 1)[(int)(c)] & (_P | _U | _L | _N | _B))
    194 #define	isgraph(c)	((_ctype + 1)[(int)(c)] & (_P | _U | _L | _N))
    195 #define	iscntrl(c)	((_ctype + 1)[(int)(c)] & _C)
    196 
    197 #endif	/* !defined(__lint) */
    198 
    199 #endif	/* defined(__STDC__) */
    200 
    201 #ifdef	__cplusplus
    202 }
    203 #endif
    204 
    205 #endif	/* _ISO_CTYPE_ISO_H */
    206