diff options
author | Paolo Carlini <pcarlini@unitus.it> | 2003-06-27 14:33:49 +0200 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2003-06-27 12:33:49 +0000 |
commit | 3461133d7227f31154ca44497a44f1599e4c0aa8 (patch) | |
tree | 867197502c38847a583cb1129372b25e7815176b /libstdc++-v3/include | |
parent | 5648db5461855276e4445804940772c1d9d8fd18 (diff) | |
download | gcc-3461133d7227f31154ca44497a44f1599e4c0aa8.zip gcc-3461133d7227f31154ca44497a44f1599e4c0aa8.tar.gz gcc-3461133d7227f31154ca44497a44f1599e4c0aa8.tar.bz2 |
Nathan C.
2003-06-27 Paolo Carlini <pcarlini@unitus.it>
Nathan C. Myers <ncm-nospam@cantrip.org>
PR libstdc++/9178
* include/bits/fstream.tcc (_M_underflow): Properly estimate
the worst-case number of external bytes for a given get area.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/9178.cc: New.
2003-06-27 Paolo Carlini <pcarlini@unitus.it>
Petur Runolfsson <peturr02@ru.is>
PR libstdc++/11305
* include/bits/fstream.tcc (overflow): Properly estimate the
worst-case number of external bytes for a given put area
(by using codecvt::max_length()).
* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1: New.
* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2: New.
* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3: New.
* testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4: New.
Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org>
Co-Authored-By: Petur Runolfsson <peturr02@ru.is>
From-SVN: r68566
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/fstream.tcc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 1568b60..3d6fb96 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -213,16 +213,19 @@ namespace std } else { - char* __buf = static_cast<char*>(__builtin_alloca(__buflen)); - __elen = _M_file.xsgetn(__buf, __buflen); - - const char* __eend; + // Worst-case number of external bytes. + // XXX Not done encoding() == -1. + const streamsize __blen = __buflen * _M_codecvt->max_length(); + char* __buf = static_cast<char*>(__builtin_alloca(__blen)); + __elen = _M_file.xsgetn(__buf, __blen); + + const char* __eend; char_type* __iend; codecvt_base::result __r; __r = _M_codecvt->in(_M_state_cur, __buf, __buf + __elen, __eend, this->eback(), this->eback() + __buflen, __iend); - if (__r == codecvt_base::ok) + if (__r == codecvt_base::ok || __r == codecvt_base::partial) __ilen = __iend - this->eback(); else if (__r == codecvt_base::noconv) { @@ -391,11 +394,10 @@ namespace std else { // Worst-case number of external bytes needed. - int __ext_multiplier = _M_codecvt->encoding(); - if (__ext_multiplier == -1 || __ext_multiplier == 0) - __ext_multiplier = sizeof(char_type); - streamsize __blen = __ilen * __ext_multiplier; + // XXX Not done encoding() == -1. + streamsize __blen = __ilen * _M_codecvt->max_length(); char* __buf = static_cast<char*>(__builtin_alloca(__blen)); + char* __bend; const char_type* __iend; codecvt_base::result __r; |