diff options
author | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2001-01-06 02:44:11 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2001-01-06 02:44:11 +0000 |
commit | d358ecd01f0516f53e3147b818590c61b25db912 (patch) | |
tree | a2c974b2292e53afd0f3b038b13c56bc0ffa841f | |
parent | d492b0963ab57d52f0caa7b660b20d62b3f39b49 (diff) | |
download | gcc-d358ecd01f0516f53e3147b818590c61b25db912.zip gcc-d358ecd01f0516f53e3147b818590c61b25db912.tar.gz gcc-d358ecd01f0516f53e3147b818590c61b25db912.tar.bz2 |
[multiple changes]
2001-01-05 Benjamin Kosnik <bkoz@redhat.com>
Fix 27_io/filebuf_members.cc
* src/localename.cc (locale::_Impl::_Impl(const _Impl& __imp,
const string& __name, category __cat, size_t __refs): Set
_M_has_name with _M_name.
* include/bits/localefwd.h (locale::operator!=): Protect member
function call with this->.
* src/locale.cc (locale::operator==): Make fast checks first.
* include/bits/basic_ios.tcc (basic_ios::init): Simplify.
* include/bits/ios_base.h (_M_synced_with_stdio): Add data member
to ios_base::Init.
* src/ios.cc (ios_base::Init::Init): Initialize here.
(ios_base::sync_with_stdio): Set here.
2001-01-04 Loren J. Rittle <ljrittle@acm.org>
* config/c_io_stdio.cc (__basic_file<_CharT>::sys_open()): On
systems that support it, call dup() before fdopen().
From-SVN: r38742
-rw-r--r-- | libstdc++-v3/ChangeLog | 21 | ||||
-rw-r--r-- | libstdc++-v3/config/c_io_stdio.cc | 17 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.tcc | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/ios_base.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/localefwd.h | 9 | ||||
-rw-r--r-- | libstdc++-v3/src/ios.cc | 19 | ||||
-rw-r--r-- | libstdc++-v3/src/locale.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/src/localename.cc | 97 |
8 files changed, 105 insertions, 77 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7c644af..f1a4dcd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,24 @@ +2001-01-05 Benjamin Kosnik <bkoz@redhat.com> + + Fix 27_io/filebuf_members.cc + * src/localename.cc (locale::_Impl::_Impl(const _Impl& __imp, + const string& __name, category __cat, size_t __refs): Set + _M_has_name with _M_name. + * include/bits/localefwd.h (locale::operator!=): Protect member + function call with this->. + * src/locale.cc (locale::operator==): Make fast checks first. + * include/bits/basic_ios.tcc (basic_ios::init): Simplify. + + * include/bits/ios_base.h (_M_synced_with_stdio): Add data member + to ios_base::Init. + * src/ios.cc (ios_base::Init::Init): Initialize here. + (ios_base::sync_with_stdio): Set here. + +2001-01-04 Loren J. Rittle <ljrittle@acm.org> + + * config/c_io_stdio.cc (__basic_file<_CharT>::sys_open()): On + systems that support it, call dup() before fdopen(). + 2001-01-03 Benjamin Kosnik <bkoz@redhat.com> * include/c_std/bits/std_cwctype.h: Include std_cwchar.h for wint_t. diff --git a/libstdc++-v3/config/c_io_stdio.cc b/libstdc++-v3/config/c_io_stdio.cc index 1203c52..c9ac770 100644 --- a/libstdc++-v3/config/c_io_stdio.cc +++ b/libstdc++-v3/config/c_io_stdio.cc @@ -1,6 +1,6 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 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 @@ -32,6 +32,7 @@ // #include <bits/basic_file.h> +#include <unistd.h> namespace std { @@ -94,14 +95,17 @@ namespace std { _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode); - if (!this->is_open()) + int __dupfd = dup(__fd); + + if (__dupfd != -1 && !this->is_open()) { - if ((_M_cfile = fdopen(__fd, __c_mode))) + if ((_M_cfile = fdopen(__dupfd, __c_mode))) { - _M_fileno = __fd; + _M_fileno = __dupfd; __ret = this; } } + return __ret; } @@ -225,7 +229,10 @@ namespace std { template<typename _CharT> streamoff __basic_file<_CharT>::sys_seek(streamoff __pos, ios_base::seekdir __way) - { fseek(_M_cfile, __pos, __way); return ftell(_M_cfile); } + { + fseek(_M_cfile, __pos, __way); + return ftell(_M_cfile); + } // NB: Unused. template<typename _CharT> diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 54d5efd..2b9d6f8 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -119,17 +119,15 @@ namespace std { { // NB: This may be called more than once on the same object. ios_base::_M_init(); - locale __loc = this->getloc(); - _M_ios_fctype = &use_facet<__ctype_type>(__loc); + _M_ios_fctype = &use_facet<__ctype_type>(_M_ios_locale); // Should be filled in by ostream and istream, respectively. - _M_fnumput = &use_facet<__numput_type>(__loc); - _M_fnumget = &use_facet<__numget_type>(__loc); + _M_fnumput = &use_facet<__numput_type>(_M_ios_locale); + _M_fnumget = &use_facet<__numget_type>(_M_ios_locale); _M_tie = 0; _M_fill = this->widen(' '); _M_exception = goodbit; _M_streambuf = __sb; - iostate __state = __sb ? goodbit : badbit; - _M_streambuf_state = __state; + _M_streambuf_state = __sb ? goodbit : badbit; } } // namespace std diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h index 2ffeaf6..c5de5b8 100644 --- a/libstdc++-v3/include/bits/ios_base.h +++ b/libstdc++-v3/include/bits/ios_base.h @@ -1,6 +1,6 @@ // Iostreams base classes -*- C++ -*- -// Copyright (C) 1997-2000 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001 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 @@ -138,7 +138,7 @@ namespace std { class ios_base { public: - + // 27.4.2.1.1 Class ios_base::failure class failure : public exception { @@ -294,6 +294,7 @@ namespace std { ~Init(); private: static int _S_ios_base_init; + bool _M_synced_with_stdio; filebuf* _M_cout; filebuf* _M_cin; filebuf* _M_cerr; diff --git a/libstdc++-v3/include/bits/localefwd.h b/libstdc++-v3/include/bits/localefwd.h index 77731c5..cb86d91 100644 --- a/libstdc++-v3/include/bits/localefwd.h +++ b/libstdc++-v3/include/bits/localefwd.h @@ -270,7 +270,7 @@ namespace std inline bool operator!=(const locale& __other) const throw () - { return !(operator==(__other)); } + { return !(this->operator==(__other)); } template<typename _Char, typename _Traits, typename _Alloc> bool @@ -361,10 +361,9 @@ namespace std } } - _Impl(const _Impl&, size_t __refs); - _Impl(const _Impl&, const string&, category, size_t __refs); - _Impl(size_t __facets, size_t __refs, bool __has_name, - string __name = "*"); + _Impl(const _Impl&, size_t); + _Impl(const _Impl&, const string&, category, size_t); + _Impl(size_t, size_t, bool __has_name = false, string __name = "*"); ~_Impl() throw(); void diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc index 873bd3b..bac371a 100644 --- a/libstdc++-v3/src/ios.cc +++ b/libstdc++-v3/src/ios.cc @@ -1,6 +1,6 @@ // Iostreams base classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001 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 @@ -35,8 +35,8 @@ #include <bits/std_iostream.h> #include <bits/std_fstream.h> -namespace std { - +namespace std +{ // Definitions for static const data members of __ios_flags. const __ios_flags::__int_type __ios_flags::_S_boolalpha; const __ios_flags::__int_type __ios_flags::_S_dec; @@ -159,6 +159,7 @@ namespace std { __wold = wclog.rdbuf(_M_wcerr); __wold->~wstreambuf(); #endif + _M_synced_with_stdio = true; } } @@ -237,9 +238,9 @@ namespace std { ios_base::_M_init() { // NB: May be called more than once - _M_flags = skipws | dec; - _M_width = 0; _M_precision = 6; + _M_width = 0; + _M_flags = skipws | dec; _M_callbacks = 0; _M_words = 0; _M_word_limit = 0; @@ -313,9 +314,11 @@ namespace std { { #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS // 49. Underspecification of ios_base::sync_with_stdio - bool __ret = __ioinit._M_cin->_M_file->get_fileno() == 0; + bool __ret = __ioinit._M_synced_with_stdio; +#endif - // Turn off sync with C FILE* for cin, cout, cerr, clog. + // Turn off sync with C FILE* for cin, cout, cerr, clog iff + // currently synchronized. if (!__sync && __ret) { // Need to dispose of the buffers created at initialization. @@ -349,10 +352,10 @@ namespace std { wcerr.flags(ios_base::unitbuf); wclog.rdbuf(__ioinit._M_wcerr); #endif + __ioinit._M_synced_with_stdio = false; } return __ret; -#endif } } // namespace std diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 83ca7c1..d9cc304 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -623,8 +623,8 @@ namespace std bool locale::operator==(const locale& __rhs) const throw() { - return((this->name() != "*" && this->name() == __rhs.name()) - || _M_impl == __rhs._M_impl); + return (_M_impl == __rhs._M_impl + || (this->name() != "*" && this->name() == __rhs.name())); } const locale& diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index 066f0dd..f028765 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -1,4 +1,4 @@ -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001 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 @@ -45,12 +45,12 @@ namespace std { } locale::_Impl:: - _Impl(const _Impl& __other, size_t __refs) + _Impl(const _Impl& __imp, size_t __refs) : _M_references(__refs - 1), _M_facets(0), _M_category_names(0), - _M_has_name(__other._M_has_name), _M_name(__other._M_name) + _M_has_name(__imp._M_has_name), _M_name(__imp._M_name) { try - { _M_facets = new __vec_facet(*(__other._M_facets)); } + { _M_facets = new __vec_facet(*(__imp._M_facets)); } catch(...) { delete _M_facets; @@ -58,7 +58,7 @@ namespace std { } try - { _M_category_names = new __vec_string(*(__other._M_category_names)); } + { _M_category_names = new __vec_string(*(__imp._M_category_names)); } catch(...) { delete _M_category_names; @@ -73,13 +73,12 @@ namespace std { // This constructor is used to correctly initialize named locales, // including the standard "C" locale. locale::_Impl:: - _Impl(size_t __numfacets, size_t __refs, bool __has_name = false, - string __name) + _Impl(size_t __num, size_t __refs, bool __has_name, string __str) : _M_references(__refs - 1), _M_facets(0), _M_category_names(0), - _M_has_name(__has_name), _M_name(__name) + _M_has_name(__has_name), _M_name(__str) { try - { _M_facets = new __vec_facet(__numfacets, NULL); } + { _M_facets = new __vec_facet(__num, NULL); } catch(...) { delete _M_facets; @@ -97,14 +96,13 @@ namespace std { // Construct specific categories, leaving unselected ones alone locale::_Impl:: - _Impl(const _Impl& __other, const string& __name, category __cat, - size_t __refs) - : _M_references(__refs - 1), _M_has_name(__other._M_name != "*") + _Impl(const _Impl& __imp, const string& __str, category __cat, size_t __refs) + : _M_references(__refs - 1) { __cat = _S_normalize_category(__cat); // might throw try - { _M_facets = new __vec_facet(*(__other._M_facets)); } + { _M_facets = new __vec_facet(*(__imp._M_facets)); } catch(...) { delete _M_facets; @@ -112,7 +110,7 @@ namespace std { } try - { _M_category_names = new __vec_string(*(__other._M_category_names)); } + { _M_category_names = new __vec_string(*(__imp._M_category_names)); } catch(...) { delete _M_category_names; @@ -146,7 +144,7 @@ namespace std { if (mask & __cat) _M_replace_category(_S_classic, _S_facet_categories[ix]); else - (this->*ctors[ix])(__name.c_str()); + (this->*ctors[ix])(__str.c_str()); } } catch(...) @@ -159,43 +157,44 @@ namespace std { // XXX May need to be adjusted if (__cat == all) - _M_name = __name; + _M_name = __str; + _M_has_name = __str != "*"; } void locale::_Impl:: - _M_replace_categories(const _Impl* __other, category __cat) + _M_replace_categories(const _Impl* __imp, category __cat) { category __mask = locale::all & -static_cast<unsigned int>(locale::all); for (unsigned int __ix = 0; (-__mask & __cat) != 0; ++__ix, (__mask <<= 1)) { if (__mask & __cat) { - _M_replace_category(__other, _S_facet_categories[__ix]); - (*_M_category_names)[__ix] = (*(__other->_M_category_names))[__ix]; + _M_replace_category(__imp, _S_facet_categories[__ix]); + (*_M_category_names)[__ix] = (*(__imp->_M_category_names))[__ix]; } } } void locale::_Impl:: - _M_replace_category(const _Impl* __other, const locale::id* const* __idpp) + _M_replace_category(const _Impl* __imp, const locale::id* const* __idpp) { for (; *__idpp; ++__idpp) - _M_replace_facet(__other, *__idpp); + _M_replace_facet(__imp, *__idpp); } void locale::_Impl:: - _M_replace_facet(const _Impl* __other, const locale::id* __idp) + _M_replace_facet(const _Impl* __imp, const locale::id* __idp) { size_t __index = __idp->_M_index; if (__index == 0 - || __other->_M_facets->size() <= __index - || (*(__other->_M_facets))[__index] == 0) + || __imp->_M_facets->size() <= __index + || (*(__imp->_M_facets))[__index] == 0) throw runtime_error("no locale facet"); - _M_install_facet(__idp, (*(__other->_M_facets))[__index]); + _M_install_facet(__idp, (*(__imp->_M_facets))[__index]); } void @@ -220,70 +219,70 @@ namespace std { } void - locale::_Impl::_M_construct_collate(const char* __name) + locale::_Impl::_M_construct_collate(const char* __s) { - _M_facet_init(new collate_byname<char>(__name, 0)); + _M_facet_init(new collate_byname<char>(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new collate_byname<wchar_t>(__name, 0)); + _M_facet_init(new collate_byname<wchar_t>(__s, 0)); #endif } void - locale::_Impl::_M_construct_ctype(const char* __name) + locale::_Impl::_M_construct_ctype(const char* __s) { - _M_facet_init(new ctype_byname<char>(__name, 0)); - _M_facet_init(new codecvt_byname<char, char, mbstate_t>(__name)); + _M_facet_init(new ctype_byname<char>(__s, 0)); + _M_facet_init(new codecvt_byname<char, char, mbstate_t>(__s)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new ctype_byname<wchar_t>(__name, 0)); - _M_facet_init(new codecvt_byname<wchar_t, char, mbstate_t>(__name)); + _M_facet_init(new ctype_byname<wchar_t>(__s, 0)); + _M_facet_init(new codecvt_byname<wchar_t, char, mbstate_t>(__s)); #endif } void - locale::_Impl::_M_construct_monetary(const char* __name) + locale::_Impl::_M_construct_monetary(const char* __s) { _M_replace_facet(locale::_S_classic, &money_get<char>::id); _M_replace_facet(locale::_S_classic, &money_put<char>::id); - _M_facet_init(new moneypunct_byname<char, false>(__name, 0)); - _M_facet_init(new moneypunct_byname<char, true >(__name, 0)); + _M_facet_init(new moneypunct_byname<char, false>(__s, 0)); + _M_facet_init(new moneypunct_byname<char, true >(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T _M_replace_facet(locale::_S_classic, &money_get<wchar_t>::id); _M_replace_facet(locale::_S_classic, &money_put<wchar_t>::id); - _M_facet_init(new moneypunct_byname<wchar_t, false>(__name, 0)); - _M_facet_init(new moneypunct_byname<wchar_t, true >(__name, 0)); + _M_facet_init(new moneypunct_byname<wchar_t, false>(__s, 0)); + _M_facet_init(new moneypunct_byname<wchar_t, true >(__s, 0)); #endif } void - locale::_Impl::_M_construct_numeric(const char* __name) + locale::_Impl::_M_construct_numeric(const char* __s) { _M_replace_facet(locale::_S_classic, &num_get<char>::id); _M_replace_facet(locale::_S_classic, &num_put<char>::id); - _M_facet_init(new numpunct_byname<char>(__name, 0)); + _M_facet_init(new numpunct_byname<char>(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T _M_replace_facet(locale::_S_classic, &num_get<wchar_t>::id); _M_replace_facet(locale::_S_classic, &num_put<wchar_t>::id); - _M_facet_init(new numpunct_byname<wchar_t>(__name, 0)); + _M_facet_init(new numpunct_byname<wchar_t>(__s, 0)); #endif } void - locale::_Impl::_M_construct_time(const char* __name) + locale::_Impl::_M_construct_time(const char* __s) { - _M_facet_init(new time_get_byname<char>(__name, 0)); - _M_facet_init(new time_put_byname<char>(__name, 0)); + _M_facet_init(new time_get_byname<char>(__s, 0)); + _M_facet_init(new time_put_byname<char>(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new time_get_byname<wchar_t>(__name, 0)); - _M_facet_init(new time_put_byname<wchar_t>(__name, 0)); + _M_facet_init(new time_get_byname<wchar_t>(__s, 0)); + _M_facet_init(new time_put_byname<wchar_t>(__s, 0)); #endif } void - locale::_Impl::_M_construct_messages(const char* __name) + locale::_Impl::_M_construct_messages(const char* __s) { - _M_facet_init(new messages_byname<char>(__name, 0)); + _M_facet_init(new messages_byname<char>(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new messages_byname<wchar_t>(__name, 0)); + _M_facet_init(new messages_byname<wchar_t>(__s, 0)); #endif } } |