[multiple changes]

2003-03-14  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/23_containers/bitset_members.cc: Add test variable.
	* testsuite/23_containers/map_insert.cc: Same.
	* testsuite/22_locale/ctype/cons/char/1.cc: Same.
	* testsuite/22_locale/codecvt/max_length/wchar_t/1.cc: Same.
	* testsuite/22_locale/codecvt/max_length/wchar_t/2.cc: Same.
	* testsuite/22_locale/codecvt/max_length/wchar_t/3.cc: Same.
	* testsuite/22_locale/codecvt/max_length/wchar_t/4.cc: Same.
	* testsuite/22_locale/codecvt/always_noconv/wchar_t/1.cc: Same.
	* testsuite/22_locale/codecvt/always_noconv/wchar_t/2.cc: Same.
	* testsuite/22_locale/codecvt/always_noconv/wchar_t/3.cc: Same.
	* testsuite/22_locale/codecvt/always_noconv/wchar_t/4.cc: Same.
	* testsuite/27_io/istream_exception.cc: Same.
	* testsuite/27_io/filebuf_virtuals.cc: Same.
	* testsuite/27_io/stringbuf_virtuals.cc: Same.
	* testsuite/27_io/ostream_inserter_arith.cc: Same.
	* testsuite/26_numerics/valarray_operators.cc: Same.
	* testsuite/26_numerics/slice.cc: Same.
	* testsuite/26_numerics/slice_array_assignment.cc: Same.
	* testsuite/24_iterators/istream_iterator.cc: Same.
	* mkcheck.in (TESTS_FILE): Use dejagnu-generated file if possible.

2003-03-14  Petur Runolfsson  <peturr02@ru.is>

	PR libstdc++/9581
	PR libstdc++/9870
	* config/locale/generic/ctype_members.cc,
	* config/locale/gnu/ctype_members.cc
	(ctype<wchar_t>::do_widen(char)):  Cast argument to
	unsigned char before passing to btowc.
	(ctype<wchar_t>::do_widen(const char*, const char*, wchar_t*)):
	Convert characters with btowc instead of mbsrtowcs.
	(ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*,
	char, char*):
	Convert characters with wctob instead of wcsrtombs.
	* testsuite/22_locale/ctype/narrow/wchar_t/3.cc:  New test.
	* testsuite/22_locale/ctype/widen/wchar_t/2.cc:  New test.
	* testsuite/22_locale/ctype/widen/wchar_t/3.cc:  New test.

From-SVN: r64391
This commit is contained in:
Benjamin Kosnik 2003-03-15 04:53:52 +00:00
parent d8eed979a3
commit ac1613a2c2
27 changed files with 265 additions and 46 deletions

View File

@ -1,3 +1,43 @@
2003-03-14 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/23_containers/bitset_members.cc: Add test variable.
* testsuite/23_containers/map_insert.cc: Same.
* testsuite/22_locale/ctype/cons/char/1.cc: Same.
* testsuite/22_locale/codecvt/max_length/wchar_t/1.cc: Same.
* testsuite/22_locale/codecvt/max_length/wchar_t/2.cc: Same.
* testsuite/22_locale/codecvt/max_length/wchar_t/3.cc: Same.
* testsuite/22_locale/codecvt/max_length/wchar_t/4.cc: Same.
* testsuite/22_locale/codecvt/always_noconv/wchar_t/1.cc: Same.
* testsuite/22_locale/codecvt/always_noconv/wchar_t/2.cc: Same.
* testsuite/22_locale/codecvt/always_noconv/wchar_t/3.cc: Same.
* testsuite/22_locale/codecvt/always_noconv/wchar_t/4.cc: Same.
* testsuite/27_io/istream_exception.cc: Same.
* testsuite/27_io/filebuf_virtuals.cc: Same.
* testsuite/27_io/stringbuf_virtuals.cc: Same.
* testsuite/27_io/ostream_inserter_arith.cc: Same.
* testsuite/26_numerics/valarray_operators.cc: Same.
* testsuite/26_numerics/slice.cc: Same.
* testsuite/26_numerics/slice_array_assignment.cc: Same.
* testsuite/24_iterators/istream_iterator.cc: Same.
* mkcheck.in (TESTS_FILE): Use dejagnu-generated file if possible.
2003-03-14 Petur Runolfsson <peturr02@ru.is>
PR libstdc++/9581
PR libstdc++/9870
* config/locale/generic/ctype_members.cc,
* config/locale/gnu/ctype_members.cc
(ctype<wchar_t>::do_widen(char)): Cast argument to
unsigned char before passing to btowc.
(ctype<wchar_t>::do_widen(const char*, const char*, wchar_t*)):
Convert characters with btowc instead of mbsrtowcs.
(ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*,
char, char*):
Convert characters with wctob instead of wcsrtombs.
* testsuite/22_locale/ctype/narrow/wchar_t/3.cc: New test.
* testsuite/22_locale/ctype/widen/wchar_t/2.cc: New test.
* testsuite/22_locale/ctype/widen/wchar_t/3.cc: New test.
2003-03-14 Benjamin Kosnik <bkoz@redhat.com>
* include/stdc++.h: New.

View File

@ -158,15 +158,18 @@ namespace std
wchar_t
ctype<wchar_t>::
do_widen(char __c) const
{ return btowc(__c); }
{ return btowc(static_cast<unsigned char>(__c)); }
const char*
ctype<wchar_t>::
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
{
mbstate_t __state;
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
mbsrtowcs(__dest, &__lo, __hi - __lo, &__state);
while (__lo < __hi)
{
*__dest = btowc(static_cast<unsigned char>(*__lo));
++__lo;
++__dest;
}
return __hi;
}
@ -183,22 +186,12 @@ namespace std
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
char* __dest) const
{
size_t __offset = 0;
while (true)
while (__lo < __hi)
{
const wchar_t* __start = __lo + __offset;
size_t __len = __hi - __start;
mbstate_t __state;
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
size_t __con = wcsrtombs(__dest + __offset, &__start, __len, &__state);
if (__con != __len && __start != 0)
{
__offset = __start - __lo;
__dest[__offset++] = __dfault;
}
else
break;
int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++__lo;
++__dest;
}
return __hi;
}

View File

@ -169,7 +169,7 @@ namespace std
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_ctype);
#endif
wchar_t __ret = btowc(__c);
wchar_t __ret = btowc(static_cast<unsigned char>(__c));
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
@ -183,9 +183,12 @@ namespace std
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_ctype);
#endif
mbstate_t __state;
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
mbsrtowcs(__dest, &__lo, __hi - __lo, &__state);
while (__lo < __hi)
{
*__dest = btowc(static_cast<unsigned char>(*__lo));
++__lo;
++__dest;
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
@ -214,22 +217,12 @@ namespace std
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_ctype);
#endif
size_t __offset = 0;
while (true)
while (__lo < __hi)
{
const wchar_t* __start = __lo + __offset;
size_t __len = __hi - __start;
mbstate_t __state;
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
size_t __con = wcsrtombs(__dest + __offset, &__start, __len, &__state);
if (__con != __len && __start != 0)
{
__offset = __start - __lo;
__dest[__offset++] = __dfault;
}
else
break;
int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++__lo;
++__dest;
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);

View File

@ -99,6 +99,9 @@ fi
# Make a list of the files we're going to run, or use an old one if it exists.
if [ ! -f "$TESTS_FILE" ]; then
if [ -f "$TEST_DIR/testsuite_files" ]; then
cp $TEST_DIR/testsuite_files $TESTS_FILE
else
echo "making file $TESTS_FILE"
for LONG_NAME in $SRC_DIR/testsuite/*/*.cc
do
@ -106,6 +109,7 @@ if [ ! -f "$TESTS_FILE" ]; then
SHORT_NAME="`basename $DIR_NAME`/`basename $LONG_NAME`"
echo "$SHORT_NAME" >> $TESTS_FILE
done
fi
fi
# Nasty solution to replace GNU date(1)'s %s time_t output function.

View File

@ -28,6 +28,7 @@
void test01()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc;

View File

@ -30,6 +30,7 @@
void test02()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc ("en_US.ISO-8859-1");

View File

@ -30,6 +30,7 @@
void test03()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc ("en_US.ISO-8859-15");

View File

@ -30,6 +30,7 @@
void test04()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc ("en_US.UTF-8");

View File

@ -28,6 +28,7 @@
void test01()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc_c = locale::classic();

View File

@ -28,6 +28,7 @@
void test02()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc ("en_US.ISO-8859-1");

View File

@ -28,6 +28,7 @@
void test03()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc ("en_US.ISO-8859-15");

View File

@ -28,6 +28,7 @@
void test04()
{
using namespace std;
bool test = true;
typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;
locale loc ("en_US.UTF-8");

View File

@ -51,7 +51,8 @@ public:
void test01()
{
using namespace std;
bool test = true;
comma_ctype obj;
const ctype_base::mask* tmp = obj.get_classic_table();

View File

@ -0,0 +1,56 @@
// 2003-03-12 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 22.2.1.3.2 ctype<wchar_t> members
#include <locale>
#include <testsuite_hooks.h>
// libstdc++/9581
void test03()
{
using namespace std;
bool test = true;
locale loc ("se_NO.UTF-8");
const ctype<wchar_t>& wct = use_facet<ctype<wchar_t> >(loc);
const wchar_t* wstrlit = L"\x80";
char buf[2];
wct.narrow(wstrlit, wstrlit + 2, ' ', buf);
VERIFY( buf[0] == wct.narrow(wstrlit[0], ' ') );
VERIFY( buf[1] == wct.narrow(wstrlit[1], ' ') );
}
int main()
{
test03();
return 0;
}

View File

@ -0,0 +1,54 @@
// 2003-03-12 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 22.2.1.3.2 ctype<wchar_t> members
#include <locale>
#include <testsuite_hooks.h>
// libstdc++/9870
void test02()
{
using namespace std;
bool test = true;
locale loc ("en_US.ISO-8859-1");
const ctype<wchar_t>& wct = use_facet<ctype<wchar_t> >(loc);
char c = 0xff;
wchar_t wc = wct.widen(c);
VERIFY( wc == static_cast<wchar_t>(0xff) );
}
int main()
{
test02();
return 0;
}

View File

@ -0,0 +1,57 @@
// 2003-03-12 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 22.2.1.3.2 ctype<wchar_t> members
#include <locale>
#include <testsuite_hooks.h>
// libstdc++/9581
void test03()
{
using namespace std;
bool test = true;
locale loc ("se_NO.UTF-8");
const ctype<wchar_t>& wct = use_facet<ctype<wchar_t> >(loc);
const char* strlit = "\xc2\x80";
wchar_t wbuf[3];
wct.widen(strlit, strlit + 3, wbuf);
VERIFY( wbuf[0] == wct.widen(strlit[0]) );
VERIFY( wbuf[1] == wct.widen(strlit[1]) );
VERIFY( wbuf[2] == wct.widen(strlit[2]) );
}
int main()
{
test03();
return 0;
}

View File

@ -1,6 +1,6 @@
// 2001-06-03 pme
// 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
@ -55,6 +55,7 @@ void test02()
void test03()
{
bool test = true;
std::bitset<5> b;
std::stringstream ss ("101");

View File

@ -1,6 +1,6 @@
// 2001-08-23 pme & Sylvain.Pion@sophia.inria.fr
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 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
@ -29,6 +29,7 @@
// http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01375.html
void test01()
{
bool test = true;
typedef std::map<int, int> Map;
Map M;
Map::iterator hint;

View File

@ -1,6 +1,6 @@
// 2002-03-05 Stephen M. Webb <stephen.webb@bregmasoft.com>
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 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
@ -32,6 +32,7 @@ void test01()
// libstdc++/6886
void test02()
{
bool test = true;
typedef std::vector<bool> bvec;
int i, num = 0;
bvec v;

View File

@ -1,6 +1,6 @@
// 2001-06-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 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
@ -53,6 +53,7 @@ template class std::istream_iterator<char>;
void test02()
{
using namespace std;
bool test = true;
string st("R.Rorty");

View File

@ -1,6 +1,6 @@
// 20020717 gdr
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 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
@ -51,6 +51,7 @@ assignment(int start, int size, int stride)
int main()
{
bool test = true;
std::srand(20020717); using std::rand;
VERIFY(construction(rand(), rand(), rand()));

View File

@ -1,6 +1,6 @@
// 20010613 gdr
// 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
@ -34,6 +34,7 @@
int main()
{
bool test = true;
using std::valarray;
using std::slice;
valarray<int> v(1, 10), w(2, 10);

View File

@ -24,6 +24,7 @@
void test01() // check unary operators
{
bool test = true;
std::valarray<int> u(1);
u[0]=1;
@ -35,6 +36,7 @@ void test01() // check unary operators
void test02() // check binary operators
{
bool test = true;
std::valarray<int> u(1), v(1);
u[0]=1;
v[0]=3;

View File

@ -546,6 +546,7 @@ class MyTraits : public std::char_traits<char>
public:
static bool eq(char c1, char c2)
{
bool test = true;
VERIFY( c1 != 'X' );
VERIFY( c2 != 'X' );
return std::char_traits<char>::eq(c1, c2);

View File

@ -40,6 +40,7 @@ struct buf: std::streambuf
void test01()
{
using namespace std;
bool test = true;
buf b;
std::istream strm (&b);

View File

@ -1,7 +1,7 @@
// 1999-11-15 Kevin Ediger <kediger@licor.com>
// test the floating point inserters (facet num_put)
// Copyright (C) 1999, 2002 Free Software Foundation, Inc.
// Copyright (C) 1999, 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
@ -360,6 +360,7 @@ test04()
int
test05()
{
bool test = true;
double pi = 3.14159265358979323846;
ostringstream ostr;
ostr.precision(20);
@ -377,6 +378,7 @@ test05()
int
test06()
{
bool test = true;
int prec = numeric_limits<double>::digits10 + 2;
double oval = numeric_limits<double>::min();

View File

@ -40,6 +40,7 @@ void test01()
void test02(std::stringbuf& in, bool pass)
{
bool test = true;
using namespace std;
typedef streambuf::pos_type pos_type;
typedef streambuf::off_type off_type;