diff options
author | Nathan Myers <ncm@cantrip.org> | 2004-09-14 19:11:46 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-09-14 19:11:46 +0000 |
commit | d1768069410858ba003f30461ec95198d25a43ae (patch) | |
tree | 0ad7b944550789448e1afa7348a8bbc7e79e4017 | |
parent | 3b53cddc38abb716ac6b300d68cfe841a3a4f265 (diff) | |
download | gcc-d1768069410858ba003f30461ec95198d25a43ae.zip gcc-d1768069410858ba003f30461ec95198d25a43ae.tar.gz gcc-d1768069410858ba003f30461ec95198d25a43ae.tar.bz2 |
fstream.tcc (xsgetn): Slightly tweak the recent fix for 11722...
2004-09-14 Nathan Myers <ncm@cantrip.org>
* include/bits/fstream.tcc (xsgetn): Slightly tweak the recent fix
for 11722: copy can replace move; the common case is __avail == 0.
From-SVN: r87501
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/fstream.tcc | 19 |
2 files changed, 16 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7991951..8b52da2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2004-09-14 Nathan Myers <ncm@cantrip.org> + + * include/bits/fstream.tcc (xsgetn): Slightly tweak the recent fix + for 11722: copy can replace move; the common case is __avail == 0. + 2004-09-14 Paolo Carlini <pcarlini@suse.de> * include/bits/cpp_type_traits.h: Rename __is_trivially_copyable diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 542dc6e..c24d4ca 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -524,14 +524,17 @@ namespace std { // First, copy the chars already present in the buffer. const streamsize __avail = this->egptr() - this->gptr(); - if (__avail == 1) - *__s = *this->gptr(); - else if (__avail > 1) - traits_type::move(__s, this->gptr(), __avail); - __s += __avail; - this->gbump(__avail); - __ret += __avail; - __n -= __avail; + if (__avail != 0) + { + if (__avail == 1) + *__s = *this->gptr(); + else if (__avail > 1) + traits_type::copy(__s, this->gptr(), __avail); + __s += __avail; + this->gbump(__avail); + __ret += __avail; + __n -= __avail; + } const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s), __n); |