diff options
author | kan <kan@FreeBSD.org> | 2006-08-26 21:29:46 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2006-08-26 21:29:46 +0000 |
commit | 42689eaf549f5433a44b3430fb505361a8681778 (patch) | |
tree | 1eea941fcded8f9a67f75fffb3a63b2a4780a0e9 /contrib/libstdc++/include/bits/fstream.tcc | |
parent | ab6c6e434e4ca0bf593007d49dee6eceb73286c0 (diff) | |
download | FreeBSD-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.tcc | 29 |
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; |