From cf578c75a521e1f35a9f07ca04c0cd678209c79f Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 27 Dec 2008 10:19:19 +0000 Subject: 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 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 --- libc/misc/wctype/_wctype.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'libc/misc/wctype') 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. */ -- cgit v1.2.3