ctype_noninline.h: Cast to unsigned char.
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 13 Mar 2002 02:32:08 +0000 (02:32 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 13 Mar 2002 02:32:08 +0000 (02:32 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h
libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h
libstdc++-v3/config/os/irix/irix6.5/bits/ctype_inline.h
libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h
libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h
libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h
libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h
libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h
libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h
libstdc++-v3/testsuite/22_locale/ctype_members_char.cc

index 9e07ffd9419ec4ec54aabdf68887eea709f2093f..c055900584eb4e988fe291e049758c95c729064b 100644 (file)
@@ -1,3 +1,23 @@
+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,
index e584083a1d43407c340e987a9cf1b45b29edb5bf..af409c87629b10a189841c98b76f46a3551b3d5b 100644 (file)
@@ -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
   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;
   }
 
@@ -52,7 +52,8 @@
   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;
   }
@@ -61,7 +62,8 @@
   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;
   }
index 86a38fa8f584f4aa6e2d9b9d46c6e2773e6ff17e..18324d167dda1cef7dee0a65529963c4362d9267 100644 (file)
 
   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;
index 6a20c096cd5c692c0a9b7c891fc407a96bc4fb01..b7ab12dbf14607bdbe75a6ef5408e8043fd4b4bf 100644 (file)
@@ -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
   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;
   }
 
@@ -52,7 +52,8 @@
   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;
   }
-
-
-
-
-
index affa4945c601f599ff5c27217866f60a0e0d487e..93a04aa1b6d750c25a114372850cd7b2ba5d3f9f 100644 (file)
@@ -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
   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;
   }
 
@@ -52,7 +52,8 @@
   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;
   }
@@ -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<unsigned char>(*__low)] & __m) != 0)
       ++__low;
     return __low;
   }
index 9ab764a6c17becb810f8c49308bbc257dc757b70..f466afbc1cee643ae926db94fab56fa0d8d02f26 100644 (file)
@@ -52,7 +52,7 @@
 
   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
@@ -67,7 +67,7 @@
 
   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
@@ -79,5 +79,3 @@
       }
     return __high;
   }
-
-
index f254e839fb86ad25e314a039d297971952d973db..0bd56a19702151496854cdad38656395de7cd19c 100644 (file)
@@ -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<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>::
@@ -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<unsigned char>(*__low)];
        int __i = 0; // Lowest bitmask value from ctype_base.
        while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
          ++__i;
@@ -59,7 +59,8 @@
   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;
   }
@@ -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<unsigned char>(*__low)] & __m) != 0)
       ++__low;
     return __low;
   }
index 8e1c2d76f9724d7f41bff224741a4ea9ac01df8e..b22ad9a137433ffd3ee92b7c0b1d723dde1f28c9 100644 (file)
 
   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;
index 8ec057dfb4756410cb12164652fb38d50faafb8d..af409c87629b10a189841c98b76f46a3551b3d5b 100644 (file)
@@ -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
   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;
   }
 
@@ -52,7 +52,8 @@
   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;
   }
@@ -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<unsigned char>(*__low)] & __m) != 0)
       ++__low;
     return __low;
   }
index eafc1fc71e2411d2031c43024fad3cd31709b306..61462a909453e8dad17b0aef4c50eeb1347e38c0 100644 (file)
 
   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;
   }
-
-
index cc69094c34514a10b8cdec7b09b653d2befd967a..d1e47b6bbbd5bc4c5e6e9158219359e6da44007c 100644 (file)
@@ -243,8 +243,25 @@ public:
   { 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".
@@ -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;
 }