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,
_InIter, const _Alloc&, forward_iterator_tag): Check for null.
// 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
// software; you can redistribute it and/or modify it under the
bool
ctype<char>::
is(mask __m, char __c) const
- { return _M_table[__c] & __m; }
+ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const
{
while (__low < __high)
- *__vec++ = _M_table[*__low++];
+ *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
return __high;
}
ctype<char>::
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;
return __low;
}
ctype<char>::
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;
return __low;
}
char
ctype<char>::do_toupper(char __c) const
- { return _M_toupper[static_cast<int>(__c)]; }
+ { return _M_toupper[static_cast<unsigned char>(__c)]; }
const char*
ctype<char>::do_toupper(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = _M_toupper[static_cast<int>(*__low)];
+ *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++__low;
}
return __high;
char
ctype<char>::do_tolower(char __c) const
- { return _M_tolower[static_cast<int>(__c)]; }
+ { return _M_tolower[static_cast<unsigned char>(__c)]; }
const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = _M_tolower[static_cast<int>(*__low)];
+ *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++__low;
}
return __high;
// 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
// software; you can redistribute it and/or modify it under the
bool
ctype<char>::
is(mask __m, char __c) const
- { return (_M_table)[__c] & __m; }
+ { return (_M_table)[static_cast<unsigned char>(__c)] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const
{
while (__low < __high)
- *__vec++ = (_M_table)[*__low++];
+ *__vec++ = (_M_table)[static_cast<unsigned char>(*__low++)];
return __high;
}
ctype<char>::
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;
return __low;
}
ctype<char>::
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;
return __low;
}
-
-
-
-
-
// 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
// software; you can redistribute it and/or modify it under the
bool
ctype<char>::
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*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const
{
while (__low < __high)
- *__vec++ = (_M_table + 1)[(unsigned char) (*__low++)];
+ *__vec++ = (_M_table + 1)[static_cast<unsigned char>(*__low++)];
return __high;
}
ctype<char>::
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;
return __low;
}
scan_not(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
- && ((_M_table + 1)[(unsigned char)(*__low)] & __m) != 0)
+ && ((_M_table + 1)[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low;
return __low;
}
char
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*
ctype<char>::do_toupper(char* __low, const char* __high) const
char
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*
ctype<char>::do_tolower(char* __low, const char* __high) const
}
return __high;
}
-
-
// 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
// software; you can redistribute it and/or modify it under the
bool
ctype<char>::
is(mask __m, char __c) const
- { return _M_table[__c] & __m; }
+ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char*
ctype<char>::
const int __bitmasksize = sizeof(mask) * 8;
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.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
ctype<char>::
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;
return __low;
}
scan_not(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
- && (_M_table[*__low] & __m) != 0)
+ && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low;
return __low;
}
char
ctype<char>::do_toupper(char __c) const
- { return _M_toupper[(int) __c]; }
+ { return _M_toupper[static_cast<unsigned char>(__c)]; }
const char*
ctype<char>::do_toupper(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = _M_toupper[(int) *__low];
+ *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++__low;
}
return __high;
char
ctype<char>::do_tolower(char __c) const
- { return _M_tolower[(int) __c]; }
+ { return _M_tolower[static_cast<unsigned char>(__c)]; }
const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = _M_tolower[(int) *__low];
+ *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++__low;
}
return __high;
// 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
// software; you can redistribute it and/or modify it under the
bool
ctype<char>::
is(mask __m, char __c) const
- { return _M_table[__c] & __m; }
+ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const
{
while (__low < __high)
- *__vec++ = _M_table[*__low++];
+ *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
return __high;
}
ctype<char>::
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;
return __low;
}
scan_not(mask __m, const char* __low, const char* __high) const
{
while (__low < __high
- && (_M_table[*__low] & __m) != 0)
+ && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
++__low;
return __low;
}
char
ctype<char>::do_toupper(char __c) const
- { return _M_toupper[(int) __c]; }
+ { return _M_toupper[static_cast<unsigned char>(__c)]; }
const char*
ctype<char>::do_toupper(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = _M_toupper[(int) *__low];
+ *__low = _M_toupper[static_cast<unsigned char>(*__low)];
++__low;
}
return __high;
char
ctype<char>::do_tolower(char __c) const
- { return _M_tolower[(int) __c]; }
+ { return _M_tolower[static_cast<unsigned char>(__c)]; }
const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = _M_tolower[(int) *__low];
+ *__low = _M_tolower[static_cast<unsigned char>(*__low)];
++__low;
}
return __high;
}
-
-
{ classic_table(); }
};
-// libstdc++/5280
+// Per Liboriussen <liborius@stofanet.dk>
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
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
{
test01();
test02();
+ test03();
setenv("LANG", oldLANG ? oldLANG : "", 1);
}
#endif
test01();
test02();
test03();
+ test04();
return 0;
}