diff options
author | Benjamin Kosnik <bkoz@purist.soma.redhat.com> | 2000-06-30 00:38:09 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2000-06-30 00:38:09 +0000 |
commit | 4a2f4b128f298dcd45d4985e67289b82e9efd2e5 (patch) | |
tree | a7427e5ee89eafaa12d67281487880451cc233b1 /libstdc++-v3 | |
parent | ab76ca54bb48c62ce6d9faf6097344692baf0519 (diff) | |
download | gcc-4a2f4b128f298dcd45d4985e67289b82e9efd2e5.tar.gz |
ostream_manip.cc (test02): Add tests.
2000-06-29 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* testsuite/27_io/ostream_manip.cc (test02): Add tests.
* bits/ostream.tcc: Tweak.
* bits/std_fstream.h (basic_filebuf::setbuf): Reset
_M_buf_size_opt too.
* bits/std_streambuf.h (basic_streambuf::~basic_streambuf): Zero
out _M_buf_size_opt.
* bits/std_sstream.h (basic_stringbuf::_M_init_stringbuf): Zero
_M_buf_size_opt out here.
* bits/char_traits.h (char_traits::eos): Non standard member
function, uglify to __eos. Return char_type().
* bits/std_ostream.h: Change.
From-SVN: r34797
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/bits/char_traits.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/bits/ostream.tcc | 2 | ||||
-rw-r--r-- | libstdc++-v3/bits/sstream.tcc | 6 | ||||
-rw-r--r-- | libstdc++-v3/bits/std_fstream.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/bits/std_ostream.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/bits/std_sstream.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/bits/std_streambuf.h | 1 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/ostream_manip.cc | 43 |
9 files changed, 68 insertions, 15 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4e2454cf890..6f1b2277ad8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ -2000-06-29 <bkoz@purist.soma.redhat.com> +2000-06-29 Benjamin Kosnik <bkoz@purist.soma.redhat.com> + * testsuite/27_io/ostream_manip.cc (test02): Add tests. + * bits/ostream.tcc: Tweak. + * bits/std_fstream.h (basic_filebuf::setbuf): Reset + _M_buf_size_opt too. + * bits/std_streambuf.h (basic_streambuf::~basic_streambuf): Zero + out _M_buf_size_opt. + * bits/std_sstream.h (basic_stringbuf::_M_init_stringbuf): Zero + _M_buf_size_opt out here. * bits/char_traits.h (char_traits::eos): Non standard member function, uglify to __eos. Return char_type(). * bits/std_ostream.h: Change. diff --git a/libstdc++-v3/bits/char_traits.h b/libstdc++-v3/bits/char_traits.h index a8c606a8961..7b9516667eb 100644 --- a/libstdc++-v3/bits/char_traits.h +++ b/libstdc++-v3/bits/char_traits.h @@ -137,7 +137,7 @@ namespace std { eof() { return static_cast<int_type>(-1); } static int_type - eos() { return int_type(); } + __eos() { return char_type(); } static int_type not_eof(const int_type& __c) @@ -211,7 +211,7 @@ namespace std { eof() { return static_cast<int_type>(EOF); } static int_type - eos() { return '\0'; } + __eos() { return char_type(); } static int_type not_eof(const int_type& __c) @@ -282,7 +282,7 @@ namespace std { eof() { return static_cast<int_type>(WEOF); } static int_type - eos() { return int_type(); } + __eos() { return char_type(); } static int_type not_eof(const int_type& __c) diff --git a/libstdc++-v3/bits/ostream.tcc b/libstdc++-v3/bits/ostream.tcc index ca6813b97c3..ce683ef51ad 100644 --- a/libstdc++-v3/bits/ostream.tcc +++ b/libstdc++-v3/bits/ostream.tcc @@ -40,7 +40,7 @@ namespace std { { // XXX MT if (_M_ok && __os.tie()) - __os.tie()->flush(); + __os.tie()->flush(); } template<typename _CharT, typename _Traits> diff --git a/libstdc++-v3/bits/sstream.tcc b/libstdc++-v3/bits/sstream.tcc index 6596c4b6d08..4e8a640d870 100644 --- a/libstdc++-v3/bits/sstream.tcc +++ b/libstdc++-v3/bits/sstream.tcc @@ -85,11 +85,7 @@ namespace std { { if (!__testeof) { - // NB: Start ostringstream buffers at 1024 bytes. This - // is an experimental value (pronounced "arbitrary" in - // some of the hipper english-speaking countries), and - // can be changed to suite particular needs. - __size_type __len = max(_M_buf_size, static_cast<int_type>(512)); + __size_type __len = max(_M_buf_size, _M_buf_size_opt); __len *= 2; if (__testwrite) diff --git a/libstdc++-v3/bits/std_fstream.h b/libstdc++-v3/bits/std_fstream.h index f372100efc9..3efb70e9646 100644 --- a/libstdc++-v3/bits/std_fstream.h +++ b/libstdc++-v3/bits/std_fstream.h @@ -141,7 +141,10 @@ namespace std { setbuf(char_type* __s, streamsize __n) { if (!this->is_open() && __s == 0 && __n == 0) - _M_buf_size = 0; + { + _M_buf_size = 0; + _M_buf_size_opt = 0; + } _M_last_overflowed = false; return this; } diff --git a/libstdc++-v3/bits/std_ostream.h b/libstdc++-v3/bits/std_ostream.h index eff25b90625..eca9d6b5d45 100644 --- a/libstdc++-v3/bits/std_ostream.h +++ b/libstdc++-v3/bits/std_ostream.h @@ -1,6 +1,6 @@ // Output streams -*- C++ -*- -// Copyright (C) 1997-1999 Free Software Foundation, Inc. +// Copyright (C) 1997-1999, 2000 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 @@ -262,7 +262,7 @@ namespace std { template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) - { return __os.put(_Traits::eos()); } + { return __os.put(_Traits::__eos()); } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& diff --git a/libstdc++-v3/bits/std_sstream.h b/libstdc++-v3/bits/std_sstream.h index 126d86d1d36..939d6c0b87f 100644 --- a/libstdc++-v3/bits/std_sstream.h +++ b/libstdc++-v3/bits/std_sstream.h @@ -108,6 +108,12 @@ namespace std { // streambufs having control of the allocation and // re-allocation of the internal string object, _M_string. _M_buf_size = _M_string.size(); + + // NB: Start ostringstream buffers at 1024 bytes. This is an + // experimental value (pronounced "arbitrary" in some of the + // hipper english-speaking countries), and can be changed to + // suite particular needs. + _M_buf_size_opt = 512; _M_mode = __mode; if (_M_mode & ios_base::ate) _M_really_sync(0, _M_buf_size); diff --git a/libstdc++-v3/bits/std_streambuf.h b/libstdc++-v3/bits/std_streambuf.h index 84699bfb0ab..5798ba1f6a6 100644 --- a/libstdc++-v3/bits/std_streambuf.h +++ b/libstdc++-v3/bits/std_streambuf.h @@ -191,6 +191,7 @@ namespace std { { _M_buf_unified = false; _M_buf_size = 0; + _M_buf_size_opt = 0; _M_mode = ios_base::openmode(0); _M_fctype_buf = NULL; _M_locale_set = false; diff --git a/libstdc++-v3/testsuite/27_io/ostream_manip.cc b/libstdc++-v3/testsuite/27_io/ostream_manip.cc index c8b9f941a44..e9b30c13f2f 100644 --- a/libstdc++-v3/testsuite/27_io/ostream_manip.cc +++ b/libstdc++-v3/testsuite/27_io/ostream_manip.cc @@ -1,6 +1,6 @@ // 1999-07-22 bkoz -// Copyright (C) 1994, 1999 Free Software Foundation, Inc. +// Copyright (C) 1994, 1999, 2000 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 @@ -20,7 +20,7 @@ // 27.6.2.7 standard basic_ostream manipulators -#include <istream> +#include <ostream> #include <sstream> #include <stdexcept> #ifdef DEBUG_ASSERT @@ -81,6 +81,45 @@ bool test01(void) return test; } + +// based vaguely on this: +// http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00109.html +bool test02() +{ + using namespace std; + typedef ostringstream::int_type int_type; + + bool test = true; + ostringstream osst_01; + const string str_00("herbie_hancock"); + int_type len1 = str_00.size(); + osst_01 << str_00; + test &= osst_01.str().size() == len1; + + osst_01 << ends; + + const string str_01("speak like a child"); + int_type len2 = str_01.size(); + osst_01 << str_01; + int_type len3 = osst_01.str().size(); + test &= len1 < len3; + test &= len3 == len1 + len2 + 1; + + osst_01 << ends; + + const string str_02("+ inventions and dimensions"); + int_type len4 = str_02.size(); + osst_01 << str_02; + int_type len5 = osst_01.str().size(); + test &= len3 < len5; + test &= len5 == len3 + len4 + 1; + +#ifdef DEBUG_ASSERT + assert(test); +#endif + return test; +} + int main() { test01(); |