diff options
Diffstat (limited to 'libstdc++-v3/include/bits/fstream.tcc')
-rw-r--r-- | libstdc++-v3/include/bits/fstream.tcc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 22a24dc..1568b60 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -215,7 +215,7 @@ namespace std { char* __buf = static_cast<char*>(__builtin_alloca(__buflen)); __elen = _M_file.xsgetn(__buf, __buflen); - + const char* __eend; char_type* __iend; codecvt_base::result __r; @@ -246,7 +246,15 @@ namespace std __ret = traits_type::to_int_type(*this->gptr()); if (__bump) this->gbump(1); - } + } + else if (__elen == 0) + { + // If the actual end of file is reached, set 'uncommitted' + // mode, thus allowing an immediate write without an + // intervening seek. + _M_set_buffer(-1); + _M_reading = false; + } } _M_last_overflowed = false; return __ret; |