From: Paolo Carlini Date: Sun, 15 Aug 2004 23:08:58 +0000 (+0000) Subject: 2832.cc: Remove junk. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba43cf0b4fb7373a29d486d1507bc852028bf519;p=gcc.git 2832.cc: Remove junk. 2004-08-15 Paolo Carlini * testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc: Remove junk. * testsuite/27_io/basic_stringstream/str/char/1.cc: Likewise. * testsuite/27_io/basic_stringstream/str/char/3.cc: Likewise. * testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc: New. * testsuite/27_io/basic_stringstream/str/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringstream/str/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_stringstream/str/wchar_t/3.cc: Likewise. * testsuite/27_io/basic_stringstream/str/wchar_t/4.cc: Likewise. 2004-08-15 Paolo Carlini * include/bits/deque.tcc: Trivial formatting fixes. From-SVN: r86040 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e5b5d659e94..58c0aa9dbd9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2004-08-15 Paolo Carlini + + * testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc: Remove junk. + * testsuite/27_io/basic_stringstream/str/char/1.cc: Likewise. + * testsuite/27_io/basic_stringstream/str/char/3.cc: Likewise. + + * testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc: New. + * testsuite/27_io/basic_stringstream/str/wchar_t/1.cc: Likewise. + * testsuite/27_io/basic_stringstream/str/wchar_t/2.cc: Likewise. + * testsuite/27_io/basic_stringstream/str/wchar_t/3.cc: Likewise. + * testsuite/27_io/basic_stringstream/str/wchar_t/4.cc: Likewise. + +2004-08-15 Paolo Carlini + + * include/bits/deque.tcc: Trivial formatting fixes. + 2004-08-15 Paolo Carlini * include/bits/deque.tcc: Trivial formatting fixes. diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index 3fbde412ef6..0c57bd53a11 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -268,12 +268,11 @@ namespace _GLIBCXX_STD for (__cur = this->_M_impl._M_start._M_node; __cur < this->_M_impl._M_finish._M_node; ++__cur) - std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(), __value, - this->get_allocator()); + std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(), + __value, this->get_allocator()); std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first, this->_M_impl._M_finish._M_cur, - __value, - this->get_allocator()); + __value, this->get_allocator()); } catch(...) { @@ -519,8 +518,8 @@ namespace _GLIBCXX_STD { iterator __start_n = (this->_M_impl._M_start + difference_type(__n)); - std::__uninitialized_copy_a(this->_M_impl._M_start, __start_n, - __new_start, + std::__uninitialized_copy_a(this->_M_impl._M_start, + __start_n, __new_start, this->get_allocator()); this->_M_impl._M_start = __new_start; std::copy(__start_n, __pos, __old_start); @@ -557,7 +556,8 @@ namespace _GLIBCXX_STD { iterator __finish_n = (this->_M_impl._M_finish - difference_type(__n)); - std::__uninitialized_copy_a(__finish_n, this->_M_impl._M_finish, + std::__uninitialized_copy_a(__finish_n, + this->_M_impl._M_finish, this->_M_impl._M_finish, this->get_allocator()); this->_M_impl._M_finish = __new_finish; @@ -605,8 +605,8 @@ namespace _GLIBCXX_STD { iterator __start_n = (this->_M_impl._M_start + difference_type(__n)); - std::__uninitialized_copy_a(this->_M_impl._M_start, __start_n, - __new_start, + std::__uninitialized_copy_a(this->_M_impl._M_start, + __start_n, __new_start, this->get_allocator()); this->_M_impl._M_start = __new_start; std::copy(__start_n, __pos, __old_start); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc index 9a0b6685560..7ea26bc4ce5 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc @@ -35,10 +35,6 @@ active_buffer(std::ios& stream) void test02() { bool test __attribute__((unused)) = true; - const char* strlit01 = "fuck war"; - const std::string str00; - const std::string str01(strlit01); - std::string str02; std::stringbuf sbuf; std::streambuf* pbasebuf0 = &sbuf; @@ -64,6 +60,3 @@ int main() test02(); return 0; } - - - diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc new file mode 100644 index 00000000000..74b3cb2c879 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2004 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. + +// 27.7.6 - Member functions [lib.stringstream.members] + +#include +#include + +void +redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) +{ stream.rdbuf(new_buf); } + +std::wstreambuf* +active_buffer(std::wios& stream) +{ return stream.rdbuf(); } + +// libstdc++/2832 +void test02() +{ + bool test __attribute__((unused)) = true; + std::wstringbuf sbuf; + std::wstreambuf* pbasebuf0 = &sbuf; + + std::wstringstream sstrm1; + // derived rdbuf() always returns original streambuf, even though + // it's no longer associated with the stream. + std::wstringbuf* const buf1 = sstrm1.rdbuf(); + // base rdbuf() returns the currently associated streambuf + std::wstreambuf* pbasebuf1 = active_buffer(sstrm1); + redirect_buffer(sstrm1, &sbuf); + std::wstringbuf* const buf2 = sstrm1.rdbuf(); + std::wstreambuf* pbasebuf2 = active_buffer(sstrm1); + VERIFY( buf1 == buf2 ); + VERIFY( pbasebuf1 != pbasebuf2 ); + VERIFY( pbasebuf2 == pbasebuf0 ); + + // How confusing and non-intuitive is this? + // These semantics are a joke, a serious defect, and incredibly lame. +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc index 00bfb89c85f..9ad1f3d230f 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc @@ -33,8 +33,7 @@ void test01() const int i01 = 123; int a,b; - std::ios_base::iostate state1, state2, statefail, stateeof; - statefail = std::ios_base::failbit; + std::ios_base::iostate state1, state2, stateeof; stateeof = std::ios_base::eofbit; // string str() const diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc index 2d24f6b7922..71371d3a9bb 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc @@ -1,6 +1,6 @@ // 2001-05-24 Benjamin Kosnik -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -40,22 +40,16 @@ test03() std::ostringstream ostrst02(blank); // No buffer, so should be created. - ostrst01 << "i: " << i << " i's address: " << pi << "\n" + ostrst01 << "i: " << i << " i's address: " << pi << '\n' << "d: " << d << " d's address: " << pd << std::endl; // Buffer, so existing buffer should be overwritten. - ostrst02 << "i: " << i << " i's address: " << pi << "\n" + ostrst02 << "i: " << i << " i's address: " << pi << '\n' << "d: " << d << " d's address: " << pd << std::endl; std::string msg01 = ostrst01.str(); std::string msg02 = ostrst02.str(); VERIFY( msg01 == msg02 ); VERIFY( msg02 != blank ); - - // stringstream - std::string str1(""); - std::string str3("this is a somewhat string"); - std::stringstream ss1(str1, std::ios_base::in|std::ios_base::out); - std::stringstream ss2(str3, std::ios_base::in|std::ios_base::out); } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc new file mode 100644 index 00000000000..5534a9a783f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2004 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. + +// 27.7.6 member functions (stringstream_members) + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + std::wstringstream is01; + const std::wstring str00; + const std::wstring str01 = L"123"; + std::wstring str02; + const int i01 = 123; + int a,b; + + std::ios_base::iostate state1, state2, stateeof; + stateeof = std::ios_base::eofbit; + + // string str() const + str02 = is01.str(); + VERIFY( str00 == str02 ); + + // void str(const basic_string&) + is01.str(str01); + str02 = is01.str(); + VERIFY( str01 == str02 ); + state1 = is01.rdstate(); + is01 >> a; + state2 = is01.rdstate(); + VERIFY( a == i01 ); + // 22.2.2.1.2 num_get virtual functions + // p 13 + // in any case, if stage 2 processing was terminated by the test for + // in == end then err != ios_base::eofbit is performed. + VERIFY( state1 != state2 ); + VERIFY( state2 == stateeof ); + + is01.str(str01); + is01 >> b; + VERIFY( b != a ); + // as is01.good() is false, istream::sentry blocks extraction. + + is01.clear(); + state1 = is01.rdstate(); + is01 >> b; + state2 = is01.rdstate(); + VERIFY( b == a ); + VERIFY( state1 != state2 ); + VERIFY( state2 == stateeof ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc new file mode 100644 index 00000000000..32ed0e3d66a --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2004 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. + +// 27.7.6 member functions (stringstream_members) + +#include +#include + +void +redirect_buffer(std::wios& stream, std::wstreambuf* new_buf) +{ stream.rdbuf(new_buf); } + +std::wstreambuf* +active_buffer(std::wios& stream) +{ return stream.rdbuf(); } + +// libstdc++/2832 +void test02() +{ + bool test __attribute__((unused)) = true; + const wchar_t* strlit01 = L"fuck war"; + const std::wstring str00; + const std::wstring str01(strlit01); + std::wstring str02; + std::wstringbuf sbuf(str01); + std::wstreambuf* pbasebuf0 = &sbuf; + + std::wstringstream sstrm1; + VERIFY( sstrm1.str() == str00 ); + // derived rdbuf() always returns original streambuf, even though + // it's no longer associated with the stream. + std::wstringbuf* const buf1 = sstrm1.rdbuf(); + // base rdbuf() returns the currently associated streambuf + std::wstreambuf* pbasebuf1 = active_buffer(sstrm1); + redirect_buffer(sstrm1, &sbuf); + std::wstringbuf* const buf2 = sstrm1.rdbuf(); + std::wstreambuf* pbasebuf2 = active_buffer(sstrm1); + VERIFY( buf1 == buf2 ); + VERIFY( pbasebuf1 != pbasebuf2 ); + VERIFY( pbasebuf2 == pbasebuf0 ); + + // derived rdbuf() returns the original buf, so str() doesn't change. + VERIFY( sstrm1.str() != str01 ); + VERIFY( sstrm1.str() == str00 ); + // however, casting the active streambuf to a stringbuf shows what's up: + std::wstringbuf* psbuf = dynamic_cast(pbasebuf2); + str02 = psbuf->str(); + VERIFY( str02 == str01 ); + + // How confusing and non-intuitive is this? + // These semantics are a joke, a serious defect, and incredibly lame. +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc new file mode 100644 index 00000000000..664a65ef6d2 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2004 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. + +// 27.7.6 member functions (stringstream_members) + +#include +#include + +void +test03() +{ + bool test __attribute__((unused)) = true; + + // + // 1: Automatic formatting of a compound string + // + int i = 1024; + int *pi = &i; + double d = 3.14159; + double *pd = &d; + std::wstring blank; + std::wostringstream ostrst01; + std::wostringstream ostrst02(blank); + + // No buffer, so should be created. + ostrst01 << L"i: " << i << L" i's address: " << pi << L'\n' + << L"d: " << d << L" d's address: " << pd << std::endl; + // Buffer, so existing buffer should be overwritten. + ostrst02 << L"i: " << i << L" i's address: " << pi << L'\n' + << L"d: " << d << L" d's address: " << pd << std::endl; + + std::wstring msg01 = ostrst01.str(); + std::wstring msg02 = ostrst02.str(); + VERIFY( msg01 == msg02 ); + VERIFY( msg02 != blank ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.cc new file mode 100644 index 00000000000..8c2cffc2ddb --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2004 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. + +// 27.7.6 member functions (stringstream_members) + +#include +#include + +// libstdc++/8466 +void test04() +{ + bool test __attribute__((unused)) = true; + + const wchar_t* strlit00 = L"orvieto"; + const std::wstring str00 = strlit00; + + std::wostringstream oss; + + oss.str(str00); + oss << L"cortona"; + VERIFY( str00 == strlit00 ); +} + +int main() +{ + test04(); + return 0; +}