+2004-08-15 Paolo Carlini <pcarlini@suse.de>
+
+ * 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 <pcarlini@suse.de>
+
+ * include/bits/deque.tcc: Trivial formatting fixes.
+
2004-08-15 Paolo Carlini <pcarlini@suse.de>
* include/bits/deque.tcc: Trivial formatting fixes.
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(...)
{
{
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);
{
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;
{
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);
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;
test02();
return 0;
}
-
-
-
--- /dev/null
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+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;
+}
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
// 2001-05-24 Benjamin Kosnik <bkoz@redhat.com>
-// 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
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()
--- /dev/null
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+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;
+}
--- /dev/null
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+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<std::wstringbuf*>(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;
+}
--- /dev/null
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+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;
+}
--- /dev/null
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+// 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;
+}