summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/include/bits/fstream.tcc
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2006-08-26 21:29:46 +0000
committerkan <kan@FreeBSD.org>2006-08-26 21:29:46 +0000
commit42689eaf549f5433a44b3430fb505361a8681778 (patch)
tree1eea941fcded8f9a67f75fffb3a63b2a4780a0e9 /contrib/libstdc++/include/bits/fstream.tcc
parentab6c6e434e4ca0bf593007d49dee6eceb73286c0 (diff)
downloadFreeBSD-src-42689eaf549f5433a44b3430fb505361a8681778.zip
FreeBSD-src-42689eaf549f5433a44b3430fb505361a8681778.tar.gz
Gcc 3.4.6 C++ support bits (as of 2006/08/25 #116475).
Diffstat (limited to 'contrib/libstdc++/include/bits/fstream.tcc')
-rw-r--r--contrib/libstdc++/include/bits/fstream.tcc29
1 files changed, 22 insertions, 7 deletions
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<char*>(__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<char*>(__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;
OpenPOWER on IntegriCloud