diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2016-01-14 19:40:19 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2016-01-14 19:41:01 +0100 |
commit | a54fe77c04c7c2bda913ff63b0463417fb28794c (patch) | |
tree | 1ef85655a56b967a594d54813636b7196aa6ceab /include | |
parent | partially split malloc.c (diff) | |
download | slibc-a54fe77c04c7c2bda913ff63b0463417fb28794c.tar.gz slibc-a54fe77c04c7c2bda913ff63b0463417fb28794c.tar.bz2 slibc-a54fe77c04c7c2bda913ff63b0463417fb28794c.tar.xz |
misread specification
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/ctype.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/include/ctype.h b/include/ctype.h index 6da0ae2..8f253c1 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -256,11 +256,6 @@ int (isxdigit)(int) /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */ * Convert a uppercase ASCII character to * an lowercase ASCII character. * - * The function's behaviour is unspecified - * of the character is not alphabetical. - * You should consider running - * `(isupper(c) ? tolower(c) : c)` instead. - * * @etymology Convert character (to) (lower)case! * * @param c The character. @@ -272,17 +267,15 @@ int (isxdigit)(int) /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */ */ int (tolower)(int) /* [0x41, 0x5A] -> [0x61, 0x7A] */ __GCC_ONLY(__attribute__((__const__, __warn_unused_result__))); -#define tolower(c) (int)((unsigned)(c) | 0x20) +#if defined (__GNUC__) +# define tolower(c) \ + ({ int __c = (int)(unsigned)(c); (islower(__c) ? (__c | 0x20) : __c; }) +#endif /** * Convert a lowercase ASCII character to * an uppercase ASCII character. * - * The function's behaviour is unspecified - * of the character is not alphabetical. - * You should consider running - * `(isupper(c) ? tolower(c) : c)` instead. - * * @etymology Convert character (to) (upper)case! * * @param c The character. @@ -294,7 +287,10 @@ int (tolower)(int) /* [0x41, 0x5A] -> [0x61, 0x7A] */ */ int (toupper)(int) /* [0x61, 0x7A] -> [0x41, 0x5A] */ __GCC_ONLY(__attribute__((__const__, __warn_unused_result__))); -#define toupper(c) (int)((unsigned)(c) & (unsigned)~0x20) +#if defined (__GNUC__) +# define toupper(c) \ + ({ int __c = (int)(unsigned)(c); (isupper(__c) ? (__c & ~0x20) : __c; }) +#endif |