aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/fstream.tcc
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@unitus.it>2003-06-28 09:50:29 +0200
committerPaolo Carlini <paolo@gcc.gnu.org>2003-06-28 07:50:29 +0000
commitb417ae14c842723b740591ee78c952778ed5f26b (patch)
tree52e347bd536aee544eea377434e8f4ce399d123c /libstdc++-v3/include/bits/fstream.tcc
parent9756310a6efc9bcf05f0d0996b2d1ee4b6777c51 (diff)
downloadgcc-b417ae14c842723b740591ee78c952778ed5f26b.zip
gcc-b417ae14c842723b740591ee78c952778ed5f26b.tar.gz
gcc-b417ae14c842723b740591ee78c952778ed5f26b.tar.bz2
re PR libstdc++/9875 (filebuf doesn't handle codecvt::encoding() > 1)
2003-06-28 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/9875 * include/bits/fstream.tcc (seekoff): Fix for encoding() > 0. (seekpos): Likewise. * testsuite/27_io/basic_filebuf/seekoff/wchar_t/9875_seekoff.cc: New test. * testsuite/27_io/basic_filebuf/seekpos/wchar_t/9875_seekpos.cc: New test. From-SVN: r68630
Diffstat (limited to 'libstdc++-v3/include/bits/fstream.tcc')
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc17
1 files changed, 13 insertions, 4 deletions
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 3d6fb96..6f585dc 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -486,7 +486,7 @@ namespace std
int __width = 0;
if (_M_codecvt)
- __width = _M_codecvt->encoding();
+ __width = _M_codecvt->encoding();
if (__width < 0)
__width = 0;
@@ -497,7 +497,7 @@ namespace std
_M_destroy_pback();
// Sync the internal and external streams.
- off_type __computed_off = __width * __off;
+ off_type __computed_off = __off;
if (this->pbase() < this->pptr()
|| _M_last_overflowed)
@@ -512,7 +512,8 @@ namespace std
__computed_off += this->gptr() - this->egptr();
// Return pos_type(off_type(-1)) in case of failure.
- __ret = _M_file.seekoff(__computed_off, __way, __mode);
+ __ret = _M_file.seekoff(__computed_off * __width, __way, __mode);
+
_M_reading = false;
_M_writing = false;
_M_set_buffer(-1);
@@ -528,7 +529,15 @@ namespace std
{
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// 171. Strange seekpos() semantics due to joint position
- return this->seekoff(off_type(__pos), ios_base::beg, __mode);
+ pos_type __ret = pos_type(off_type(-1));
+
+ int __width = 0;
+ if (_M_codecvt)
+ __width = _M_codecvt->encoding();
+ if (__width > 0)
+ __ret = this->seekoff(off_type(__pos) / __width, ios_base::beg, __mode);
+
+ return __ret;
#endif
}