Add explicit casts to unsigned char before calling ctype functions.

Fixes the value range on platforms with signed char.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@180940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Joerg Sonnenberger
2013-05-02 19:17:48 +00:00
parent 15467189c3
commit 63d8f7e341
6 changed files with 9 additions and 9 deletions

View File

@@ -1068,28 +1068,28 @@ ctype_byname<char>::~ctype_byname()
char
ctype_byname<char>::do_toupper(char_type c) const
{
return static_cast<char>(toupper_l(c, __l));
return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l));
}
const char*
ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
{
for (; low != high; ++low)
*low = static_cast<char>(toupper_l(*low, __l));
*low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l));
return low;
}
char
ctype_byname<char>::do_tolower(char_type c) const
{
return static_cast<char>(tolower_l(c, __l));
return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l));
}
const char*
ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
{
for (; low != high; ++low)
*low = static_cast<char>(tolower_l(*low, __l));
*low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l));
return low;
}