libstdc++: std::ctype fixes for recent versions of NetBSD
authorJonathan Wakely <jwakely@redhat.com>
Fri, 10 Jan 2020 16:01:19 +0000 (16:01 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 16 Jan 2020 16:30:12 +0000 (16:30 +0000)
This removes support for EOL versions of NetBSD and syncs the
definitions with patches from NetBSD upstream.

The only change here that isn't from upstream is to use _CTYPE_BL for
the isblank class, which is correct but wasn't previously done either in
FSF GCC or the NetBSD packages.

2020-01-16  Kai-Uwe Eckhardt  <kuehro@gmx.de>
    Matthew Bauer  <mjbauer95@gmail.com>
    Jonathan Wakely  <jwakely@redhat.com>

PR bootstrap/64271 (partial)
* config/os/bsd/netbsd/ctype_base.h (ctype_base::mask): Change type
to unsigned short.
(ctype_base::alpha, ctype_base::digit, ctype_base::xdigit)
(ctype_base::print, ctype_base::graph, ctype_base::alnum): Sync
definitions with NetBSD upstream.
(ctype_base::blank): Use _CTYPE_BL.
* config/os/bsd/netbsd/ctype_configure_char.cc (_C_ctype_): Remove
Declaration.
(ctype<char>::classic_table): Use _C_ctype_tab_ instead of _C_ctype_.
(ctype<char>::do_toupper, ctype<char>::do_tolower): Cast char
parameters to unsigned char.
* config/os/bsd/netbsd/ctype_inline.h (ctype<char>::is): Likewise.

libstdc++-v3/ChangeLog
libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc
libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h

index d99c1bbdabcd8ce84cf53b2cb05ad94fde82e646..c37d3b1bfe3e2dbb5406b64f1f267169379a3540 100644 (file)
@@ -1,3 +1,21 @@
+2020-01-16  Kai-Uwe Eckhardt  <kuehro@gmx.de>
+           Matthew Bauer  <mjbauer95@gmail.com>
+           Jonathan Wakely  <jwakely@redhat.com>
+
+       PR bootstrap/64271 (partial)
+       * config/os/bsd/netbsd/ctype_base.h (ctype_base::mask): Change type
+       to unsigned short.
+       (ctype_base::alpha, ctype_base::digit, ctype_base::xdigit)
+       (ctype_base::print, ctype_base::graph, ctype_base::alnum): Sync
+       definitions with NetBSD upstream.
+       (ctype_base::blank): Use _CTYPE_BL.
+       * config/os/bsd/netbsd/ctype_configure_char.cc (_C_ctype_): Remove
+       Declaration.
+       (ctype<char>::classic_table): Use _C_ctype_tab_ instead of _C_ctype_.
+       (ctype<char>::do_toupper, ctype<char>::do_tolower): Cast char
+       parameters to unsigned char.
+       * config/os/bsd/netbsd/ctype_inline.h (ctype<char>::is): Likewise.
+
 2020-01-16  François Dumont  <fdumont@gcc.gnu.org>
 
        PR libstdc++/91263
index 340bd8e3d4e75762d58aa4ff5dc6f1f38c0d3726..28bf232ba8399e4d0b03cde6e2e6727bb92c5364 100644 (file)
@@ -43,35 +43,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     // NB: Offsets into ctype<char>::_M_table force a particular size
     // on the mask type. Because of this, we don't use an enum.
-    typedef unsigned char              mask;
+    typedef unsigned short             mask;
 
-#ifndef _CTYPE_U
-    static const mask upper            = _U;
-    static const mask lower    = _L;
-    static const mask alpha    = _U | _L;
-    static const mask digit    = _N;
-    static const mask xdigit   = _N | _X;
-    static const mask space    = _S;
-    static const mask print    = _P | _U | _L | _N | _B;
-    static const mask graph    = _P | _U | _L | _N;
-    static const mask cntrl    = _C;
-    static const mask punct    = _P;
-    static const mask alnum    = _U | _L | _N;
-#else
-    static const mask upper            = _CTYPE_U;
-    static const mask lower    = _CTYPE_L;
-    static const mask alpha    = _CTYPE_U | _CTYPE_L;
-    static const mask digit    = _CTYPE_N;
-    static const mask xdigit   = _CTYPE_N | _CTYPE_X;
-    static const mask space    = _CTYPE_S;
-    static const mask print    = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N | _CTYPE_B;
-    static const mask graph    = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N;
-    static const mask cntrl    = _CTYPE_C;
-    static const mask punct    = _CTYPE_P;
-    static const mask alnum    = _CTYPE_U | _CTYPE_L | _CTYPE_N;
-#endif
+    static const mask upper    = _CTYPE_U;
+    static const mask lower    = _CTYPE_L;
+    static const mask alpha    = _CTYPE_A;
+    static const mask digit    = _CTYPE_D;
+    static const mask xdigit   = _CTYPE_X;
+    static const mask space    = _CTYPE_S;
+    static const mask print    = _CTYPE_R;
+    static const mask graph    = _CTYPE_G;
+    static const mask cntrl    = _CTYPE_C;
+    static const mask punct    = _CTYPE_P;
+    static const mask alnum    = _CTYPE_A | _CTYPE_D;
 #if __cplusplus >= 201103L
-    static const mask blank    = space;
+    static const mask blank    = _CTYPE_BL;
 #endif
   };
 
index 0680bb350c3f964e60c10cd670286a128048616d..86f7828517dca91765731dbcc2ad84909af4d2cb 100644 (file)
@@ -38,11 +38,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // Information as gleaned from /usr/include/ctype.h
 
-  extern "C" const u_int8_t _C_ctype_[];
-
   const ctype_base::mask*
   ctype<char>::classic_table() throw()
-  { return _C_ctype_ + 1; }
+  { return _C_ctype_tab_ + 1; }
 
   ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
                     size_t __refs)
@@ -69,14 +67,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   char
   ctype<char>::do_toupper(char __c) const
-  { return ::toupper((int) __c); }
+  { return ::toupper((int)(unsigned char) __c); }
 
   const char*
   ctype<char>::do_toupper(char* __low, const char* __high) const
   {
     while (__low < __high)
       {
-       *__low = ::toupper((int) *__low);
+       *__low = ::toupper((int)(unsigned char) *__low);
        ++__low;
       }
     return __high;
@@ -84,14 +82,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   char
   ctype<char>::do_tolower(char __c) const
-  { return ::tolower((int) __c); }
+  { return ::tolower((int)(unsigned char) __c); }
 
   const char*
   ctype<char>::do_tolower(char* __low, const char* __high) const
   {
     while (__low < __high)
       {
-       *__low = ::tolower((int) *__low);
+       *__low = ::tolower((int)(unsigned char) *__low);
        ++__low;
       }
     return __high;
index 6395433e1ac2dff69eb610dfd6d441d9f0caee49..4536690b6d869872d8d2d50ce3731ce66a08959b 100644 (file)
@@ -48,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   is(const char* __low, const char* __high, mask* __vec) const
   {
     while (__low < __high)
-      *__vec++ = _M_table[*__low++];
+      *__vec++ = _M_table[(unsigned char)*__low++];
     return __high;
   }