From: Benjamin Kosnik Date: Tue, 19 Dec 2000 19:49:00 +0000 (+0000) Subject: ctype_inline.h (is): Same. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=62f4333a68e86e13c02d9436a71bb7367ffcaea8;p=gcc.git ctype_inline.h (is): Same. 2000-12-19 Benjamin Kosnik * config/os/solaris/solaris2.5/bits/ctype_inline.h (is): Same. * config/os/solaris/solaris2.6/bits/ctype_inline.h (is): Same. * config/os/solaris/solaris2.7/bits/ctype_inline.h (is): Same. * config/os/newlib/bits/ctype_inline.h (is): Same. * config/os/irix/bits/ctype_inline.h (is): Same. * config/os/bsd/netbsd/bits/ctype_inline.h (is): Same. * config/os/bsd/freebsd/bits/ctype_inline.h (is): Same. * config/os/aix/bits/ctype_inline.h (is): Same. * config/os/gnu-linux/bits/ctype_inline.h (is): Revert. * config/os/generic/bits/ctype_inline.h (is): Non-table based implementation. * testsuite/22_locale/ctype_char_members.cc (test01): Use binary operator correctly. (test01): Check 'A' for alnum, upper, alpha. From-SVN: r38385 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d5692fc6497..b440b9e8067 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,21 @@ +2000-12-19 Benjamin Kosnik + + * config/os/solaris/solaris2.5/bits/ctype_inline.h (is): Same. + * config/os/solaris/solaris2.6/bits/ctype_inline.h (is): Same. + * config/os/solaris/solaris2.7/bits/ctype_inline.h (is): Same. + * config/os/newlib/bits/ctype_inline.h (is): Same. + * config/os/irix/bits/ctype_inline.h (is): Same. + * config/os/bsd/netbsd/bits/ctype_inline.h (is): Same. + * config/os/bsd/freebsd/bits/ctype_inline.h (is): Same. + * config/os/aix/bits/ctype_inline.h (is): Same. + * config/os/gnu-linux/bits/ctype_inline.h (is): Revert. + * config/os/generic/bits/ctype_inline.h (is): Non-table based + implementation. + + * testsuite/22_locale/ctype_char_members.cc (test01): Use binary + operator correctly. + (test01): Check 'A' for alnum, upper, alpha. + 2000-12-19 Gabriel Dos Reis * include/bits/std_complex.h (complex::operator-=): Fix diff --git a/libstdc++-v3/config/os/aix/bits/ctype_inline.h b/libstdc++-v3/config/os/aix/bits/ctype_inline.h index 16e011c4a9a..d9df620b010 100644 --- a/libstdc++-v3/config/os/aix/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/aix/bits/ctype_inline.h @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = __OBJ_DATA(__lc_ctype)->mask[*__low++]; - int __i = 0; // Lowest bitmask. - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = __OBJ_DATA(__lc_ctype)->mask[*__low++]; return __high; } diff --git a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h index b51867dcac2..c282c4bf158 100644 --- a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h @@ -48,14 +48,18 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; + const int __bitmasksize = 11; // Highest bitmask in ctype_base == 10 for (;__low < __high; ++__vec, ++__low) { - mask __m = _M_table[*__low]; - int __i = 0; // Lowest bitmask value, 1 == 1 << 0 means 0 - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); + mask __m = 0; + int __i = 0; // Lowest bitmask in ctype_base == 0 + for (;__i < __bitmasksize; ++__i) + { + mask __bit = static_cast(1 << __i); + if (this->is(__bit, *__low)) + __m |= __bit; + } + *__vec = __m; } return __high; } diff --git a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h index 2d72d9896cf..f6dfc4d7f65 100644 --- a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = _M_table[*__low]; - int __i = 0; // Lowest bitmask. - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = _M_table[*__low++]; return __high; } diff --git a/libstdc++-v3/config/os/generic/bits/ctype_inline.h b/libstdc++-v3/config/os/generic/bits/ctype_inline.h index 98c7e3d0309..a5f6e855a93 100644 --- a/libstdc++-v3/config/os/generic/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/generic/bits/ctype_inline.h @@ -93,11 +93,15 @@ const int __bitmasksize = 11; // Highest bitmask in ctype_base == 10 for (;__low < __high; ++__vec, ++__low) { - mask __m = _M_table[*__low]; + mask __m = 0; int __i = 0; // Lowest bitmask in ctype_base == 0 - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); + for (;__i < __bitmasksize; ++__i) + { + mask __bit = static_cast(1 << __i); + if (this->is(__bit, *__low)) + __m |= __bit; + } + *__vec = __m; } return __high; } 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 83563a9ade7..4c248242625 100644 --- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = _M_table[*__low]; - int __i = 1; // Lowest bitmask on linux, 1 <= x <= 15 - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = _M_table[*__low++]; return __high; } diff --git a/libstdc++-v3/config/os/irix/bits/ctype_inline.h b/libstdc++-v3/config/os/irix/bits/ctype_inline.h index 1b400f24183..6a20c096cd5 100644 --- a/libstdc++-v3/config/os/irix/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/irix/bits/ctype_inline.h @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = _M_table[*__low]; - int __i = 1; // Lowest bitmask on linux, 1 <= x <= 15 - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = (_M_table)[*__low++]; return __high; } diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_inline.h b/libstdc++-v3/config/os/newlib/bits/ctype_inline.h index 61c4bc85898..cddffedaa44 100644 --- a/libstdc++-v3/config/os/newlib/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/newlib/bits/ctype_inline.h @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = _M_table[*__low]; - int __i = 0; // Lowest bitmask with newlib, 1 << 0 == 01 - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = (_M_table + 1)[(unsigned char) (*__low++)]; return __high; } 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 f6719935af0..affa4945c60 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 @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = _M_table[*__low]; - int __i = 0; // Lowest bitmask in ctype_base::mask. - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = (_M_table + 1)[(unsigned char) (*__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 f254e839fb8..8ec057dfb47 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 @@ -43,15 +43,8 @@ ctype:: is(const char* __low, const char* __high, mask* __vec) const { - const int __bitmasksize = sizeof(mask) * 8; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = _M_table[*__low]; - int __i = 0; // Lowest bitmask value from ctype_base. - while (__i < __bitmasksize && !(__m & static_cast(1 << __i))) - ++__i; - *__vec = static_cast(1 << __i); - } + while (__low < __high) + *__vec++ = _M_table[*__low++]; return __high; } diff --git a/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc b/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc index d1a7783cfb5..93eedd171ce 100644 --- a/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc +++ b/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc @@ -69,8 +69,17 @@ void test01() int i10 = std::ctype_base::print; int i11 = std::ctype_base::cntrl; int i12 = sizeof(std::ctype_base::mask); - VERIFY ( i01 != i02 != i03 != i04 != i05 != i06 != i07 != i08 != i09 ); - VERIFY ( i01 != i10 != i11); + VERIFY ( i01 != i02); + VERIFY ( i02 != i03); + VERIFY ( i03 != i04); + VERIFY ( i04 != i05); + VERIFY ( i05 != i06); + VERIFY ( i06 != i07); + VERIFY ( i07 != i08); + VERIFY ( i08 != i09); + VERIFY ( i09 != i10); + VERIFY ( i10 != i11); + VERIFY ( i11 != i01); // bool is(mask m, char c) const; VERIFY( gctype.is(std::ctype_base::space, c30) ); @@ -118,14 +127,17 @@ void test01() VERIFY( gctype.is(m01[1], cc0[1]) ); VERIFY( gctype.is(m01[2], cc0[2]) ); - cc0 = strlit00; + cc0 = strlit01; cc1 = gctype.is(cc0, cc0 + 13, m02); - VERIFY( cc1 == strlit00 + 13); + VERIFY( cc1 == strlit01 + 13); VERIFY( m02[6] != m00 ); VERIFY( m02[7] != m00 ); VERIFY( m02[8] != m00 ); - VERIFY( m02[8] != m02[6] != m02[7] ); + VERIFY( m02[8] != m02[6] ); + VERIFY( m02[6] != m02[7] ); VERIFY( static_cast(m02[6] & std::ctype_base::alnum) ); + VERIFY( static_cast(m02[6] & std::ctype_base::upper) ); + VERIFY( static_cast(m02[6] & std::ctype_base::alpha) ); VERIFY( static_cast(m02[7] & std::ctype_base::punct) ); VERIFY( static_cast(m02[8] & std::ctype_base::space) ); VERIFY( gctype.is(m02[6], cc0[6]) );