diff options
author | Eric Blake <eblake@redhat.com> | 2009-04-30 22:53:00 +0000 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2009-04-30 22:53:00 +0000 |
commit | 82b77480f797603e3425228b83ed3c0cbc2a2977 (patch) | |
tree | 2a010ef8c9c4b40a9b8354f4e8493f002e35aeea /newlib/libc/include | |
parent | 47b09662ee3bfc612507f15e1d4ab6af7046ed61 (diff) | |
download | cygnal-82b77480f797603e3425228b83ed3c0cbc2a2977.tar.gz cygnal-82b77480f797603e3425228b83ed3c0cbc2a2977.tar.bz2 cygnal-82b77480f797603e3425228b83ed3c0cbc2a2977.zip |
Allow gcc warning for toupper even with extended charsets.
* libc/include/ctype.h (toupper, tolower)
[_MB_EXTENDED_CHARSETS_ISO]: Allow gcc warning when called with
'char' even when we must call the function for correct behavior.
[!_MB_EXTENDED_CHARSETS_ISO]: Fix regression in result type.
Diffstat (limited to 'newlib/libc/include')
-rw-r--r-- | newlib/libc/include/ctype.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h index acded28e8..e1d2d01c8 100644 --- a/newlib/libc/include/ctype.h +++ b/newlib/libc/include/ctype.h @@ -71,14 +71,25 @@ extern __IMPORT char *__ctype_ptr__; /* Non-gcc versions will get the library versions, and will be slightly slower. These macros are not NLS-aware so they are disabled if the system supports the extended character sets. */ -# if defined(__GNUC__) && !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS) -# define toupper(__c) \ +# if defined(__GNUC__) +# if !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS) +# define toupper(__c) \ __extension__ ({ __typeof__ (__c) __x = (__c); \ - islower(__x) ? (__x - 'a' + 'A') : __x;}) -# define tolower(__c) \ + islower (__x) ? (int) __x - 'a' + 'A' : (int) __x;}) +# define tolower(__c) \ __extension__ ({ __typeof__ (__c) __x = (__c); \ - isupper(__x) ? (__x - 'A' + 'a') : __x;}) -#endif + isupper (__x) ? (int) __x - 'A' + 'a' : (int) __x;}) +# else /* _MB_EXTENDED_CHARSETS* */ +/* Allow a gcc warning if the user passed 'char', but defer to the + function. */ +# define toupper(__c) \ + __extension__ ({ __typeof__ (__c) __x = (__c); \ + (void) __ctype_ptr__[__x]; (toupper) (__x);}) +# define tolower(__c) \ + __extension__ ({ __typeof__ (__c) __x = (__c); \ + (void) __ctype_ptr__[__x]; (tolower) (__x);}) +# endif /* _MB_EXTENDED_CHARSETS* */ +# endif /* __GNUC__ */ #endif /* !__cplusplus */ #ifndef __STRICT_ANSI__ |