Commit 7a59efae by Paolo Carlini Committed by Paolo Carlini

std_fstream.h (basic_fstream<>::open, [...]): Implement the resolution of DR 409…

std_fstream.h (basic_fstream<>::open, [...]): Implement the resolution of DR 409 [Ready], call clear() on success.

2005-03-07  Paolo Carlini  <pcarlini@suse.de>

	* include/std/std_fstream.h (basic_fstream<>::open,
	basic_ifstream<>::open, basic_ofstream<>::open): Implement the
	resolution of DR 409 [Ready], call clear() on success.
	* docs/html/ext/howto.html: Add an entry for DR 409.
	* docs/html/faq/index.html (4_4): Clarify the new behavior.
	* testsuite/27_io/basic_ifstream/open/char/1.cc: Adjust.
	* testsuite/27_io/basic_ofstream/open/char/1.cc: Likewise.

From-SVN: r96030
parent 9ed9eda6
2005-03-07 Paolo Carlini <pcarlini@suse.de>
* include/std/std_fstream.h (basic_fstream<>::open,
basic_ifstream<>::open, basic_ofstream<>::open): Implement the
resolution of DR 409 [Ready], call clear() on success.
* docs/html/ext/howto.html: Add an entry for DR 409.
* docs/html/faq/index.html (4_4): Clarify the new behavior.
* testsuite/27_io/basic_ifstream/open/char/1.cc: Adjust.
* testsuite/27_io/basic_ofstream/open/char/1.cc: Likewise.
2005-03-05 Joseph S. Myers <joseph@codesourcery.com> 2005-03-05 Joseph S. Myers <joseph@codesourcery.com>
* testsuite/22_locale/collate/compare/wchar_t/2.cc, * testsuite/22_locale/collate/compare/wchar_t/2.cc,
......
...@@ -503,6 +503,12 @@ ...@@ -503,6 +503,12 @@
<dd>Replace &quot;new&quot; with &quot;::new&quot;. <dd>Replace &quot;new&quot; with &quot;::new&quot;.
</dd> </dd>
<dt><a href="lwg-active.html#409">409</a>:
<em>Closing an fstream should clear the error state</em>
</dt>
<dd>Have <code>open</code> clear the error flags.
</dd>
<dt><a href="lwg-active.html#434">434</a>: <dt><a href="lwg-active.html#434">434</a>:
<em>bitset::to_string() hard to use</em> <em>bitset::to_string() hard to use</em>
</dt> </dt>
......
...@@ -721,6 +721,9 @@ which is no longer available, thanks deja...--> ...@@ -721,6 +721,9 @@ which is no longer available, thanks deja...-->
DR #22</a> is to leave the flags unchanged. You must insert a call DR #22</a> is to leave the flags unchanged. You must insert a call
to <code>fs.clear()</code> between the calls to close() and open(), to <code>fs.clear()</code> between the calls to close() and open(),
and then everything will work like we all expect it to work. and then everything will work like we all expect it to work.
<strong>Update:</strong> for GCC 4.0 we implemented the resolution
of <a href="../ext/howto.html#5">DR #409</a> and open() now calls
<code>clear()</code> on success!
</p> </p>
<p><a name="4_4_rel_ops"><strong>rel_ops</strong></a> <p><a name="4_4_rel_ops"><strong>rel_ops</strong></a>
Another is the <code>rel_ops</code> namespace and the template Another is the <code>rel_ops</code> namespace and the template
......
...@@ -496,6 +496,10 @@ namespace std ...@@ -496,6 +496,10 @@ namespace std
{ {
if (!_M_filebuf.open(__s, __mode | ios_base::in)) if (!_M_filebuf.open(__s, __mode | ios_base::in))
this->setstate(ios_base::failbit); this->setstate(ios_base::failbit);
else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 409. Closing an fstream should clear error state
this->clear();
} }
/** /**
...@@ -623,6 +627,10 @@ namespace std ...@@ -623,6 +627,10 @@ namespace std
{ {
if (!_M_filebuf.open(__s, __mode | ios_base::out)) if (!_M_filebuf.open(__s, __mode | ios_base::out))
this->setstate(ios_base::failbit); this->setstate(ios_base::failbit);
else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 409. Closing an fstream should clear error state
this->clear();
} }
/** /**
...@@ -749,6 +757,10 @@ namespace std ...@@ -749,6 +757,10 @@ namespace std
{ {
if (!_M_filebuf.open(__s, __mode)) if (!_M_filebuf.open(__s, __mode))
this->setstate(ios_base::failbit); this->setstate(ios_base::failbit);
else
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 409. Closing an fstream should clear error state
this->clear();
} }
/** /**
......
// Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. // Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -40,9 +40,10 @@ void test01() ...@@ -40,9 +40,10 @@ void test01()
ifs1.open(name_01); ifs1.open(name_01);
VERIFY( ifs1.is_open() ); VERIFY( ifs1.is_open() );
// fail bit still true
VERIFY( !(ifs1) ); // As per the resolution of DR 409.
VERIFY( ifs1.rdstate() == std::ios_base::failbit ); VERIFY( (ifs1) );
VERIFY( ifs1.rdstate() == std::ios_base::goodbit );
ifs1.close(); ifs1.close();
} }
......
// Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. // Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -41,9 +41,10 @@ void test01() ...@@ -41,9 +41,10 @@ void test01()
ofs1.open(name_02); ofs1.open(name_02);
VERIFY( ofs1.is_open() ); VERIFY( ofs1.is_open() );
// fail bit still true
VERIFY( !(ofs1) ); // As per the resolution of DR 409.
VERIFY( ofs1.rdstate() == std::ios_base::failbit ); VERIFY( (ofs1) );
VERIFY( ofs1.rdstate() == std::ios_base::goodbit );
ofs1.close(); ofs1.close();
} }
......
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