summaryrefslogtreecommitdiff
path: root/libc/misc/wctype
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-27 10:19:19 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-27 10:19:19 +0000
commitcf578c75a521e1f35a9f07ca04c0cd678209c79f (patch)
tree03cf31e8d7db0d0fcdf8384278e672bf437dc423 /libc/misc/wctype
parent7779fe81082b7521e537b02cdf71f88aff3de358 (diff)
ctype: remove some trivial macros from ctype.h;
remove __tolower and __toupper (they existed only in SOME configs!); remove usages of _tolower (some of them clearly buggy) from uclibc code; add a few more -U<define> options to unifdef pass over installed headers; document it on docs/wchar_and_locale.txt text data bss dec hex filename - 514963 2727 15396 533086 8225e lib/libuClibc-0.9.30-svn.so + 514888 2727 15396 533011 82213 lib/libuClibc-0.9.30-svn.so
Diffstat (limited to 'libc/misc/wctype')
-rw-r--r--libc/misc/wctype/_wctype.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
index c3303d247..c6f536d91 100644
--- a/libc/misc/wctype/_wctype.c
+++ b/libc/misc/wctype/_wctype.c
@@ -701,23 +701,20 @@ libc_hidden_def(iswctype)
/* Minimal support for C/POSIX locale. */
-#ifndef _tolower
-#warning _tolower is undefined!
-#define _tolower(c) tolower(c)
-#endif
-#ifndef _toupper
-#warning _toupper is undefined!
-#define _toupper(c) toupper(c)
-#endif
-
wint_t towctrans(wint_t wc, wctrans_t desc)
{
- if (((unsigned int)(desc - _CTYPE_tolower))
- <= (_CTYPE_toupper - _CTYPE_tolower)
- ) {
+ if ((unsigned int)(desc - _CTYPE_tolower) <= (_CTYPE_toupper - _CTYPE_tolower)) {
/* Transliteration is either tolower or toupper. */
- if (((__uwchar_t) wc) <= 0x7f) {
- return (desc == _CTYPE_tolower) ? _tolower(wc) : _toupper(wc);
+// I think it's wrong: _toupper(c) assumes that c is a *lowercase* *letter* -
+// it is defined as ((c) ^ 0x20)!
+// if ((__uwchar_t) wc <= 0x7f) {
+// return (desc == _CTYPE_tolower) ? _tolower(wc) : _toupper(wc);
+// }
+ __uwchar_t c = wc | 0x20; /* lowercase if it's a letter */
+ if (c >= 'a' && c <= 'z') {
+ if (desc == _CTYPE_toupper)
+ c &= ~0x20; /* uppercase */
+ return c;
}
} else {
__set_errno(EINVAL); /* Invalid transliteration. */