[multiple changes]
authorPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Sep 2003 17:36:18 +0000 (17:36 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Sep 2003 17:36:18 +0000 (17:36 +0000)
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.

From-SVN: r71911

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc [new file with mode: 0644]

index d421c40a3b3b310d9ea5f9a4b09196d4e7c7e728..08ce582dc9cc5f3380248165b0911939af9ec77e 100644 (file)
@@ -1,3 +1,19 @@
+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:
index e6677c523a4bfc2314aa79e1264052840cd22649..bf583377e725e2273e252470162c559c0a63a44d 100644 (file)
@@ -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
index 7b3fa9d423296cc35004c796c01efbe08c0d1c7c..598eb0f01c9cafee095fc76df7ed2c81ef42d687 100644 (file)
@@ -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 (file)
index 0000000..a700376
--- /dev/null
@@ -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 (file)
index 0000000..8b4ef74
--- /dev/null
@@ -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;
+}