Commit 544f9440 by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/21286 (filebuf::xsgetn vs pipes)

2005-04-29  Paolo Carlini  <pcarlini@suse.de>
	    Nathan Myers  <ncm@cantrip.org>

	PR libstdc++/21286
	* include/bits/fstream.tcc (basic_filebuf<>::xsgetn):
	Loop on short reads; remove the work-around for
	libstdc++/20806, not needed anymore.

Co-Authored-By: Nathan Myers <ncm@cantrip.org>

From-SVN: r99033
parent bbf9b913
2005-04-29 Paolo Carlini <pcarlini@suse.de> 2005-04-29 Paolo Carlini <pcarlini@suse.de>
Nathan Myers <ncm@cantrip.org>
PR libstdc++/21286
* include/bits/fstream.tcc (basic_filebuf<>::xsgetn):
Loop on short reads; remove the work-around for
libstdc++/20806, not needed anymore.
2005-04-29 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/21238 PR libstdc++/21238
* include/bits/locale_facets.tcc (num_get::_M_extract_float, * include/bits/locale_facets.tcc (num_get::_M_extract_float,
......
...@@ -531,15 +531,8 @@ namespace std ...@@ -531,15 +531,8 @@ namespace std
const bool __testin = _M_mode & ios_base::in; const bool __testin = _M_mode & ios_base::in;
const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM
// About this workaround, see libstdc++/20806.
const bool __testbinary = _M_mode & ios_base::binary;
if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
&& __testin && __testbinary && !_M_writing)
#else
if (__n > __buflen && __check_facet(_M_codecvt).always_noconv() if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
&& __testin && !_M_writing) && __testin && !_M_writing)
#endif
{ {
// First, copy the chars already present in the buffer. // First, copy the chars already present in the buffer.
const streamsize __avail = this->egptr() - this->gptr(); const streamsize __avail = this->egptr() - this->gptr();
...@@ -555,13 +548,28 @@ namespace std ...@@ -555,13 +548,28 @@ namespace std
__n -= __avail; __n -= __avail;
} }
const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s), // Need to loop in case of short reads (relatively common
__n); // with pipes).
if (__len == -1) streamsize __len;
__throw_ios_failure(__N("basic_filebuf::xsgetn " for (;;)
"error reading the file")); {
__ret += __len; __len = _M_file.xsgetn(reinterpret_cast<char*>(__s),
if (__len == __n) __n);
if (__len == -1)
__throw_ios_failure(__N("basic_filebuf::xsgetn "
"error reading the file"));
if (__len == 0)
break;
__n -= __len;
__ret += __len;
if (__n == 0)
break;
__s += __len;
}
if (__n == 0)
{ {
_M_set_buffer(0); _M_set_buffer(0);
_M_reading = true; _M_reading = true;
......
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