diff options
Diffstat (limited to 'include/ctype.h')
-rw-r--r-- | include/ctype.h | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/include/ctype.h b/include/ctype.h index f01ad57..f98705d 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -35,7 +35,8 @@ * @return Whether the character is in * ['0', '9'], ['A', 'Z'], or ['a', 'z']. */ -int (isalnum)(int); /* [0x30, 0x39], [0x41, 0x5A], [0x61, 0x7A] */ +int (isalnum)(int) /* [0x30, 0x39], [0x41, 0x5A], [0x61, 0x7A] */ + __GCC_ONLY(__attribute__((const))); #if defined (__GNUC__) # define isalnum(c) \ ({ int __c = (c); (isalpha(__c) || isdigit(__c)); }) @@ -49,7 +50,8 @@ int (isalnum)(int); /* [0x30, 0x39], [0x41, 0x5A], [0x61, 0x7A] */ * @return Whether the character is in * ['A', 'Z'] or ['a', 'z']. */ -int (isalpha)(int); /* [0x41, 0x5A], [0x61, 0x7A] */ +int (isalpha)(int) /* [0x41, 0x5A], [0x61, 0x7A] */ + __GCC_ONLY(__attribute__((const))); #define isalpha(c) (islower(tolower(a))) @@ -63,7 +65,8 @@ int (isalpha)(int); /* [0x41, 0x5A], [0x61, 0x7A] */ * @param c The character. * @return Whether the character is a ' ' or a '\t'. */ -int (isblank)(int); /* ' ', '\t' */ +int (isblank)(int) /* ' ', '\t' */ + __GCC_ONLY(__attribute__((const))); # if defined(__GNUC__) # define isblank(c) \ ({ int __c = (c); ((__c == ' ') || (__c == '\t')); }) @@ -79,7 +82,8 @@ int (isblank)(int); /* ' ', '\t' */ * @return Whether the character is lower than ' ', * or is 0x7F. */ -int (iscntrl)(int); /* [0x00, 0x1F], 0x7F */ +int (iscntrl)(int) /* [0x00, 0x1F], 0x7F */ + __GCC_ONLY(__attribute__((const))); #if defined(__GNUC__) # define iscntrl(c) \ ({ int __c = (c); (((unsigned)__c < ' ') || (c__ == 0x7F)); }) @@ -92,7 +96,8 @@ int (iscntrl)(int); /* [0x00, 0x1F], 0x7F */ * @param c The character. * @return Whether the character is in ['0', '9']. */ -int (isdigit)(int); /* [0x30, 0x39] */ +int (isdigit)(int) /* [0x30, 0x39] */ + __GCC_ONLY(__attribute__((const))); #define isdigit(c) ((unsigned)((c) - '0') < 10) @@ -103,7 +108,8 @@ int (isdigit)(int); /* [0x30, 0x39] */ * @return Whether the character is greater * than ' ', but is not 0x7F. */ -int (isgraph)(int); /* [0x21, 0x7E] */ +int (isgraph)(int) /* [0x21, 0x7E] */ + __GCC_ONLY(__attribute__((const))); #define isgraph(c) ((unsigned)(c - 0x21) < 0x5E) @@ -114,7 +120,8 @@ int (isgraph)(int); /* [0x21, 0x7E] */ * @param c The character. * @return Whether the character is in ['a', 'z']. */ -int (islower)(int); /* [0x61, 0x7A] */ +int (islower)(int) /* [0x61, 0x7A] */ + __GCC_ONLY(__attribute__((const))); #define islower(c) ((unsigned)((c) - 'a') < 26) @@ -126,7 +133,8 @@ int (islower)(int); /* [0x61, 0x7A] */ * @return Whether the character is at least * as great as ' ', but is not 0x7F. */ -int (isprint)(int); /* [0x20, 0x7E] */ +int (isprint)(int) /* [0x20, 0x7E] */ + __GCC_ONLY(__attribute__((const))); #define isprint(c) ((unsigned)(c - 0x20) < 0x5F) @@ -138,7 +146,8 @@ int (isprint)(int); /* [0x20, 0x7E] */ * @param c The character. * @return Whether the character is a punctuation. */ -int (ispunct)(int); /* isprint && !isalnum && !isspace) */ +int (ispunct)(int) /* isprint && !isalnum && !isspace) */ + __GCC_ONLY(__attribute__((const))); #if defined (__GNUC__) # define ispunk(c) \ ({ int __c = (c); (isprint(__c) && !isalnum(__c) && !isspace(__c)); }) @@ -152,7 +161,8 @@ int (ispunct)(int); /* isprint && !isalnum && !isspace) */ * @return Whether the character is a ' ', '\f', * '\n', '\r', '\t', or '\v'. */ -int (isspace)(int); /* 0x20, [0x09, 0x0D] */ +int (isspace)(int) /* 0x20, [0x09, 0x0D] */ + __GCC_ONLY(__attribute__((const))); #if defined (__GNUC__) # define isspace(c) \ ({ int __c = (c); ((__c == ' ') || ((unsigned)(__c - '\t') < 5)); }) @@ -166,7 +176,8 @@ int (isspace)(int); /* 0x20, [0x09, 0x0D] */ * @param c The character. * @return Whether the character is in ['A', 'Z']. */ -int (isupper)(int); /* [0x41, 0x5A] */ +int (isupper)(int) /* [0x41, 0x5A] */ + __GCC_ONLY(__attribute__((const))); #define isupper(c) ((unsigned)((c) - 'A') < 26) @@ -179,7 +190,8 @@ int (isupper)(int); /* [0x41, 0x5A] */ * @return Whether the character is in * ['0', '9'], ['A', 'Z'], or ['a', 'z']. */ -int (isxdigit)(int); /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */ +int (isxdigit)(int) /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */ + __GCC_ONLY(__attribute__((const))); #if defined (__GNUC__) # define isxdigit(c) \ ({ int __c = (c); (isdigit(__c) && (tolower(__c) - 'a' < 6)); }) @@ -201,8 +213,9 @@ int (isxdigit)(int); /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */ * Guaranteed to be unchanged if the * character already is in lowercase. */ -int (tolower)(int); /* [0x41, 0x5A] -> [0x61, 0x7A] */ -#define tolower(c) ((c) | 0x20) +int (tolower)(int) /* [0x41, 0x5A] -> [0x61, 0x7A] */ + __GCC_ONLY(__attribute__((const))); +#define tolower(c) ((unsigned)(c) | 0x20) /** * Convert a lowercase ASCII character to @@ -218,8 +231,9 @@ int (tolower)(int); /* [0x41, 0x5A] -> [0x61, 0x7A] */ * Guaranteed to be unchanged if the * character already is in lowercase. */ -int (toupper)(int); /* [0x61, 0x7A] -> [0x41, 0x5A] */ -#define toupper(c) ((c) & ~0x20) +int (toupper)(int) /* [0x61, 0x7A] -> [0x41, 0x5A] */ + __GCC_ONLY(__attribute__((const))); +#define toupper(c) ((unsigned)(c) & ~0x20) @@ -229,7 +243,8 @@ int (toupper)(int); /* [0x61, 0x7A] -> [0x41, 0x5A] */ * @param c The character * @return - Whether the character is an ASCII character. */ -int (isascii)(int); /* [0x00, 0x7E] */ +int (isascii)(int) /* [0x00, 0x7E] */ + __GCC_ONLY(__attribute__((const))); #define isascii(c) ((unsigned)(c) < 0x7F) /** @@ -242,9 +257,10 @@ int (isascii)(int); /* [0x00, 0x7E] */ * @param c The character with the 8:th bit cleared. */ int (toascii)(int) - __warning("Using 'toascii' is, generally, unwise."); + __warning("Using 'toascii' is, generally, unwise.") + __GCC_ONLY(__attribute__((const))); #if defined(_SLIBC_SUPPRESS_WARNINGS) -# define toascii(c) ((c) & 0x7F) +# define toascii(c) ((unsigned)(c) & 0x7F) #endif /** @@ -252,14 +268,16 @@ int (toascii)(int) * It is provided for backwards-compatibility with SVID. */ int _tolower(int) - __deprecated("Use 'tolower' instead."); + __deprecated("Use 'tolower' instead.") + __GCC_ONLY(__attribute__((const))); /** * This function is identical to `tolower`. * It is provided for backwards-compatibility with SVID. */ int _toupper(int) - __deprecated("Use 'toupper' instead."); + __deprecated("Use 'toupper' instead.") + __GCC_ONLY(__attribute__((const))); |