From 59df6a0de67d0c43e66aca159af4b0b9458f909e Mon Sep 17 00:00:00 2001 From: bkoz Date: Wed, 13 Mar 2002 02:32:08 +0000 Subject: [PATCH] 2002-03-12 Benjamin Kosnik Per Liboriussen * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50708 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 20 ++++++++++++++++++++ .../config/os/gnu-linux/bits/ctype_inline.h | 12 +++++++----- .../config/os/gnu-linux/bits/ctype_noninline.h | 8 ++++---- .../config/os/irix/irix6.5/bits/ctype_inline.h | 17 +++++++---------- .../os/solaris/solaris2.5/bits/ctype_inline.h | 11 ++++++----- .../os/solaris/solaris2.5/bits/ctype_noninline.h | 6 ++---- .../os/solaris/solaris2.6/bits/ctype_inline.h | 11 ++++++----- .../os/solaris/solaris2.6/bits/ctype_noninline.h | 8 ++++---- .../os/solaris/solaris2.7/bits/ctype_inline.h | 11 ++++++----- .../os/solaris/solaris2.7/bits/ctype_noninline.h | 10 ++++------ .../testsuite/22_locale/ctype_members_char.cc | 21 ++++++++++++++++++++- 11 files changed, 86 insertions(+), 49 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9e07ffd..c055900 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,4 +1,24 @@ 2002-03-12 Benjamin Kosnik + Per Liboriussen + + * 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 * include/bits/basic_string.tcc (string::_S_construct(_InIter, _InIter, const _Alloc&, forward_iterator_tag): Check for null. diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h index e584083..af409c8 100644 --- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h @@ -1,6 +1,6 @@ // 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 @@ -37,14 +37,14 @@ bool ctype:: is(mask __m, char __c) const - { return _M_table[__c] & __m; } + { return _M_table[static_cast(__c)] & __m; } const char* ctype:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) - *__vec++ = _M_table[*__low++]; + *__vec++ = _M_table[static_cast(*__low++)]; return __high; } @@ -52,7 +52,8 @@ ctype:: 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(*__low)] & __m)) ++__low; return __low; } @@ -61,7 +62,8 @@ ctype:: 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(*__low)] & __m) != 0) ++__low; return __low; } diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h index 86a38fa..18324d1 100644 --- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h @@ -71,14 +71,14 @@ char ctype::do_toupper(char __c) const - { return _M_toupper[static_cast(__c)]; } + { return _M_toupper[static_cast(__c)]; } const char* ctype::do_toupper(char* __low, const char* __high) const { while (__low < __high) { - *__low = _M_toupper[static_cast(*__low)]; + *__low = _M_toupper[static_cast(*__low)]; ++__low; } return __high; @@ -86,14 +86,14 @@ char ctype::do_tolower(char __c) const - { return _M_tolower[static_cast(__c)]; } + { return _M_tolower[static_cast(__c)]; } const char* ctype::do_tolower(char* __low, const char* __high) const { while (__low < __high) { - *__low = _M_tolower[static_cast(*__low)]; + *__low = _M_tolower[static_cast(*__low)]; ++__low; } return __high; diff --git a/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_inline.h b/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_inline.h index 6a20c09..b7ab12d 100644 --- a/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_inline.h @@ -1,6 +1,6 @@ // 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 @@ -37,14 +37,14 @@ bool ctype:: is(mask __m, char __c) const - { return (_M_table)[__c] & __m; } + { return (_M_table)[static_cast(__c)] & __m; } const char* ctype:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) - *__vec++ = (_M_table)[*__low++]; + *__vec++ = (_M_table)[static_cast(*__low++)]; return __high; } @@ -52,7 +52,8 @@ ctype:: 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(*__low)] & __m)) ++__low; return __low; } @@ -61,12 +62,8 @@ ctype:: 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(*__low)] & __m) != 0) ++__low; return __low; } - - - - - diff --git a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h index affa494..93a04aa 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h @@ -1,6 +1,6 @@ // 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 @@ -37,14 +37,14 @@ bool ctype:: is(mask __m, char __c) const - { return (_M_table + 1)[(unsigned char)(__c)] & __m; } + { return (_M_table + 1)[static_cast(__c)] & __m; } const char* ctype:: 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(*__low++)]; return __high; } @@ -52,7 +52,8 @@ ctype:: 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(*__low)] & __m)) ++__low; return __low; } @@ -62,7 +63,7 @@ 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(*__low)] & __m) != 0) ++__low; return __low; } diff --git a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h index 9ab764a..f466afb 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h @@ -52,7 +52,7 @@ char ctype::do_toupper(char __c) const - { return ((_M_table + 258)[static_cast(__c)]); } + { return ((_M_table + 258)[static_cast(__c)]); } const char* ctype::do_toupper(char* __low, const char* __high) const @@ -67,7 +67,7 @@ char ctype::do_tolower(char __c) const - { return ((_M_table + 258)[static_cast(__c)]); } + { return ((_M_table + 258)[static_cast(__c)]); } const char* ctype::do_tolower(char* __low, const char* __high) const @@ -79,5 +79,3 @@ } return __high; } - - diff --git a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h index f254e83..0bd56a1 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h @@ -1,6 +1,6 @@ // 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 @@ -37,7 +37,7 @@ bool ctype:: is(mask __m, char __c) const - { return _M_table[__c] & __m; } + { return _M_table[static_cast(__c)] & __m; } const char* ctype:: @@ -46,7 +46,7 @@ const int __bitmasksize = sizeof(mask) * 8; for (;__low < __high; ++__vec, ++__low) { - mask __m = _M_table[*__low]; + mask __m = _M_table[static_cast(*__low)]; int __i = 0; // Lowest bitmask value from ctype_base. while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) ++__i; @@ -59,7 +59,8 @@ ctype:: 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(*__low)] & __m)) ++__low; return __low; } @@ -69,7 +70,7 @@ scan_not(mask __m, const char* __low, const char* __high) const { while (__low < __high - && (_M_table[*__low] & __m) != 0) + && (_M_table[static_cast(*__low)] & __m) != 0) ++__low; return __low; } diff --git a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h index 8e1c2d7..b22ad9a 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h @@ -52,14 +52,14 @@ char ctype::do_toupper(char __c) const - { return _M_toupper[(int) __c]; } + { return _M_toupper[static_cast(__c)]; } const char* ctype::do_toupper(char* __low, const char* __high) const { while (__low < __high) { - *__low = _M_toupper[(int) *__low]; + *__low = _M_toupper[static_cast(*__low)]; ++__low; } return __high; @@ -67,14 +67,14 @@ char ctype::do_tolower(char __c) const - { return _M_tolower[(int) __c]; } + { return _M_tolower[static_cast(__c)]; } const char* ctype::do_tolower(char* __low, const char* __high) const { while (__low < __high) { - *__low = _M_tolower[(int) *__low]; + *__low = _M_tolower[static_cast(*__low)]; ++__low; } return __high; diff --git a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h index 8ec057d..af409c8 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h @@ -1,6 +1,6 @@ // 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 @@ -37,14 +37,14 @@ bool ctype:: is(mask __m, char __c) const - { return _M_table[__c] & __m; } + { return _M_table[static_cast(__c)] & __m; } const char* ctype:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) - *__vec++ = _M_table[*__low++]; + *__vec++ = _M_table[static_cast(*__low++)]; return __high; } @@ -52,7 +52,8 @@ ctype:: 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(*__low)] & __m)) ++__low; return __low; } @@ -62,7 +63,7 @@ scan_not(mask __m, const char* __low, const char* __high) const { while (__low < __high - && (_M_table[*__low] & __m) != 0) + && (_M_table[static_cast(*__low)] & __m) != 0) ++__low; return __low; } diff --git a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h index eafc1fc..61462a9 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h @@ -53,14 +53,14 @@ char ctype::do_toupper(char __c) const - { return _M_toupper[(int) __c]; } + { return _M_toupper[static_cast(__c)]; } const char* ctype::do_toupper(char* __low, const char* __high) const { while (__low < __high) { - *__low = _M_toupper[(int) *__low]; + *__low = _M_toupper[static_cast(*__low)]; ++__low; } return __high; @@ -68,17 +68,15 @@ char ctype::do_tolower(char __c) const - { return _M_tolower[(int) __c]; } + { return _M_tolower[static_cast(__c)]; } const char* ctype::do_tolower(char* __low, const char* __high) const { while (__low < __high) { - *__low = _M_tolower[(int) *__low]; + *__low = _M_tolower[static_cast(*__low)]; ++__low; } return __high; } - - diff --git a/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc b/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc index cc69094..d1e47b6 100644 --- a/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc +++ b/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc @@ -243,9 +243,26 @@ public: { classic_table(); } }; -// libstdc++/5280 +// Per Liboriussen 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* f = new std::ctype(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"); @@ -257,6 +274,7 @@ void test03() { test01(); test02(); + test03(); setenv("LANG", oldLANG ? oldLANG : "", 1); } #endif @@ -267,5 +285,6 @@ int main() test01(); test02(); test03(); + test04(); return 0; } -- 2.7.4