summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/ctype/ctype.c6
-rw-r--r--libc/misc/regex/regcomp.c2
-rw-r--r--libc/misc/regex/regex.c4
-rw-r--r--libc/misc/regex/regex_internal.c4
-rw-r--r--libc/misc/regex/regex_old.c2
-rw-r--r--libc/misc/wctype/_wctype.c25
6 files changed, 19 insertions, 24 deletions
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index 8c99d004c..8d20a39cf 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -319,7 +319,8 @@ int tolower_l(int c, __locale_t l)
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_tolower[c] : c;
}
libc_hidden_def(tolower_l)
-weak_alias (tolower_l, __tolower_l)
+//remove after 0.9.31. See ctype.h for why.
+//weak_alias (tolower_l, __tolower_l)
#endif
/**********************************************************************/
@@ -366,7 +367,8 @@ int toupper_l(int c, __locale_t l)
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_toupper[c] : c;
}
libc_hidden_def(toupper_l)
-weak_alias (toupper_l, __toupper_l)
+//remove after 0.9.31. See ctype.h for why.
+//weak_alias (toupper_l, __toupper_l)
#endif
/**********************************************************************/
diff --git a/libc/misc/regex/regcomp.c b/libc/misc/regex/regcomp.c
index 720214161..0c348a48d 100644
--- a/libc/misc/regex/regcomp.c
+++ b/libc/misc/regex/regcomp.c
@@ -281,7 +281,7 @@ re_set_fastmap (char *fastmap, int icase, int ch)
{
fastmap[ch] = 1;
if (icase)
- fastmap[__tolower (ch)] = 1;
+ fastmap[tolower (ch)] = 1;
}
/* Helper function for re_compile_fastmap.
diff --git a/libc/misc/regex/regex.c b/libc/misc/regex/regex.c
index bc2e502f6..fa46f635f 100644
--- a/libc/misc/regex/regex.c
+++ b/libc/misc/regex/regex.c
@@ -38,10 +38,6 @@
# define __wctype wctype
# endif
# include <ctype.h>
-# ifdef __UCLIBC_HAS_CTYPE_TABLES__
-# define __toupper toupper
-# define __tolower tolower
-# endif
#endif
/* Make sure noone compiles this code with a C++ compiler. */
diff --git a/libc/misc/regex/regex_internal.c b/libc/misc/regex/regex_internal.c
index c6685528d..493985217 100644
--- a/libc/misc/regex/regex_internal.c
+++ b/libc/misc/regex/regex_internal.c
@@ -289,7 +289,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
{
/* In case of a singlebyte character. */
pstr->mbs[byte_idx]
- = __toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
+ = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
/* The next step uses the assumption that wchar_t is encoded
ASCII-safe: all ASCII values can be converted like this. */
pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
@@ -523,7 +523,7 @@ build_upper_buffer (re_string_t *pstr)
if (BE (pstr->trans != NULL, 0))
ch = pstr->trans[ch];
if (islower (ch))
- pstr->mbs[char_idx] = __toupper (ch);
+ pstr->mbs[char_idx] = toupper (ch);
else
pstr->mbs[char_idx] = ch;
}
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index af1af50a6..bdc298a3e 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -226,7 +226,7 @@ char *realloc ();
# ifdef _tolower
# define TOLOWER(c) _tolower(c)
# else
-# define TOLOWER(c) __tolower(c)
+# define TOLOWER(c) tolower(c)
# endif
# ifndef NULL
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. */