From 42689eaf549f5433a44b3430fb505361a8681778 Mon Sep 17 00:00:00 2001 From: kan Date: Sat, 26 Aug 2006 21:29:46 +0000 Subject: Gcc 3.4.6 C++ support bits (as of 2006/08/25 #116475). --- contrib/libstdc++/include/bits/fstream.tcc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'contrib/libstdc++/include/bits/fstream.tcc') diff --git a/contrib/libstdc++/include/bits/fstream.tcc b/contrib/libstdc++/include/bits/fstream.tcc index 25a4d48..3b433ea 100644 --- a/contrib/libstdc++/include/bits/fstream.tcc +++ b/contrib/libstdc++/include/bits/fstream.tcc @@ -535,13 +535,28 @@ namespace std __n -= __avail; } - const streamsize __len = _M_file.xsgetn(reinterpret_cast(__s), - __n); - if (__len == -1) - __throw_ios_failure(__N("basic_filebuf::xsgetn " - "error reading the file")); - __ret += __len; - if (__len == __n) + // Need to loop in case of short reads (relatively common + // with pipes). + streamsize __len; + for (;;) + { + __len = _M_file.xsgetn(reinterpret_cast(__s), + __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_reading = true; -- cgit v1.1