diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-03 02:32:52 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-03 02:32:52 +0000 |
commit | a0e7d388874b75d3460bed887a4c960562b620e0 (patch) | |
tree | 6251cfb06881554892dd18eece7ba47087929eaa /libstdc++-v3 | |
parent | d46792c2862f9f1efad65f3aa20abfef6df708cb (diff) | |
download | gcc-a0e7d388874b75d3460bed887a4c960562b620e0.tar.gz |
2002-04-02 Benjamin Kosnik <bkoz@redhat.com>
libstdc++/5268
* src/ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls.
* testsuite/27_io/ios_init.cc (tests04): Add test.
libstdc++/3983
* include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove.
(basic_ios::_M_ios_fctype): Consistently name to _M_fctype.
* include/bits/basic_ios.tcc: Same. Remove outdated comments.
* include/bits/istream.tcc: Use _M_fctype, make consistent with
ostream.
* testsuite/27_io/ios_init.cc (tests03): Add test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51777 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 14 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.tcc | 18 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/istream.tcc | 31 | ||||
-rw-r--r-- | libstdc++-v3/src/ios.cc | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/ios_init.cc | 76 |
6 files changed, 113 insertions, 38 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b61a6997c81..bbb282d2610 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,17 @@ +2002-04-02 Benjamin Kosnik <bkoz@redhat.com> + + libstdc++/5268 + * src/ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls. + * testsuite/27_io/ios_init.cc (tests04): Add test. + + libstdc++/3983 + * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. + (basic_ios::_M_ios_fctype): Consistently name to _M_fctype. + * include/bits/basic_ios.tcc: Same. Remove outdated comments. + * include/bits/istream.tcc: Use _M_fctype, make consistent with + ostream. + * testsuite/27_io/ios_init.cc (tests03): Add test. + 2002-04-02 Phil Edwards <pme@gcc.gnu.org> * include/Makefile.am (install-data-local): Use mkinstalldirs. diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h index cc8617f986f..13ad0f82e99 100644 --- a/libstdc++-v3/include/bits/basic_ios.h +++ b/libstdc++-v3/include/bits/basic_ios.h @@ -69,17 +69,13 @@ namespace std basic_streambuf<_CharT, _Traits>* _M_streambuf; // Cached use_facet<ctype>, which is based on the current locale info. - const __ctype_type* _M_ios_fctype; + const __ctype_type* _M_fctype; // From ostream. const __numput_type* _M_fnumput; // From istream. const __numget_type* _M_fnumget; public: - const __ctype_type* - _M_get_fctype_ios(void) - { return _M_ios_fctype; } - operator void*() const { return this->fail() ? 0 : const_cast<basic_ios*>(this); } diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 7dba1222cfb..1e345dc2117 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -67,12 +67,6 @@ namespace std _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? _M_local_word : new _Words[__rhs._M_word_size]; - // XXX This is the only reason _Callback_list was defined - // inline. The suspicion is that this increased compilation - // times dramatically for functions that use this member - // function (inserters_extractors, ios_manip_fmtflags). FIX ME, - // clean this stuff up. Callbacks are broken right now, anyway. - // Bump refs before doing callbacks, for safety. _Callback_list* __cb = __rhs._M_callbacks; if (__cb) @@ -113,8 +107,8 @@ namespace std basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const { char __ret = __dfault; - if (_M_check_facet(_M_ios_fctype)) - __ret = _M_ios_fctype->narrow(__c, __dfault); + if (_M_check_facet(_M_fctype)) + __ret = _M_fctype->narrow(__c, __dfault); return __ret; } @@ -123,8 +117,8 @@ namespace std basic_ios<_CharT, _Traits>::widen(char __c) const { char_type __ret = char_type(); - if (_M_check_facet(_M_ios_fctype)) - __ret = _M_ios_fctype->widen(__c); + if (_M_check_facet(_M_fctype)) + __ret = _M_fctype->widen(__c); return __ret; } @@ -175,9 +169,9 @@ namespace std basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc) { if (has_facet<__ctype_type>(__loc)) - _M_ios_fctype = &use_facet<__ctype_type>(__loc); + _M_fctype = &use_facet<__ctype_type>(__loc); else - _M_ios_fctype = 0; + _M_fctype = 0; // Should be filled in by ostream and istream, respectively. if (has_facet<__numput_type>(__loc)) _M_fnumput = &use_facet<__numput_type>(__loc); diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 4a32c659be4..7f985594f9b 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -50,12 +50,13 @@ namespace std if (!__noskipws && (__in.flags() & ios_base::skipws)) { const __int_type __eof = traits_type::eof(); - const __ctype_type* __ctype = __in._M_get_fctype_ios(); __streambuf_type* __sb = __in.rdbuf(); __int_type __c = __sb->sgetc(); - - while (__c != __eof && __ctype->is(ctype_base::space, __c)) - __c = __sb->snextc(); + + if (__in._M_check_facet(__in._M_fctype)) + while (__c != __eof + && __in._M_fctype->is(ctype_base::space, __c)) + __c = __sb->snextc(); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS //195. Should basic_istream::sentry's constructor ever set eofbit? @@ -1098,12 +1099,12 @@ namespace std if (__num == 0) __num = numeric_limits<streamsize>::max(); + const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc()); + const int_type __eof = _Traits::eof(); __streambuf_type* __sb = __in.rdbuf(); - const __ctype_type* __ctype = __in._M_get_fctype_ios(); int_type __c = __sb->sbumpc(); - const int_type __eof = _Traits::eof(); - bool __testsp = __ctype->is(ctype_base::space, __c); bool __testeof = __c == __eof; + bool __testsp = __ctype.is(ctype_base::space, __c); while (__extracted < __num - 1 && !__testeof && !__testsp) { @@ -1111,7 +1112,7 @@ namespace std ++__extracted; __c = __sb->sbumpc(); __testeof = __c == __eof; - __testsp = __ctype->is(ctype_base::space, __c); + __testsp = __ctype.is(ctype_base::space, __c); } if (!__testeof) @@ -1150,8 +1151,8 @@ namespace std typedef typename __istream_type::int_type __int_type; typedef typename __istream_type::char_type __char_type; + const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc()); __streambuf_type* __sb = __in.rdbuf(); - const __ctype_type* __ctype = __in._M_get_fctype_ios(); const __int_type __eof = _Traits::eof(); __int_type __c; bool __testeof; @@ -1160,8 +1161,8 @@ namespace std do { __c = __sb->sbumpc(); - __testeof = __c == __eof; - __testsp = __ctype->is(ctype_base::space, __c); + __testeof = __c == __eof; + __testsp = __ctype.is(ctype_base::space, __c); } while (!__testeof && __testsp); @@ -1195,12 +1196,12 @@ namespace std __size_type __n; __n = __w > 0 ? static_cast<__size_type>(__w) : __str.max_size(); + const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc()); + const __int_type __eof = _Traits::eof(); __streambuf_type* __sb = __in.rdbuf(); - const __ctype_type* __ctype = __in._M_get_fctype_ios(); __int_type __c = __sb->sbumpc(); - const __int_type __eof = _Traits::eof(); - bool __testsp = __ctype->is(ctype_base::space, __c); bool __testeof = __c == __eof; + bool __testsp = __ctype.is(ctype_base::space, __c); while (__extracted < __n && !__testeof && !__testsp) { @@ -1208,7 +1209,7 @@ namespace std ++__extracted; __c = __sb->sbumpc(); __testeof = __c == __eof; - __testsp = __ctype->is(ctype_base::space, __c); + __testsp = __ctype.is(ctype_base::space, __c); } if (!__testeof) __sb->sputbackc(__c); diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc index d13ff0e73cf..0aab0a25a3a 100644 --- a/libstdc++-v3/src/ios.cc +++ b/libstdc++-v3/src/ios.cc @@ -190,16 +190,10 @@ namespace std // Explicitly call dtors to free any memory that is dynamically // allocated by filebuf ctor or member functions, but don't // deallocate all memory by calling operator delete. - cout.flush(); - cerr.flush(); - clog.flush(); buf_cout.~filebuf(); buf_cin.~filebuf(); buf_cerr.~filebuf(); #ifdef _GLIBCPP_USE_WCHAR_T - wcout.flush(); - wcerr.flush(); - wclog.flush(); buf_wcout.~wfilebuf(); buf_wcin.~wfilebuf(); buf_wcerr.~wfilebuf(); diff --git a/libstdc++-v3/testsuite/27_io/ios_init.cc b/libstdc++-v3/testsuite/27_io/ios_init.cc index 38d2e522822..72b9fb4cc85 100644 --- a/libstdc++-v3/testsuite/27_io/ios_init.cc +++ b/libstdc++-v3/testsuite/27_io/ios_init.cc @@ -132,6 +132,80 @@ void test02() VERIFY( test ); } +// libstdc++/3983 +void test03() +{ + using namespace std; + bool test = true; + + // input streams + basic_istringstream<unsigned char> iss_uc; + unsigned char arr[6] = { 'a', 'b', 'c', 'd', 'e' }; + + // Sentry uses locale info, so have to try one formatted input. + try + { + int i; + iss_uc >> i; + } + catch (bad_cast& obj) + { } + catch (exception& obj) + { test = false; } + + try + { + iss_uc >> arr; + } + catch (bad_cast& obj) + { } + catch (exception& obj) + { test = false; } + + try + { + iss_uc >> ws; + } + catch (bad_cast& obj) + { } + catch (exception& obj) + { test = false; } + + try + { + basic_string<unsigned char> s_uc(arr); + iss_uc >> s_uc; + } + catch (bad_cast& obj) + { } + catch (exception& obj) + { test = false; } + + // output streams + basic_ostringstream<unsigned char> oss_uc; + + try + { + bool b = true; + oss_uc << b; + } + catch (bad_cast& obj) + { } + catch (exception& obj) + { test = false; } + + VERIFY( test ); +} + +// libstdc++/5268 +int test04() +{ + std::stringbuf b1; + std::cout.rdbuf( &b1 ); + std::cout << "hello\n"; + return 0; +} + #if !__GXX_WEAK__ // Explicitly instantiate for systems with no COMDAT or weak support. template @@ -147,5 +221,7 @@ int main() { test01(); test02(); + test03(); + test04(); return 0; } |