165 lines
4.3 KiB
C
165 lines
4.3 KiB
C
#ifndef VLIBC_CTYPE_H
|
|
#define VLIBC_CTYPE_H
|
|
|
|
/*
|
|
* vlibc — <ctype.h>.
|
|
*
|
|
* Character classification and case mapping. Every function takes an int
|
|
* that represents an unsigned char value or EOF (-1). The implementation
|
|
* always casts the argument to unsigned char before any table lookup, so a
|
|
* negative char value can never index out of bounds; EOF classifies false
|
|
* in every is* function, and tolower/toupper pass it (and every non-letter)
|
|
* through unchanged. All results are for the "C" locale.
|
|
*
|
|
* Levels are cumulative (see include/vlibc/features.h):
|
|
* Level 1 (onlyposix): ISO C — the classification and case-mapping
|
|
* functions.
|
|
* Level 2 (muslmimic): XSI — isascii, toascii.
|
|
*
|
|
* This header includes <vlibc/features.h> itself, so the gates below always
|
|
* see the configured VLIBC_LEVEL even when the caller included no vlibc
|
|
* header first. The classification functions return exactly 1 when the
|
|
* character is in the class and 0 otherwise, never any other nonzero value.
|
|
*/
|
|
|
|
#include <vlibc/features.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Level 1: ISO C (always present). */
|
|
|
|
/*
|
|
* Nonzero when c is alphanumeric: a letter or a decimal digit.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isalnum(int c);
|
|
|
|
/*
|
|
* Nonzero when c is a letter.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isalpha(int c);
|
|
|
|
/*
|
|
* Nonzero when c is blank: space or horizontal tab.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isblank(int c);
|
|
|
|
/*
|
|
* Nonzero when c is a control character (0x00..0x1f or 0x7f).
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
iscntrl(int c);
|
|
|
|
/*
|
|
* Nonzero when c is a decimal digit.
|
|
* const: bit arithmetic on the argument alone (also matches GCC's const
|
|
* builtin declaration for isdigit).
|
|
*/
|
|
__attribute__((const)) int
|
|
isdigit(int c);
|
|
|
|
/*
|
|
* Nonzero when c has a visible representation (printable, except space).
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isgraph(int c);
|
|
|
|
/*
|
|
* Nonzero when c is a lowercase letter.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
islower(int c);
|
|
|
|
/*
|
|
* Nonzero when c is printable (0x20..0x7e).
|
|
* pure: the implementation is bit arithmetic on the argument alone, but
|
|
* GCC's isprint builtin is declared pure, and a const redeclaration would
|
|
* conflict with it.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isprint(int c);
|
|
|
|
/*
|
|
* Nonzero when c is a punctuation character: printable and not alphanumeric
|
|
* and not space.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
ispunct(int c);
|
|
|
|
/*
|
|
* Nonzero when c is white space (space, form feed, newline, carriage
|
|
* return, horizontal or vertical tab).
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isspace(int c);
|
|
|
|
/*
|
|
* Nonzero when c is an uppercase letter.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
isupper(int c);
|
|
|
|
/*
|
|
* Nonzero when c is a hexadecimal digit (0-9, a-f, A-F).
|
|
* const: bit arithmetic on the argument alone (also matches GCC's const
|
|
* builtin declaration for isxdigit).
|
|
*/
|
|
__attribute__((const)) int
|
|
isxdigit(int c);
|
|
|
|
/*
|
|
* Return the lowercase counterpart of c when c is an uppercase letter
|
|
* ('A'..'Z' in the "C" locale); otherwise return c unchanged, including
|
|
* EOF.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
tolower(int c);
|
|
|
|
/*
|
|
* Return the uppercase counterpart of c when c is a lowercase letter
|
|
* ('a'..'z' in the "C" locale); otherwise return c unchanged, including
|
|
* EOF.
|
|
* pure: reads the classification table, no side effects.
|
|
*/
|
|
__attribute__((pure)) int
|
|
toupper(int c);
|
|
|
|
#if VLIBC_LEVEL_GE(2)
|
|
/* Level 2 (muslmimic): XSI. */
|
|
|
|
/*
|
|
* Nonzero when c is a 7-bit ASCII value (0..127). EOF and negative values
|
|
* are outside the range.
|
|
* const: depends only on its argument.
|
|
*/
|
|
__attribute__((const)) int
|
|
isascii(int c);
|
|
|
|
/*
|
|
* Clear every bit above the low 7 of c (c & 0x7f).
|
|
* const: depends only on its argument.
|
|
*/
|
|
__attribute__((const)) int
|
|
toascii(int c);
|
|
#endif /* VLIBC_LEVEL_GE(2) */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* VLIBC_CTYPE_H */
|