Commit 1bc59af5 by Benjamin Kosnik Committed by Benjamin Kosnik

ios.cc (ios_base::~ios_base): Tweak.


2002-02-25  Benjamin Kosnik  <bkoz@redhat.com>

	* src/ios.cc (ios_base::~ios_base): Tweak.
	(ios_base::_M_call_callbacks): Deal with null __p.
	(ios_base::ios_base): Set _M_callbacks.
	* include/bits/basic_ios.tcc (basic_ios::init): Adjust comment.
	* testsuite/27_io/ios_init.cc (test02): Fix.

	* mkcheck.in (static_fail): Failed links go to output file.

From-SVN: r50032
parent 801791cc
2002-02-25 Benjamin Kosnik <bkoz@redhat.com>
* src/ios.cc (ios_base::~ios_base): Tweak.
(ios_base::_M_call_callbacks): Deal with null __p.
(ios_base::ios_base): Set _M_callbacks.
* include/bits/basic_ios.tcc (basic_ios::init): Adjust comment.
* testsuite/27_io/ios_init.cc (test02): Fix.
* mkcheck.in (static_fail): Failed links go to output file.
2002-02-25 Phil Edwards <pme@gcc.gnu.org> 2002-02-25 Phil Edwards <pme@gcc.gnu.org>
* docs/html/faq/index.html: Update. * docs/html/faq/index.html: Update.
......
...@@ -148,12 +148,12 @@ namespace std ...@@ -148,12 +148,12 @@ namespace std
// requirements after basic_ios::init() has been called. As part // requirements after basic_ios::init() has been called. As part
// of this, fill() must return widen(' '), which needs an imbued // of this, fill() must return widen(' '), which needs an imbued
// ctype facet of char_type to return without throwing an // ctype facet of char_type to return without throwing an
// exception. This is not a required facet, so streams with // exception. Unfortunately, ctype<char_type> is not necessarily a
// char_type != [char, wchar_t] will not have it by // required facet, so streams with char_type != [char, wchar_t]
// default. However, because fill()'s signature is const, this // will not have it by default. However, because fill()'s
// data member cannot be lazily initialized. Thus, thoughts of // signature is const, this data member cannot be lazily
// using a non-const helper function in ostream inserters is // initialized. Thus, thoughts of using a non-const helper
// really besides the point. // function in ostream inserters is really besides the point.
_M_fill = this->widen(' '); _M_fill = this->widen(' ');
_M_exception = goodbit; _M_exception = goodbit;
......
...@@ -277,7 +277,7 @@ namespace std ...@@ -277,7 +277,7 @@ namespace std
}; };
static const int _S_local_words = 8; static const int _S_local_words = 8;
_Words _M_word_array[_S_local_words]; // Guaranteed storage _Words _M_word_array[_S_local_words]; // Guaranteed storage.
_Words _M_dummy; // Only for failed iword/pword calls. _Words _M_dummy; // Only for failed iword/pword calls.
_Words* _M_words; _Words* _M_words;
int _M_word_limit; int _M_word_limit;
......
...@@ -362,8 +362,8 @@ test_file() ...@@ -362,8 +362,8 @@ test_file()
else else
# the file did not compile/link. # the file did not compile/link.
printf "\n" >> $LOG_FILE printf "\n" >> $LOG_FILE
# `cat compile.out >> $LOG_FILE` `cat compile.out >> $LOG_FILE`
# rm compile.out rm compile.out
RESULT="-b" RESULT="-b"
TEXT="0" TEXT="0"
DATA="0" DATA="0"
......
...@@ -257,7 +257,7 @@ namespace std ...@@ -257,7 +257,7 @@ namespace std
} }
for (; i < _M_word_limit; i++) for (; i < _M_word_limit; i++)
words[i] = _M_words[i]; words[i] = _M_words[i];
if (_M_words != _M_word_array) if (_M_words && _M_words != _M_word_array)
delete [] _M_words; delete [] _M_words;
} }
...@@ -294,7 +294,11 @@ namespace std ...@@ -294,7 +294,11 @@ namespace std
ios_base::ios_base() ios_base::ios_base()
{ {
// Do nothing; init() does it. Static init to 0 makes everything sane. // Do nothing: basic_ios::init() does it.
// NB: _M_callbacks and _M_words must be zero for non-initialized
// ios_base to go through ~ios_base gracefully.
_M_callbacks = 0;
_M_words = 0;
} }
// 27.4.2.7 ios_base constructors/destructors // 27.4.2.7 ios_base constructors/destructors
...@@ -302,9 +306,8 @@ namespace std ...@@ -302,9 +306,8 @@ namespace std
{ {
_M_call_callbacks(erase_event); _M_call_callbacks(erase_event);
_M_dispose_callbacks(); _M_dispose_callbacks();
if (_M_words != _M_word_array) if (_M_words && _M_words != _M_word_array)
delete [] _M_words; delete [] _M_words;
// XXX done?
} }
void void
...@@ -314,13 +317,14 @@ namespace std ...@@ -314,13 +317,14 @@ namespace std
void void
ios_base::_M_call_callbacks(event __e) throw() ios_base::_M_call_callbacks(event __e) throw()
{ {
for (_Callback_list* __p = _M_callbacks; __p; __p = __p->_M_next) _Callback_list* __p = _M_callbacks;
while (__p)
{ {
try { try
(*__p->_M_fn) (__e, *this, __p->_M_index); { (*__p->_M_fn) (__e, *this, __p->_M_index); }
} catch (...)
catch (...) { { }
} __p = __p->_M_next;
} }
} }
......
...@@ -86,6 +86,9 @@ void test01() ...@@ -86,6 +86,9 @@ void test01()
// by default, into the locale object. As such, basic_ios::init is // by default, into the locale object. As such, basic_ios::init is
// required to return a bad_cast for the first use of fill() call. // required to return a bad_cast for the first use of fill() call.
// See 27.4.4.1 // See 27.4.4.1
class gnu_ios: public std::basic_ios<char> { };
void test02() void test02()
{ {
bool test = true; bool test = true;
...@@ -93,7 +96,7 @@ void test02() ...@@ -93,7 +96,7 @@ void test02()
// 01: Doesn't call basic_ios::init, which uses ctype<char_type>.. // 01: Doesn't call basic_ios::init, which uses ctype<char_type>..
try try
{ {
std::basic_ostringstream<unsigned short> oss; gnu_ios gios;
} }
catch(...) catch(...)
{ {
...@@ -122,7 +125,7 @@ void test02() ...@@ -122,7 +125,7 @@ void test02()
} }
catch(const std::bad_cast& obj) catch(const std::bad_cast& obj)
{ {
test = true; // This is correct.
} }
catch(...) catch(...)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment