[multiple changes]

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
This commit is contained in:
Paolo Carlini 2003-09-29 17:36:18 +00:00
parent 38b35623d3
commit e5012ba5ec
5 changed files with 96 additions and 3 deletions

View 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:

View 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

View 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)) {

View File

@ -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>);
}

View File

@ -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;
}