This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Revert 2005-01-05 istream::ignore change
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 11 Jan 2005 17:55:51 +0100
- Subject: [v3] Revert 2005-01-05 istream::ignore change
Hi,
thinking more about the issue, I'm convinced the previous behavior
was correct, albeit slightly different from that of 3.3 in a corner
case (i.e., now if eof/delim immediately follows the n-th char, we
set eof/eat the delim) due to the use of snextc. Indeed, the very
same behavior wrt eof can be seen in get(char_type*, streamsize,
char_type).
Sorry.
Tested x86-linux.
Paolo.
////////////
2005-01-11 Paolo Carlini <pcarlini@suse.de>
* src/istream.cc (basic_istream<char>::ignore(streamsize),
basic_istream<char>::ignore(streamsize, int_type),
basic_istream<wchar_t>::ignore(streamsize),
basic_istream<wchar_t>::ignore(streamsize, int_type)): Revert
2005-01-05 change: actually, the previous behavior is conforming
and consistent with that of get(char_type*, streamsize, char_type),
albeit slightly different from that of 3.3/3.4 in a corner case
due to the use of snextc.
* include/bits/istream.tcc (ignore(streamsize), ignore(streamsize,
int_type)): Likewise.
* testsuite/27_io/basic_istream/ignore/char/4.cc: Remove.
* testsuite/27_io/basic_istream/ignore/wchar_t/4.cc: Likewise.
diff -urN libstdc++-v3-orig/include/bits/istream.tcc libstdc++-v3/include/bits/istream.tcc
--- libstdc++-v3-orig/include/bits/istream.tcc 2005-01-05 12:11:47.000000000 +0100
+++ libstdc++-v3/include/bits/istream.tcc 2005-01-11 17:21:24.000000000 +0100
@@ -707,7 +707,7 @@
break;
}
- if (_M_gcount < __n)
+ if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
catch(...)
@@ -755,11 +755,9 @@
break;
}
- if (_M_gcount == __n)
- ;
- else if (traits_type::eq_int_type(__c, __eof))
+ if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
- else
+ else if (traits_type::eq_int_type(__c, __delim))
{
++_M_gcount;
__sb->sbumpc();
diff -urN libstdc++-v3-orig/src/istream.cc libstdc++-v3/src/istream.cc
--- libstdc++-v3-orig/src/istream.cc 2005-01-05 12:11:47.000000000 +0100
+++ libstdc++-v3/src/istream.cc 2005-01-11 17:23:00.000000000 +0100
@@ -152,7 +152,7 @@
break;
}
- if (_M_gcount < __n)
+ if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
catch(...)
@@ -217,11 +217,9 @@
break;
}
- if (_M_gcount == __n)
- ;
- else if (traits_type::eq_int_type(__c, __eof))
+ if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
- else
+ else if (traits_type::eq_int_type(__c, __delim))
{
++_M_gcount;
__sb->sbumpc();
@@ -432,7 +430,7 @@
break;
}
- if (_M_gcount < __n)
+ if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
catch(...)
@@ -497,11 +495,9 @@
break;
}
- if (_M_gcount == __n)
- ;
- else if (traits_type::eq_int_type(__c, __eof))
+ if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
- else
+ else if (traits_type::eq_int_type(__c, __delim))
{
++_M_gcount;
__sb->sbumpc();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_istream/ignore/char/4.cc libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/4.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_istream/ignore/char/4.cc 2005-01-05 12:11:48.000000000 +0100
+++ libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/4.cc 1970-01-01 01:00:00.000000000 +0100
@@ -1,59 +0,0 @@
-// 2005-01-05 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2005 Free Software Foundation
-//
-// 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.6.1.3 unformatted input functions
-
-#include <istream>
-#include <sstream>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
- using namespace std;
- bool test __attribute__((unused)) = true;
-
- const string str_01("Gesang der junglinge");
- ios_base::iostate state1, state2;
-
- stringbuf isbuf_01(str_01, ios_base::in);
- istream is_01(&isbuf_01);
-
- state1 = is_01.rdstate();
- VERIFY( state1 == ios_base::goodbit );
-
- is_01.ignore(11, 'j');
- VERIFY( is_01.gcount() == 11 );
- state2 = is_01.rdstate();
- VERIFY( state2 == state1 );
- VERIFY( is_01.peek() == 'j' );
-
- is_01.ignore(9);
- VERIFY( is_01.gcount() == 9 );
- state2 = is_01.rdstate();
- VERIFY( state2 == state1 );
-}
-
-int
-main()
-{
- test01();
- return 0;
-}
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_istream/ignore/wchar_t/4.cc libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/4.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_istream/ignore/wchar_t/4.cc 2005-01-05 12:11:48.000000000 +0100
+++ libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/4.cc 1970-01-01 01:00:00.000000000 +0100
@@ -1,59 +0,0 @@
-// 2005-01-05 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2005 Free Software Foundation
-//
-// 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.6.1.3 unformatted input functions
-
-#include <istream>
-#include <sstream>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
- using namespace std;
- bool test __attribute__((unused)) = true;
-
- const wstring str_01(L"Gesang der junglinge");
- ios_base::iostate state1, state2;
-
- wstringbuf isbuf_01(str_01, ios_base::in);
- wistream is_01(&isbuf_01);
-
- state1 = is_01.rdstate();
- VERIFY( state1 == ios_base::goodbit );
-
- is_01.ignore(11, L'j');
- VERIFY( is_01.gcount() == 11 );
- state2 = is_01.rdstate();
- VERIFY( state2 == state1 );
- VERIFY( is_01.peek() == L'j' );
-
- is_01.ignore(9);
- VERIFY( is_01.gcount() == 9 );
- state2 = is_01.rdstate();
- VERIFY( state2 == state1 );
-}
-
-int
-main()
-{
- test01();
- return 0;
-}