From: Benjamin Kosnik Date: Thu, 15 Aug 2002 22:25:10 +0000 (+0000) Subject: [multiple changes] X-Git-Tag: releases/gcc-3.2.1~381 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b2d131f71431eb7fce7781af10036f2df485f84;p=thirdparty%2Fgcc.git [multiple changes] 2002-08-15 Danny Smith Benjamin Kosnik * include/bits/istream.tcc (basic_istream::ignore): Use sbumpc, not snextc. * testsuite/27_io/narrow_stream_objects.cc (test10): Add. 2002-08-15 Danny Smith * config/os/newlib/ctype_inline.h (is): Don't offset _M_table. (scan_is): Use this->is. (scan_not): Likewise. 2002-08-15 Rick Danos PR libstdc++/7461 * config/os/newlib/ctype_noninline.h (classic_table): Add offset. * config/os/newlib/ctype_inline.h (is): Use static_cast. From-SVN: r56364 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 375b54e8a9d7..a4414c30d17b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2002-08-15 Danny Smith + Benjamin Kosnik + + * include/bits/istream.tcc (basic_istream::ignore): Use sbumpc, + not snextc. + * testsuite/27_io/narrow_stream_objects.cc (test10): Add. + +2002-08-15 Danny Smith + + * config/os/newlib/ctype_inline.h (is): Don't offset _M_table. + (scan_is): Use this->is. + (scan_not): Likewise. + +2002-08-15 Rick Danos + + PR libstdc++/7461 + * config/os/newlib/ctype_noninline.h (classic_table): Add offset. + * config/os/newlib/ctype_inline.h (is): Use static_cast. + 2002-08-14 Release Manager * GCC 3.2 Released. diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_inline.h b/libstdc++-v3/config/os/newlib/bits/ctype_inline.h index cddffedaa444..8381aced9cd3 100644 --- a/libstdc++-v3/config/os/newlib/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/newlib/bits/ctype_inline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2002 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 @@ -37,14 +37,14 @@ bool ctype:: is(mask __m, char __c) const - { return (_M_table + 1)[(unsigned char)(__c)] & __m; } + { return _M_table[static_cast(__c)] & __m; } const char* ctype:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) - *__vec++ = (_M_table + 1)[(unsigned char) (*__low++)]; + *__vec++ = _M_table[static_cast(*__low++)]; return __high; } @@ -52,7 +52,7 @@ ctype:: scan_is(mask __m, const char* __low, const char* __high) const { - while (__low < __high && !((_M_table + 1)[(unsigned char)(*__low)] & __m)) + while (__low < __high && !this->is(__m, *__low)) ++__low; return __low; } @@ -61,13 +61,7 @@ ctype:: scan_not(mask __m, const char* __low, const char* __high) const { - while (__low < __high - && ((_M_table + 1)[(unsigned char)(*__low)] & __m) != 0) + while (__low < __high && this->is(__m, *__low) != 0) ++__low; return __low; } - - - - - diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h b/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h index 7cb1ece512e0..b511c4a86aa7 100644 --- a/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h @@ -35,7 +35,7 @@ const ctype_base::mask* ctype::classic_table() throw() - { return _ctype_; } + { return _ctype_ + 1; } ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 798fd332b906..58e2caf02cdf 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -722,23 +722,18 @@ namespace std { const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); - int_type __c = __sb->sgetc(); + int_type __c; __n = min(__n, numeric_limits::max()); while (_M_gcount < __n - && !traits_type::eq_int_type(__c, __eof) - && !traits_type::eq_int_type(__c, __delim)) + && !traits_type::eq_int_type(__c = __sb->sbumpc(), __eof)) { - __c = __sb->snextc(); ++_M_gcount; + if (traits_type::eq_int_type(__c, __delim)) + break; } if (traits_type::eq_int_type(__c, __eof)) this->setstate(ios_base::eofbit); - else if (traits_type::eq_int_type(__c, __delim)) - { - __sb->sbumpc(); - ++_M_gcount; - } } catch(exception& __fail) { diff --git a/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc b/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc index f767b7248713..0ee1fce5bfa6 100644 --- a/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc +++ b/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc @@ -66,7 +66,8 @@ #include #include #include -#include +//#include +#define VERIFY(x) x // Include iostream last, just to make is as difficult as possible to // properly initialize the standard iostream objects. @@ -116,19 +117,20 @@ void test03() // Interactive test, to be exercised as follows: // assign stderr to stdout in shell command line, // pipe stdout to cat process and/or redirect stdout to file. -// "hello fine world\n" should be written to stdout in proper order. -// This is a version of the scott snyder test taken from: -// http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00108.html +// a.out >& output +// "hello fine world\n" should be written to stdout, and output, in +// proper order. This is a version of the scott snyder test taken +// from: http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00108.html void test04() { using namespace std; cout << "hello "; - cout.flush (); + cout.flush(); cerr << "fine "; - cerr.flush (); + cerr.flush(); cout << "world" << endl; - cout.flush (); + cout.flush(); } // Interactive test, to be exercised as follows: @@ -138,7 +140,7 @@ void test04() // depending upon buffering mode enforced. void test05() { - std::cout << "hello" << ' ' << "world" <> s; @@ -169,7 +171,7 @@ void test06() void test07() { bool test = true; - std::cout << "Please, enter 'test':"; + std::cout << "Enter 'test':"; std::string s; std::getline(std::cin, s, '\n'); VERIFY( s == "test" ); @@ -188,10 +190,21 @@ void test08() void test09() { bool test = true; - std::cout << "Enter name: "; + std::cout << "Enter favorite beach: "; std::cin.ignore(2048, '\n'); } +// http://gcc.gnu.org/ml/libstdc++/2002-08/msg00060.html +// Should only have to hit enter once. +void +test10() +{ + using namespace std; + cout << "Press ENTER once\n"; + cin.ignore(1); + cout << "_M_gcount: "<< cin.gcount() << endl; +} + int main() { @@ -205,5 +218,6 @@ main() // test07(); // test08(); // test09(); + // test10(); return 0; }