From 8d0a564bba54f790c0306edd35ed0e1c98e904ce Mon Sep 17 00:00:00 2001 From: Jerry Quinn Date: Tue, 4 Feb 2003 20:56:50 +0000 Subject: [PATCH] std_ostream.h (ostream::_M_write): Declare. 2003-02-04 Jerry Quinn * include/std/std_ostream.h (ostream::_M_write): Declare. * ostream.tcc (ostream::_M_write): Define. (basic_ostream::write): Use it. (operator<<(basic_ostream, _CharT)): Ditto. (operator<<(basic_ostream, char)): Ditto. (operator<<(basic_ostream, _CharT*)): Ditto. (operator<<(basic_ostream, char*)): Ditto. (operator<<(basic_ostream, basic_string)): Ditto. From-SVN: r62399 --- libstdc++-v3/ChangeLog | 14 +++++++++++++- libstdc++-v3/include/bits/ostream.tcc | 24 +++++++++--------------- libstdc++-v3/include/std/std_ostream.h | 11 ++++++++++- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 64ba8627254..de954ffbc19 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2003-02-04 Jerry Quinn + + * include/std/std_ostream.h (ostream::_M_write): Declare. + * ostream.tcc (ostream::_M_write): Define. + (basic_ostream::write): Use it. + (operator<<(basic_ostream, _CharT)): Ditto. + (operator<<(basic_ostream, char)): Ditto. + (operator<<(basic_ostream, _CharT*)): Ditto. + (operator<<(basic_ostream, char*)): Ditto. + (operator<<(basic_ostream, basic_string)): Ditto. + 2003-02-04 Benjamin Kosnik * testsuite/26_numerics/valarray_name_lookup.cc: Fix. @@ -67,7 +78,8 @@ * include/bits/valarray_before.h (_UnBase::operator[]): Apply unary operator. - * include/bits/valarray_before.h (__not_equal_to): Use != instead of ==. + * include/bits/valarray_before.h (__not_equal_to): Use != instead + of ==. * testsuite/26_numerics/valarray_operators.cc: New test. diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index 30b16ca8dfd..b5b8762e5bf 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -1,6 +1,6 @@ // ostream classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -388,7 +388,7 @@ namespace std if (traits_type::eq_int_type(__put, traits_type::eof())) this->setstate(ios_base::badbit); } - return *this; + return *this; } template @@ -397,11 +397,7 @@ namespace std { sentry __cerb(*this); if (__cerb) - { - streamsize __put = this->rdbuf()->sputn(__s, __n); - if ( __put != __n) - this->setstate(ios_base::badbit); - } + _M_write(__s, __n); return *this; } @@ -488,7 +484,7 @@ namespace std &__c, __w, __len, false); __len = __w; } - __out.write(__pads, __len); + __out._M_write(__pads, __len); __out.width(0); } catch(exception& __fail) @@ -524,7 +520,7 @@ namespace std &__c, __w, __len, false); __len = __w; } - __out.write(__pads, __len); + __out._M_write(__pads, __len); __out.width(0); } catch(exception& __fail) @@ -559,7 +555,7 @@ namespace std __s = __pads; __len = __w; } - __out.write(__s, __len); + __out._M_write(__s, __len); __out.width(0); } catch(exception& __fail) @@ -608,7 +604,7 @@ namespace std __str = __pads; __len = __w; } - __out.write(__str, __len); + __out._M_write(__str, __len); __out.width(0); } catch(exception& __fail) @@ -647,7 +643,7 @@ namespace std __s = __pads; __len = __w; } - __out.write(__s, __len); + __out._M_write(__s, __len); __out.width(0); } catch(exception& __fail) @@ -688,10 +684,8 @@ namespace std __s = __pads; __len = __w; } - streamsize __res = __out.rdbuf()->sputn(__s, __len); + __out._M_write(__s, __len); __out.width(0); - if (__res != __len) - __out.setstate(ios_base::failbit); } return __out; } diff --git a/libstdc++-v3/include/std/std_ostream.h b/libstdc++-v3/include/std/std_ostream.h index 7a553296102..9d1c1f62c5a 100644 --- a/libstdc++-v3/include/std/std_ostream.h +++ b/libstdc++-v3/include/std/std_ostream.h @@ -1,6 +1,6 @@ // Output streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -261,6 +261,15 @@ namespace std __ostream_type& put(char_type __c); + // Core write functionality, without sentry. + void + _M_write(const char_type* __s, streamsize __n) + { + streamsize __put = this->rdbuf()->sputn(__s, __n); + if (__put != __n) + this->setstate(ios_base::badbit); + } + /** * @brief Character string insertion. * @param s The array to insert.