+2004-08-12 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/16956
+ * include/bits/sstream.tcc (basic_stringbuf<>::seekoff): Add __off
+ to the returned value, reorganize a bit.
+ * testsuite/27_io/basic_stringbuf/seekoff/char/16956.cc: New.
+ * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc: New.
+
+ * testsuite/27_io/basic_stringbuf/seekoff/char/1.cc: Remove junk.
+ * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/seekpos/char/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/seekpos/wchar_t/1.cc: Likewise.
+
2004-08-12 Paul Brook <paul@codesourcery.com>
* config/cpu/arm/cxxabi_tweaks.h: Define __cxa_vec_ctor_return and
// String based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2004
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
_M_update_egptr();
- off_type __newoffi = 0;
- off_type __newoffo = 0;
+ off_type __newoffi = __off;
+ off_type __newoffo = __newoffi;
if (__way == ios_base::cur)
{
- __newoffi = this->gptr() - __beg;
- __newoffo = this->pptr() - __beg;
+ __newoffi += this->gptr() - __beg;
+ __newoffo += this->pptr() - __beg;
}
else if (__way == ios_base::end)
- __newoffo = __newoffi = this->egptr() - __beg;
+ __newoffo = __newoffi += this->egptr() - __beg;
if ((__testin || __testboth)
- && __newoffi + __off >= 0
- && this->egptr() - __beg >= __newoffi + __off)
+ && __newoffi >= 0
+ && this->egptr() - __beg >= __newoffi)
{
- this->gbump((__beg + __newoffi + __off) - this->gptr());
+ this->gbump((__beg + __newoffi) - this->gptr());
__ret = pos_type(__newoffi);
}
if ((__testout || __testboth)
- && __newoffo + __off >= 0
- && this->egptr() - __beg >= __newoffo + __off)
+ && __newoffo >= 0
+ && this->egptr() - __beg >= __newoffo)
{
- this->pbump((__beg + __newoffo + __off) - this->pptr());
+ this->pbump((__beg + __newoffo) - this->pptr());
__ret = pos_type(__newoffo);
}
}
// 981208 bkoz test functionality of basic_stringbuf for char_type == char
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
#include <testsuite_hooks.h>
std::string str_01("mykonos. . . or what?");
-std::string str_02("paris, or sainte-maxime?");
-std::string str_03;
std::stringbuf strb_01(str_01);
-std::stringbuf strb_02(str_02, std::ios_base::in);
-std::stringbuf strb_03(str_03, std::ios_base::out);
// test overloaded virtual functions
void test04()
{
bool test __attribute__((unused)) = true;
std::string str_tmp;
- std::stringbuf strb_tmp;
std::streamsize strmsz_1, strmsz_2;
typedef std::stringbuf::int_type int_type;
typedef std::stringbuf::traits_type traits_type;
typedef std::stringbuf::off_type off_type;
int_type c1 = strb_01.sbumpc();
- int_type c2 = strb_02.sbumpc();
- int_type c3 = strb_01.sbumpc();
+ int_type c2, c3;
- // PUT
- strb_03.str(str_01); //reset
-
// BUFFER MANAGEMENT & POSITIONING
// seekoff
off_type off_1 = 0;
off_type off_2 = 0;
strb_01.str(str_01); //in|out ("mykonos. . . or what?");
- strb_02.str(str_02); //in ("paris, or sainte-maxime?");
- strb_03.str(str_03); //out ("")
+
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
--- /dev/null
+// 2004-08-12 Paolo Carlini <pcarlini@suse.de>
+
+// 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.1.3 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/16956
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ typedef stringbuf::int_type int_type;
+ typedef stringbuf::traits_type traits_type;
+ typedef stringbuf::pos_type pos_type;
+ typedef stringbuf::off_type off_type;
+
+ stringbuf strb_01("lara's place", ios_base::in);
+ pos_type pt_1 = strb_01.pubseekoff(5, ios_base::cur, ios_base::in);
+ int_type c1 = strb_01.sgetc();
+ VERIFY( c1 != traits_type::eof() );
+ pos_type pt_2 = strb_01.pubseekoff(2, ios_base::cur, ios_base::in);
+ pos_type pt_3 = strb_01.pubseekpos(pt_1, ios_base::in);
+ int_type c2 = strb_01.sbumpc();
+ VERIFY( off_type(pt_3) == off_type(pt_2) - 2 );
+ VERIFY( c2 == c1 );
+
+ stringbuf strb_02("-", ios_base::out);
+ pos_type pt_4 = strb_02.pubseekoff(0, ios_base::cur, ios_base::out);
+ strb_02.sputn("red", 3);
+ pos_type pt_5 = strb_02.pubseekoff(-3, ios_base::cur, ios_base::out);
+ strb_02.pubseekpos(pt_5, ios_base::out);
+ VERIFY( off_type(pt_5) == off_type(pt_4) );
+ strb_02.sputn("blu", 3);
+ VERIFY( strb_02.str() == "blu" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
#include <testsuite_hooks.h>
std::wstring str_01(L"mykonos. . . or what?");
-std::wstring str_02(L"paris, or sainte-maxime?");
-std::wstring str_03;
std::wstringbuf strb_01(str_01);
-std::wstringbuf strb_02(str_02, std::ios_base::in);
-std::wstringbuf strb_03(str_03, std::ios_base::out);
// test overloaded virtual functions
void test04()
{
bool test __attribute__((unused)) = true;
std::wstring str_tmp;
- std::wstringbuf strb_tmp;
std::streamsize strmsz_1, strmsz_2;
typedef std::wstringbuf::int_type int_type;
typedef std::wstringbuf::traits_type traits_type;
typedef std::wstringbuf::off_type off_type;
int_type c1 = strb_01.sbumpc();
- int_type c2 = strb_02.sbumpc();
- int_type c3 = strb_01.sbumpc();
-
- // PUT
- strb_03.str(str_01); //reset
+ int_type c2, c3;
// BUFFER MANAGEMENT & POSITIONING
off_type off_1 = 0;
off_type off_2 = 0;
strb_01.str(str_01); //in|out ("mykonos. . . or what?");
- strb_02.str(str_02); //in ("paris, or sainte-maxime?");
- strb_03.str(str_03); //out ("")
+
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
--- /dev/null
+// 2004-08-12 Paolo Carlini <pcarlini@suse.de>
+
+// 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.1.3 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/16956
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ typedef wstringbuf::int_type int_type;
+ typedef wstringbuf::traits_type traits_type;
+ typedef wstringbuf::pos_type pos_type;
+ typedef wstringbuf::off_type off_type;
+
+ wstringbuf strb_01(L"lara's place", ios_base::in);
+ pos_type pt_1 = strb_01.pubseekoff(5, ios_base::cur, ios_base::in);
+ int_type c1 = strb_01.sgetc();
+ VERIFY( c1 != traits_type::eof() );
+ pos_type pt_2 = strb_01.pubseekoff(2, ios_base::cur, ios_base::in);
+ pos_type pt_3 = strb_01.pubseekpos(pt_1, ios_base::in);
+ int_type c2 = strb_01.sbumpc();
+ VERIFY( off_type(pt_3) == off_type(pt_2) - 2 );
+ VERIFY( c2 == c1 );
+
+ wstringbuf strb_02(L"-", ios_base::out);
+ pos_type pt_4 = strb_02.pubseekoff(0, ios_base::cur, ios_base::out);
+ strb_02.sputn(L"red", 3);
+ pos_type pt_5 = strb_02.pubseekoff(-3, ios_base::cur, ios_base::out);
+ strb_02.pubseekpos(pt_5, ios_base::out);
+ VERIFY( off_type(pt_5) == off_type(pt_4) );
+ strb_02.sputn(L"blu", 3);
+ VERIFY( strb_02.str() == L"blu" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
#include <testsuite_hooks.h>
std::string str_01("mykonos. . . or what?");
-std::string str_02("paris, or sainte-maxime?");
-std::string str_03;
std::stringbuf strb_01(str_01);
-std::stringbuf strb_02(str_02, std::ios_base::in);
-std::stringbuf strb_03(str_03, std::ios_base::out);
// test overloaded virtual functions
void test04()
{
bool test __attribute__((unused)) = true;
std::string str_tmp;
- std::stringbuf strb_tmp;
typedef std::stringbuf::int_type int_type;
- typedef std::stringbuf::traits_type traits_type;
typedef std::stringbuf::pos_type pos_type;
typedef std::stringbuf::off_type off_type;
int_type c1 = strb_01.sbumpc();
- int_type c2 = strb_02.sbumpc();
+ int_type c2;
int_type c3 = strb_01.sbumpc();
pos_type pt_1(off_type(-1));
pos_type pt_2(off_type(0));
off_type off_1 = 0;
off_type off_2 = 0;
-
- // PUT
- strb_03.str(str_01); //reset
// BUFFER MANAGEMENT & POSITIONING
// pubseekpos(pos_type sp, ios_base::openmode)
// alters the stream position to sp
strb_01.str(str_01); //in|out ("mykonos. . . or what?");
- strb_02.str(str_02); //in ("paris, or sainte-maxime?");
- strb_03.str(str_03); //out ("")
+
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
#include <testsuite_hooks.h>
std::wstring str_01(L"mykonos. . . or what?");
-std::wstring str_02(L"paris, or sainte-maxime?");
-std::wstring str_03;
std::wstringbuf strb_01(str_01);
-std::wstringbuf strb_02(str_02, std::ios_base::in);
-std::wstringbuf strb_03(str_03, std::ios_base::out);
// test overloaded virtual functions
void test04()
{
bool test __attribute__((unused)) = true;
std::wstring str_tmp;
- std::wstringbuf strb_tmp;
typedef std::wstringbuf::int_type int_type;
- typedef std::wstringbuf::traits_type traits_type;
typedef std::wstringbuf::pos_type pos_type;
typedef std::wstringbuf::off_type off_type;
int_type c1 = strb_01.sbumpc();
- int_type c2 = strb_02.sbumpc();
+ int_type c2;
int_type c3 = strb_01.sbumpc();
pos_type pt_1(off_type(-1));
off_type off_1 = 0;
off_type off_2 = 0;
- // PUT
- strb_03.str(str_01); //reset
-
// BUFFER MANAGEMENT & POSITIONING
// seekpos
// pubseekpos(pos_type sp, ios_base::openmode)
// alters the stream position to sp
strb_01.str(str_01); //in|out ("mykonos. . . or what?");
- strb_02.str(str_02); //in ("paris, or sainte-maxime?");
- strb_03.str(str_03); //out ("")
+
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);