// Rowley C Compiler, runtime support. // // Copyright (c) 2001-2012 Rowley Associates Limited. // // This file may be distributed under the terms of the License Agreement // provided with this software. // // THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #ifndef __CTYPE_H #define __CTYPE_H // Get definition for __CODE #include "__crossworks.h" #ifdef __cplusplus extern "C" { #endif /* Internal table which classifies characters and EOF. */ extern __CODE const unsigned char __ctype[]; #define __CTYPE_UPPER 0x01 /* upper case letter */ #define __CTYPE_LOWER 0x02 /* lower case letter */ #define __CTYPE_DIGIT 0x04 /* digit */ #define __CTYPE_SPACE 0x08 /* whitespace */ #define __CTYPE_PUNCT 0x10 /* punctuation character */ #define __CTYPE_CONTROL 0x20 /* control character */ #define __CTYPE_BLANK 0x40 /* space char */ #define __CTYPE_HEX 0x80 /* hexadecimal digit */ /* Function implementation. */ /*! \brief Is character alphabetic? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if \b isupper or \b islower return true for value of the argument \a c. */ int isalpha(int __c); /*! \brief Is character an uppercase letter? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is an uppercase letter. */ int isupper(int __c); /*! \brief Is character a lowercase letter? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is an lowercase letter. */ int islower(int __c); /*! \brief Is character a decimal digit? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is a digit. */ int isdigit(int __c); /*! \brief Is character a hexadecimal digit? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is a hexadecimal digit. */ int isxdigit(int __c); /*! \brief Is character a whitespace character? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is a standard white-space character. The standard white-space characters are space (\tt{' '}), form feed (\tt{'\\f'}), new-line (\tt{'\\n'}), carriage return (\tt{'\\r'}), horizontal tab (\tt{'\\t'}), and vertical tab (\tt{'\v'}). */ int isspace(int __c); /*! \brief Is character a punctuation mark? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) for every printing character for which neither \b isspace nor \b isalnum is true. */ int ispunct(int __c); /*! \brief Is character alphanumeric? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is an alphabetic or numeric character. */ int isalnum(int __c); /*! \brief Is character printable? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is any printing character including space (\tt{' '}). */ int isprint(int __c); /*! \brief Is character any printing character except space? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is any printing character except space (\tt{' '}). */ int isgraph(int __c); /*! \brief Is character a control character? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is a control character. Control characters have values 0 through 31 and the single value 127. */ int iscntrl(int __c); /*! \brief Convert lowercase character to uppercase \ingroup Conversion functions \synopsis \desc \b \this converts a lowercase letter to a corresponding uppercase letter. If the argument \a c is a character for which \b islower is true, \b \this returns the corresponding uppercase letter; otherwise, the argument is returned unchanged. */ int toupper(int __c); /*! \brief Convert uppercase character to lowercase \ingroup Conversion functions \synopsis \desc \b \this converts an uppercase letter to a corresponding lowercase letter. If the argument \a c is a character for which \b isupper is true, \b \this returns the corresponding lowercase letter; otherwise, the argument is returned unchanged. */ int tolower(int __c); /*! \brief Is character a space or horizontal tab? \ingroup Classification functions \synopsis \desc \b \this returns nonzero (true) if and only if the value of the argument \a c is either a space character (\tt{' '}) or the horizontal tab character (\tt{'\\t'}). */ int isblank(int __c); /* C99 */ /* Define __CTYPE_MACROS before including this file and you'll get the macro implementation of these functions. */ #ifdef __CTYPE_MACROS /* Macro implementation. If you wish to use functions, simply #undef these as described in the ISO standard or use, for instance, (isalpha)(x) which forces a functional version. */ #define isalpha(c) (__ctype[(c)+1] & (__CTYPE_UPPER | __CTYPE_LOWER)) #define isupper(c) (__ctype[(c)+1] & __CTYPE_UPPER) #define islower(c) (__ctype[(c)+1] & __CTYPE_LOWER) #define isdigit(c) (__ctype[(c)+1] & __CTYPE_DIGIT) #define isxdigit(c) (__ctype[(c)+1] & __CTYPE_HEX) #define isspace(c) (__ctype[(c)+1] & __CTYPE_SPACE) #define ispunct(c) (__ctype[(c)+1] & __CTYPE_PUNCT) #define isalnum(c) (__ctype[(c)+1] & (__CTYPE_UPPER | __CTYPE_LOWER | __CTYPE_DIGIT)) #define isprint(c) (__ctype[(c)+1] & (__CTYPE_BLANK | __CTYPE_PUNCT | __CTYPE_UPPER | __CTYPE_LOWER | __CTYPE_DIGIT)) #define isgraph(c) (__ctype[(c)+1] & (__CTYPE_PUNCT | __CTYPE_ALPHA | __CTYPE_DIGIT)) #define iscntrl(c) (__ctype[(c)+1] & __CTYPE_CONTROL) #endif #ifdef __cplusplus } #endif #endif