From: Benjamin Kosnik Date: Sat, 6 Jan 2001 02:44:11 +0000 (+0000) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d358ecd01f0516f53e3147b818590c61b25db912;p=gcc.git [multiple changes] 2001-01-05 Benjamin Kosnik 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 * config/c_io_stdio.cc (__basic_file<_CharT>::sys_open()): On systems that support it, call dup() before fdopen(). From-SVN: r38742 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7c644aff638..f1a4dcd4986 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,24 @@ +2001-01-05 Benjamin Kosnik + + 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 + + * config/c_io_stdio.cc (__basic_file<_CharT>::sys_open()): On + systems that support it, call dup() before fdopen(). + 2001-01-03 Benjamin Kosnik * 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 1203c52d975..c9ac7705c55 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 +#include 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 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 diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 54d5efd19bc..2b9d6f87aaa 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 2ffeaf68e0e..c5de5b8185c 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 77731c52236..cb86d9102fd 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 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 873bd3b4724..bac371ab52c 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 #include -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 83ca7c15ed9..d9cc304c8d9 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 066f0dd0868..f028765a61e 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(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(__name, 0)); + _M_facet_init(new collate_byname(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new collate_byname(__name, 0)); + _M_facet_init(new collate_byname(__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(__name, 0)); - _M_facet_init(new codecvt_byname(__name)); + _M_facet_init(new ctype_byname(__s, 0)); + _M_facet_init(new codecvt_byname(__s)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new ctype_byname(__name, 0)); - _M_facet_init(new codecvt_byname(__name)); + _M_facet_init(new ctype_byname(__s, 0)); + _M_facet_init(new codecvt_byname(__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::id); _M_replace_facet(locale::_S_classic, &money_put::id); - _M_facet_init(new moneypunct_byname(__name, 0)); - _M_facet_init(new moneypunct_byname(__name, 0)); + _M_facet_init(new moneypunct_byname(__s, 0)); + _M_facet_init(new moneypunct_byname(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T _M_replace_facet(locale::_S_classic, &money_get::id); _M_replace_facet(locale::_S_classic, &money_put::id); - _M_facet_init(new moneypunct_byname(__name, 0)); - _M_facet_init(new moneypunct_byname(__name, 0)); + _M_facet_init(new moneypunct_byname(__s, 0)); + _M_facet_init(new moneypunct_byname(__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::id); _M_replace_facet(locale::_S_classic, &num_put::id); - _M_facet_init(new numpunct_byname(__name, 0)); + _M_facet_init(new numpunct_byname(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T _M_replace_facet(locale::_S_classic, &num_get::id); _M_replace_facet(locale::_S_classic, &num_put::id); - _M_facet_init(new numpunct_byname(__name, 0)); + _M_facet_init(new numpunct_byname(__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(__name, 0)); - _M_facet_init(new time_put_byname(__name, 0)); + _M_facet_init(new time_get_byname(__s, 0)); + _M_facet_init(new time_put_byname(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new time_get_byname(__name, 0)); - _M_facet_init(new time_put_byname(__name, 0)); + _M_facet_init(new time_get_byname(__s, 0)); + _M_facet_init(new time_put_byname(__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(__name, 0)); + _M_facet_init(new messages_byname(__s, 0)); #ifdef _GLIBCPP_USE_WCHAR_T - _M_facet_init(new messages_byname(__name, 0)); + _M_facet_init(new messages_byname(__s, 0)); #endif } }