Commit f7145757 by Benjamin Kosnik Committed by Benjamin Kosnik

ctype_noninline.h: Cast to unsigned char.


2002-03-12  Benjamin Kosnik  <bkoz@redhat.com>
            Per Liboriussen  <liborius@stofanet.dk>

	* config/os/gnu-linux/bits/ctype_noninline.h: Cast to
	unsigned char.
	* config/os/gnu-linux/bits/ctype_inline.h: Same.

	* config/os/irix/irix6.5/bits/ctype_inline.h: Same.

	* config/os/solaris/solaris2.5/bits/ctype_inline.h: Same.
	* config/os/solaris/solaris2.5/bits/ctype_noninline.h: Same.

	* config/os/solaris/solaris2.6/bits/ctype_inline.h: Same.
	* config/os/solaris/solaris2.6/bits/ctype_noninline.h: Same.

	* config/os/solaris/solaris2.7/bits/ctype_inline.h: Same.
	* config/os/solaris/solaris2.7/bits/ctype_noninline.h: Same.

	* testsuite/22_locale/ctype_members_char.cc (main): Add tests.

Co-Authored-By: Per Liboriussen <liborius@stofanet.dk>

From-SVN: r50708
parent 4e9bb42b
2002-03-12 Benjamin Kosnik <bkoz@redhat.com> 2002-03-12 Benjamin Kosnik <bkoz@redhat.com>
Per Liboriussen <liborius@stofanet.dk>
* config/os/gnu-linux/bits/ctype_noninline.h: Cast to
unsigned char.
* config/os/gnu-linux/bits/ctype_inline.h: Same.
* config/os/irix/irix6.5/bits/ctype_inline.h: Same.
* config/os/solaris/solaris2.5/bits/ctype_inline.h: Same.
* config/os/solaris/solaris2.5/bits/ctype_noninline.h: Same.
* config/os/solaris/solaris2.6/bits/ctype_inline.h: Same.
* config/os/solaris/solaris2.6/bits/ctype_noninline.h: Same.
* config/os/solaris/solaris2.7/bits/ctype_inline.h: Same.
* config/os/solaris/solaris2.7/bits/ctype_noninline.h: Same.
* testsuite/22_locale/ctype_members_char.cc (main): Add tests.
2002-03-12 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/basic_string.tcc (string::_S_construct(_InIter, * include/bits/basic_string.tcc (string::_S_construct(_InIter,
_InIter, const _Alloc&, forward_iterator_tag): Check for null. _InIter, const _Alloc&, forward_iterator_tag): Check for null.
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 2000 Free Software Foundation, Inc. // Copyright (C) 2000, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -37,14 +37,14 @@ ...@@ -37,14 +37,14 @@
bool bool
ctype<char>:: ctype<char>::
is(mask __m, char __c) const is(mask __m, char __c) const
{ return _M_table[__c] & __m; } { return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char* const char*
ctype<char>:: ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const is(const char* __low, const char* __high, mask* __vec) const
{ {
while (__low < __high) while (__low < __high)
*__vec++ = _M_table[*__low++]; *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
return __high; return __high;
} }
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
ctype<char>:: ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const scan_is(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && !(_M_table[*__low] & __m)) while (__low < __high
&& !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++__low; ++__low;
return __low; return __low;
} }
...@@ -61,7 +62,8 @@ ...@@ -61,7 +62,8 @@
ctype<char>:: ctype<char>::
scan_not(mask __m, const char* __low, const char* __high) const scan_not(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && (_M_table[*__low] & __m) != 0) while (__low < __high
&& (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low; ++__low;
return __low; return __low;
} }
...@@ -71,14 +71,14 @@ ...@@ -71,14 +71,14 @@
char char
ctype<char>::do_toupper(char __c) const ctype<char>::do_toupper(char __c) const
{ return _M_toupper[static_cast<int>(__c)]; } { return _M_toupper[static_cast<unsigned char>(__c)]; }
const char* const char*
ctype<char>::do_toupper(char* __low, const char* __high) const ctype<char>::do_toupper(char* __low, const char* __high) const
{ {
while (__low < __high) while (__low < __high)
{ {
*__low = _M_toupper[static_cast<int>(*__low)]; *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++__low; ++__low;
} }
return __high; return __high;
...@@ -86,14 +86,14 @@ ...@@ -86,14 +86,14 @@
char char
ctype<char>::do_tolower(char __c) const ctype<char>::do_tolower(char __c) const
{ return _M_tolower[static_cast<int>(__c)]; } { return _M_tolower[static_cast<unsigned char>(__c)]; }
const char* const char*
ctype<char>::do_tolower(char* __low, const char* __high) const ctype<char>::do_tolower(char* __low, const char* __high) const
{ {
while (__low < __high) while (__low < __high)
{ {
*__low = _M_tolower[static_cast<int>(*__low)]; *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++__low; ++__low;
} }
return __high; return __high;
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 2000 Free Software Foundation, Inc. // Copyright (C) 2000, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -37,14 +37,14 @@ ...@@ -37,14 +37,14 @@
bool bool
ctype<char>:: ctype<char>::
is(mask __m, char __c) const is(mask __m, char __c) const
{ return (_M_table)[__c] & __m; } { return (_M_table)[static_cast<unsigned char>(__c)] & __m; }
const char* const char*
ctype<char>:: ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const is(const char* __low, const char* __high, mask* __vec) const
{ {
while (__low < __high) while (__low < __high)
*__vec++ = (_M_table)[*__low++]; *__vec++ = (_M_table)[static_cast<unsigned char>(*__low++)];
return __high; return __high;
} }
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
ctype<char>:: ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const scan_is(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && !((_M_table)[*__low] & __m)) while (__low < __high
&& !((_M_table)[static_cast<unsigned char>(*__low)] & __m))
++__low; ++__low;
return __low; return __low;
} }
...@@ -61,12 +62,8 @@ ...@@ -61,12 +62,8 @@
ctype<char>:: ctype<char>::
scan_not(mask __m, const char* __low, const char* __high) const scan_not(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && ((_M_table + 1)[*__low] & __m) != 0) while (__low < __high
&& ((_M_table + 1)[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low; ++__low;
return __low; return __low;
} }
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. // Copyright (C) 1997-1999, 2000, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -37,14 +37,14 @@ ...@@ -37,14 +37,14 @@
bool bool
ctype<char>:: ctype<char>::
is(mask __m, char __c) const is(mask __m, char __c) const
{ return (_M_table + 1)[(unsigned char)(__c)] & __m; } { return (_M_table + 1)[static_cast<unsigned char>(__c)] & __m; }
const char* const char*
ctype<char>:: ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const is(const char* __low, const char* __high, mask* __vec) const
{ {
while (__low < __high) while (__low < __high)
*__vec++ = (_M_table + 1)[(unsigned char) (*__low++)]; *__vec++ = (_M_table + 1)[static_cast<unsigned char>(*__low++)];
return __high; return __high;
} }
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
ctype<char>:: ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const scan_is(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && !((_M_table + 1)[(unsigned char)(*__low)] & __m)) while (__low < __high
&& !((_M_table + 1)[static_cast<unsigned char>(*__low)] & __m))
++__low; ++__low;
return __low; return __low;
} }
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
scan_not(mask __m, const char* __low, const char* __high) const scan_not(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high while (__low < __high
&& ((_M_table + 1)[(unsigned char)(*__low)] & __m) != 0) && ((_M_table + 1)[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low; ++__low;
return __low; return __low;
} }
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
char char
ctype<char>::do_toupper(char __c) const ctype<char>::do_toupper(char __c) const
{ return ((_M_table + 258)[static_cast<int>(__c)]); } { return ((_M_table + 258)[static_cast<unsigned char>(__c)]); }
const char* const char*
ctype<char>::do_toupper(char* __low, const char* __high) const ctype<char>::do_toupper(char* __low, const char* __high) const
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
char char
ctype<char>::do_tolower(char __c) const ctype<char>::do_tolower(char __c) const
{ return ((_M_table + 258)[static_cast<int>(__c)]); } { return ((_M_table + 258)[static_cast<unsigned char>(__c)]); }
const char* const char*
ctype<char>::do_tolower(char* __low, const char* __high) const ctype<char>::do_tolower(char* __low, const char* __high) const
...@@ -79,5 +79,3 @@ ...@@ -79,5 +79,3 @@
} }
return __high; return __high;
} }
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 2000 Free Software Foundation, Inc. // Copyright (C) 2000, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
bool bool
ctype<char>:: ctype<char>::
is(mask __m, char __c) const is(mask __m, char __c) const
{ return _M_table[__c] & __m; } { return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char* const char*
ctype<char>:: ctype<char>::
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
const int __bitmasksize = sizeof(mask) * 8; const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low) for (;__low < __high; ++__vec, ++__low)
{ {
mask __m = _M_table[*__low]; mask __m = _M_table[static_cast<unsigned char>(*__low)];
int __i = 0; // Lowest bitmask value from ctype_base. int __i = 0; // Lowest bitmask value from ctype_base.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i))) while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i; ++__i;
...@@ -59,7 +59,8 @@ ...@@ -59,7 +59,8 @@
ctype<char>:: ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const scan_is(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && !(_M_table[*__low] & __m)) while (__low < __high
&& !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++__low; ++__low;
return __low; return __low;
} }
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
scan_not(mask __m, const char* __low, const char* __high) const scan_not(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high while (__low < __high
&& (_M_table[*__low] & __m) != 0) && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low; ++__low;
return __low; return __low;
} }
...@@ -52,14 +52,14 @@ ...@@ -52,14 +52,14 @@
char char
ctype<char>::do_toupper(char __c) const ctype<char>::do_toupper(char __c) const
{ return _M_toupper[(int) __c]; } { return _M_toupper[static_cast<unsigned char>(__c)]; }
const char* const char*
ctype<char>::do_toupper(char* __low, const char* __high) const ctype<char>::do_toupper(char* __low, const char* __high) const
{ {
while (__low < __high) while (__low < __high)
{ {
*__low = _M_toupper[(int) *__low]; *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++__low; ++__low;
} }
return __high; return __high;
...@@ -67,14 +67,14 @@ ...@@ -67,14 +67,14 @@
char char
ctype<char>::do_tolower(char __c) const ctype<char>::do_tolower(char __c) const
{ return _M_tolower[(int) __c]; } { return _M_tolower[static_cast<unsigned char>(__c)]; }
const char* const char*
ctype<char>::do_tolower(char* __low, const char* __high) const ctype<char>::do_tolower(char* __low, const char* __high) const
{ {
while (__low < __high) while (__low < __high)
{ {
*__low = _M_tolower[(int) *__low]; *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++__low; ++__low;
} }
return __high; return __high;
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 2000 Free Software Foundation, Inc. // Copyright (C) 2000, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -37,14 +37,14 @@ ...@@ -37,14 +37,14 @@
bool bool
ctype<char>:: ctype<char>::
is(mask __m, char __c) const is(mask __m, char __c) const
{ return _M_table[__c] & __m; } { return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char* const char*
ctype<char>:: ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const is(const char* __low, const char* __high, mask* __vec) const
{ {
while (__low < __high) while (__low < __high)
*__vec++ = _M_table[*__low++]; *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
return __high; return __high;
} }
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
ctype<char>:: ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const scan_is(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high && !(_M_table[*__low] & __m)) while (__low < __high
&& !(_M_table[static_cast<unsigned char>(*__low)] & __m))
++__low; ++__low;
return __low; return __low;
} }
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
scan_not(mask __m, const char* __low, const char* __high) const scan_not(mask __m, const char* __low, const char* __high) const
{ {
while (__low < __high while (__low < __high
&& (_M_table[*__low] & __m) != 0) && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low; ++__low;
return __low; return __low;
} }
...@@ -53,14 +53,14 @@ ...@@ -53,14 +53,14 @@
char char
ctype<char>::do_toupper(char __c) const ctype<char>::do_toupper(char __c) const
{ return _M_toupper[(int) __c]; } { return _M_toupper[static_cast<unsigned char>(__c)]; }
const char* const char*
ctype<char>::do_toupper(char* __low, const char* __high) const ctype<char>::do_toupper(char* __low, const char* __high) const
{ {
while (__low < __high) while (__low < __high)
{ {
*__low = _M_toupper[(int) *__low]; *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++__low; ++__low;
} }
return __high; return __high;
...@@ -68,17 +68,15 @@ ...@@ -68,17 +68,15 @@
char char
ctype<char>::do_tolower(char __c) const ctype<char>::do_tolower(char __c) const
{ return _M_tolower[(int) __c]; } { return _M_tolower[static_cast<unsigned char>(__c)]; }
const char* const char*
ctype<char>::do_tolower(char* __low, const char* __high) const ctype<char>::do_tolower(char* __low, const char* __high) const
{ {
while (__low < __high) while (__low < __high)
{ {
*__low = _M_tolower[(int) *__low]; *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++__low; ++__low;
} }
return __high; return __high;
} }
...@@ -243,9 +243,26 @@ public: ...@@ -243,9 +243,26 @@ public:
{ classic_table(); } { classic_table(); }
}; };
// libstdc++/5280 // Per Liboriussen <liborius@stofanet.dk>
void test03() void test03()
{ {
bool test = true;
std::ctype_base::mask maskdata[256];
for (int i = 0; i < 256; ++i)
maskdata[i] = std::ctype_base::alpha;
std::ctype<char>* f = new std::ctype<char>(maskdata);
std::locale global;
std::locale loc(global, f);
for (int i = 0; i < 256; ++i)
{
char ch = i;
VERIFY( std::isalpha(ch, loc) );
}
}
// libstdc++/5280
void test04()
{
#ifdef _GLIBCPP_HAVE_SETENV #ifdef _GLIBCPP_HAVE_SETENV
// Set the global locale to non-"C". // Set the global locale to non-"C".
std::locale loc_de("de_DE"); std::locale loc_de("de_DE");
...@@ -257,6 +274,7 @@ void test03() ...@@ -257,6 +274,7 @@ void test03()
{ {
test01(); test01();
test02(); test02();
test03();
setenv("LANG", oldLANG ? oldLANG : "", 1); setenv("LANG", oldLANG ? oldLANG : "", 1);
} }
#endif #endif
...@@ -267,5 +285,6 @@ int main() ...@@ -267,5 +285,6 @@ int main()
test01(); test01();
test02(); test02();
test03(); test03();
test04();
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment