X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=includes%2Fctype.h;h=a4ac53449bfd52e529860d95358dbe24ccf7d24e;hp=2c8071c5da3b39eb08f1ba72d2b8d3eacc98345e;hb=0fa6394bc70eab55e0e38703a31a3072232c0729;hpb=3d73330dba39a534ae569ca053fe626e670efd4d diff --git a/includes/ctype.h b/includes/ctype.h index 2c8071c..a4ac534 100644 --- a/includes/ctype.h +++ b/includes/ctype.h @@ -9,15 +9,85 @@ #ifndef _PDCLIB_CTYPE_H #define _PDCLIB_CTYPE_H _PDCLIB_CTYPE_H -/* ------------------------------------------------------------------------- */ -/* THIS IS A STUB - THIS IS A STUB - THIS IS A STUB - THIS IS A STUB */ -/* ------------------------------------------------------------------------- */ -/* This implements two functions that are required by / */ -/* for the C locale only. Will be replaced in v0.6 by something compliant. */ -/* ------------------------------------------------------------------------- */ - -int tolower( int c ); +/* Character classification functions */ + +/* Note that there is a difference between "whitespace" (any printing, non- + graph character, like horizontal and vertical tab), and "blank" (the literal + ' ' space character). + + There will be masking macros for each of these later on, but right now I + focus on the functions only. +*/ + +/* Returns isalpha( c ) || isdigit( c ) */ +int isalnum( int c ); + +/* Returns isupper( c ) || islower( c ) in the "C" locale. + In any other locale, also returns true for a locale-specific set of + alphabetic characters which are neither control characters, digits, + punctation, or whitespace. +*/ +int isalpha( int c ); + +/* Returns true if the character is a whitespace. In the "C" locale, only ' ' + and '\t' are considered whitespace. +*/ +int isblank( int c ); + +/* Returns true if the character is a control character. */ +int iscntrl( int c ); + +/* Returns true if the character is a decimal digit. */ +int isdigit( int c ); + +/* Returns true for every printing character except space (' '). */ +int isgraph( int c ); + +/* Returns true for lowercase letters in the "C" locale. + In any other locale, also returns true for a locale-specific set of + characters which are neither control characters, digits, punctation, or + space (' '). In a locale other than the "C" locale, a character might test + true for both islower() and isupper(). +*/ +int islower( int c ); + +/* Returns true for every printing character including space (' '). */ +int isprint( int c ); + +/* Returns true for every printing character that is neither whitespace + nor alphanumeric in the "C" locale. In any other locale, there might be + characters that are printing characters, but neither whitespace nor + alphanumeric. +*/ +int ispunct( int c ); + +/* Returns true for every standard whitespace character (' ', '\f', '\n', '\r', + '\t', '\v') in the "C" locale. In any other locale, also returns true for a + locale-specific set of characters for which isalnum() is false. +*/ int isspace( int c ); -#endif +/* Returns true for uppercase letters in the "C" locale. + In any other locale, also returns true for a locale-specific set of + characters which are neither control characters, digits, punctation, or + space (' '). In a locale other than the "C" locale, a character might test + true for both islower() and isupper(). +*/ +int isupper( int c ); + +/* Returns true for any hexadecimal-digit character. */ +int isxdigit( int c ); +/* Character case mapping functions */ + +/* Converts an uppercase letter to a corresponding lowercase letter. Input that + is not an uppercase letter remains unchanged. +*/ +int tolower( c ); + +/* Converts a lowercase letter to a corresponding uppercase letter. Input that + is not a lowercase letter remains unchanged. +*/ +int toupper( c ); + +#endif