mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-30 07:14:09 +08:00
ctype_members.cc (ctype<wchar_t>::do_is): Fix.
2003-09-25 Benjamin Kosnik <bkoz@redhat.com> * config/locale/gnu/ctype_members.cc (ctype<wchar_t>::do_is): Fix. * config/locale/generic/ctype_members.cc: Same. * testsuite/22_locale/ctype/is/char/1.cc: Initialize mask. * testsuite/22_locale/ctype/is/wchar_t/1.cc: Same. * config/os/generic/ctype_inline.h: Update. From-SVN: r71780
This commit is contained in:
parent
6cbaf0385b
commit
465ad0c712
@ -1,3 +1,12 @@
|
||||
2003-09-25 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* config/locale/gnu/ctype_members.cc (ctype<wchar_t>::do_is): Fix.
|
||||
* config/locale/generic/ctype_members.cc: Same.
|
||||
* testsuite/22_locale/ctype/is/char/1.cc: Initialize mask.
|
||||
* testsuite/22_locale/ctype/is/wchar_t/1.cc: Same.
|
||||
|
||||
* config/os/generic/ctype_inline.h: Update.
|
||||
|
||||
2003-09-25 Ulrich Weigand <uweigand@de.ibm.com>
|
||||
|
||||
* src/Makefile.am (version_dep): New variable.
|
||||
|
@ -56,7 +56,7 @@ namespace std
|
||||
template<typename _Tv>
|
||||
int
|
||||
__convert_from_v(char* __out,
|
||||
const int __size __attribute__ ((__unused__)),
|
||||
const int __size __attribute__((__unused__)),
|
||||
const char* __fmt,
|
||||
_Tv __v, const __c_locale&, int __prec = -1)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
// std::ctype implementation details, generic version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003 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
|
||||
@ -126,15 +126,39 @@ namespace std
|
||||
bool
|
||||
ctype<wchar_t>::
|
||||
do_is(mask __m, char_type __c) const
|
||||
{ return static_cast<bool>(iswctype(__c, _M_convert_to_wmask(__m))); }
|
||||
{
|
||||
bool __ret = true;
|
||||
bool __match_any = false;
|
||||
const size_t __bitmasksize = 10;
|
||||
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
|
||||
{
|
||||
mask __bit = static_cast<mask>(1 << __bitcur);
|
||||
if (__m & __bit)
|
||||
{
|
||||
__match_any = true;
|
||||
__ret &= iswctype(__c, _M_convert_to_wmask(__bit));
|
||||
}
|
||||
}
|
||||
return __ret & __match_any;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
|
||||
{
|
||||
while (__lo < __hi && !this->do_is(*__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
for (;__lo < __hi; ++__vec, ++__lo)
|
||||
{
|
||||
const size_t __bitmasksize = 10;
|
||||
mask __m = 0;
|
||||
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
|
||||
{
|
||||
mask __bit = static_cast<mask>(1 << __bitcur);
|
||||
if (iswctype(*__lo, _M_convert_to_wmask(__bit)))
|
||||
__m |= __bit;
|
||||
}
|
||||
*__vec = __m;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
|
@ -1,6 +1,6 @@
|
||||
// std::ctype implementation details, GNU version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003 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
|
||||
@ -129,19 +129,46 @@ namespace std
|
||||
|
||||
bool
|
||||
ctype<wchar_t>::
|
||||
do_is(mask __m, char_type __c) const
|
||||
do_is(mask __m, wchar_t __c) const
|
||||
{
|
||||
return static_cast<bool>(__iswctype_l(__c, _M_convert_to_wmask(__m),
|
||||
_M_c_locale_ctype));
|
||||
// Highest bitmask in ctype_base == 10, but extra in "C"
|
||||
// library for blank.
|
||||
bool __ret = true;
|
||||
bool __match_any = false;
|
||||
const size_t __bitmasksize = 11;
|
||||
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
|
||||
{
|
||||
mask __bit = static_cast<mask>(_ISbit(__bitcur));
|
||||
if (__m & __bit)
|
||||
{
|
||||
__match_any = true;
|
||||
__ret &= __iswctype_l(__c, _M_convert_to_wmask(__bit),
|
||||
_M_c_locale_ctype);
|
||||
}
|
||||
}
|
||||
return __ret & __match_any;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
|
||||
{
|
||||
while (__lo < __hi && !this->do_is(*__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
for (;__lo < __hi; ++__vec, ++__lo)
|
||||
{
|
||||
// Highest bitmask in ctype_base == 10, but extra in "C"
|
||||
// library for blank.
|
||||
const size_t __bitmasksize = 11;
|
||||
mask __m = 0;
|
||||
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
|
||||
{
|
||||
mask __bit = static_cast<mask>(_ISbit(__bitcur));
|
||||
if (__iswctype_l(*__lo, _M_convert_to_wmask(__bit),
|
||||
_M_c_locale_ctype))
|
||||
__m |= __bit;
|
||||
}
|
||||
*__vec = __m;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
|
@ -50,13 +50,15 @@
|
||||
else
|
||||
{
|
||||
bool __ret = true;
|
||||
const int __bitmasksize = 11;
|
||||
int __bitcur = 0; // Lowest bitmask in ctype_base == 0
|
||||
for (;__ret && __bitcur < __bitmasksize; ++__bitcur)
|
||||
bool __any_match = false;
|
||||
const size_t __bitmasksize = 10;
|
||||
size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0
|
||||
for (;__ret && __bitcur <= __bitmasksize; ++__bitcur)
|
||||
{
|
||||
mask __bit = static_cast<mask>(1 << __bitcur);
|
||||
if (__m & __bit)
|
||||
{
|
||||
__any_match = true;
|
||||
bool __testis;
|
||||
switch (__bit)
|
||||
{
|
||||
@ -100,7 +102,7 @@
|
||||
__ret &= __testis;
|
||||
}
|
||||
}
|
||||
return __ret;
|
||||
return __ret & __any_match;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,13 +116,13 @@
|
||||
else
|
||||
{
|
||||
// Highest bitmask in ctype_base == 10.
|
||||
const int __bitmasksize = 11;
|
||||
const size_t __bitmasksize = 10;
|
||||
for (;__low < __high; ++__vec, ++__low)
|
||||
{
|
||||
mask __m = 0;
|
||||
// Lowest bitmask in ctype_base == 0
|
||||
int __i = 0;
|
||||
for (;__i < __bitmasksize; ++__i)
|
||||
size_t __i = 0;
|
||||
for (;__i <= __bitmasksize; ++__i)
|
||||
{
|
||||
mask __bit = static_cast<mask>(1 << __i);
|
||||
if (this->is(__bit, *__low))
|
||||
|
@ -97,9 +97,8 @@ void test01()
|
||||
const char_type* cc2 = NULL;
|
||||
|
||||
cc0 = strlit00;
|
||||
m01[0] = m00;
|
||||
m01[1] = m00;
|
||||
m01[2] = m00;
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
m01[i] = m00;
|
||||
cc1 = gctype.is(cc0, cc0, m01);
|
||||
VERIFY( cc1 == strlit00 );
|
||||
VERIFY( m01[0] == m00 );
|
||||
@ -107,9 +106,8 @@ void test01()
|
||||
VERIFY( m01[2] == m00 );
|
||||
|
||||
cc0 = strlit00;
|
||||
m01[0] = m00;
|
||||
m01[1] = m00;
|
||||
m01[2] = m00;
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
m01[i] = m00;
|
||||
cc2 = gctype.is(cc0, cc0 + 3, m01);
|
||||
VERIFY( cc2 == strlit00 + 3);
|
||||
VERIFY( m01[0] != m00 );
|
||||
@ -120,6 +118,8 @@ void test01()
|
||||
VERIFY( gctype.is(m01[2], cc0[2]) );
|
||||
|
||||
cc0 = strlit01;
|
||||
for (std::size_t i = 0; i < 13; ++i)
|
||||
m02[i] = m00;
|
||||
cc1 = gctype.is(cc0, cc0 + 13, m02);
|
||||
VERIFY( cc1 == strlit01 + 13);
|
||||
VERIFY( m02[6] != m00 );
|
||||
|
@ -94,30 +94,34 @@ void test01()
|
||||
std::ctype_base::mask m02[13];
|
||||
const char_type* cc0 = strlit00;
|
||||
const char_type* cc1 = NULL;
|
||||
const char_type* cc2 = NULL;
|
||||
|
||||
cc0 = strlit00;
|
||||
m01[0] = m00;
|
||||
m01[1] = m00;
|
||||
m01[2] = m00;
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
m01[i] = m00;
|
||||
cc1 = gctype.is(cc0, cc0, m01);
|
||||
VERIFY( cc1 == strlit00 );
|
||||
VERIFY( m01[0] == m00 );
|
||||
VERIFY( m01[1] == m00 );
|
||||
VERIFY( m01[2] == m00 );
|
||||
|
||||
#if 0
|
||||
cc0 = strlit00;
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
m01[i] = m00;
|
||||
cc2 = gctype.is(cc0, cc0 + 3, m01);
|
||||
VERIFY( cc2 == strlit00 + 3);
|
||||
VERIFY( m01[0] != m00 );
|
||||
VERIFY( m01[1] != m00 );
|
||||
VERIFY( m01[2] != m00 );
|
||||
VERIFY( gctype.is(m01[0], cc0[0]) );
|
||||
VERIFY( gctype.is(m01[1], cc0[1]) );
|
||||
VERIFY( gctype.is(m01[2], cc0[2]) );
|
||||
#endif
|
||||
|
||||
cc0 = strlit01;
|
||||
for (std::size_t i = 0; i < 13; ++i)
|
||||
m02[i] = m00;
|
||||
cc1 = gctype.is(cc0, cc0 + 13, m02);
|
||||
VERIFY( cc1 == strlit01 + 13);
|
||||
#if 0
|
||||
VERIFY( m02[6] != m00 );
|
||||
VERIFY( m02[7] != m00 );
|
||||
VERIFY( m02[8] != m00 );
|
||||
@ -131,7 +135,6 @@ void test01()
|
||||
VERIFY( gctype.is(m02[6], cc0[6]) );
|
||||
VERIFY( gctype.is(m02[7], cc0[7]) );
|
||||
VERIFY( gctype.is(m02[8], cc0[8]) );
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
|
Loading…
Reference in New Issue
Block a user