aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-29 17:36:18 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-29 17:36:18 +0000
commit74dc847d1c7bc8e7721cb9b1f4c53610e19b9a8e (patch)
treef5fa10c57d387828ff902347673353a40f932323 /libstdc++-v3
parent79e45861c136c36ff36f734b217510c9f736f393 (diff)
2003-09-29 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/12296 * include/bits/istream.tcc (peek): Set eofbit if sgetc returns eof. * testsuite/27_io/basic_istream/peek/char/12296.cc: New, from the PR. 2003-09-29 Nathan Myers <ncm@cantrip.org> Paolo Carlini <pcarlini@unitus.it> PR libstdc++/11400 * include/bits/stl_algo.h (search_n): Use iterator_traits<>::difference_type for __n. * testsuite/25_algorithms/search_n/11400.cc: New, from the PR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71911 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog16
-rw-r--r--libstdc++-v3/include/bits/istream.tcc6
-rw-r--r--libstdc++-v3/include/bits/stl_algo.h4
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc32
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc41
5 files changed, 96 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d421c40a3b3..08ce582dc9c 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,21 @@
2003-09-29 Paolo Carlini <pcarlini@unitus.it>
+ PR libstdc++/12296
+ * include/bits/istream.tcc (peek): Set eofbit if sgetc
+ returns eof.
+ * testsuite/27_io/basic_istream/peek/char/12296.cc:
+ New, from the PR.
+
+2003-09-29 Nathan Myers <ncm@cantrip.org>
+ Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/11400
+ * include/bits/stl_algo.h (search_n):
+ Use iterator_traits<>::difference_type for __n.
+ * testsuite/25_algorithms/search_n/11400.cc: New, from the PR.
+
+2003-09-29 Paolo Carlini <pcarlini@unitus.it>
+
* testsuite/22_locale/locale/cons/12352.cc:
Use __attribute__((unused)) for test.
diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index e6677c523a4..bf583377e72 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -761,7 +761,11 @@ namespace std
if (__cerb)
{
try
- { __c = this->rdbuf()->sgetc(); }
+ {
+ __c = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ this->setstate(ios_base::eofbit);
+ }
catch(...)
{
// 27.6.1.3 paragraph 1
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 7b3fa9d4232..598eb0f01c9 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -609,7 +609,7 @@ namespace std
else {
__first = std::find(__first, __last, __val);
while (__first != __last) {
- _Integer __n = __count - 1;
+ typename iterator_traits<_ForwardIterator>::difference_type __n = __count - 1;
_ForwardIterator __i = __first;
++__i;
while (__i != __last && __n != 0 && *__i == __val) {
@@ -661,7 +661,7 @@ namespace std
++__first;
}
while (__first != __last) {
- _Integer __n = __count - 1;
+ typename iterator_traits<_ForwardIterator>::difference_type __n = __count - 1;
_ForwardIterator __i = __first;
++__i;
while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) {
diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc
new file mode 100644
index 00000000000..a7003768ee2
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc
@@ -0,0 +1,32 @@
+// 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.
+
+// 25.1.9 [lib.alg.search]
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <functional>
+
+struct Integral { operator int() const; };
+
+namespace std
+{
+ template int* search_n (int*, int*, Integral, const int&);
+ template int* search_n (int*, int*, Integral, const int&, greater<int>);
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc
new file mode 100644
index 00000000000..8b4ef74e423
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2003 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 <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/12296
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream stream;
+ VERIFY( stream.rdstate() == ios_base::goodbit );
+ istringstream::int_type c = stream.peek();
+ VERIFY( c == istringstream::traits_type::eof() );
+ VERIFY( stream.rdstate() == ios_base::eofbit );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}