Commit e5f7b16f4b419f75e48e4a920d1b830a596e27e0
- Diff rendering mode:
- inline
- side by side
etc/ChangeLog-5.1
(7 / 0)
|   | |||
| 1 | 2008-01-13 Francois Dumont <dums@users.sourceforge.net> | ||
| 2 | |||
| 3 | * src/fstream.cpp, stlport/stl/_fstream.c: Complete bug #1854345 | ||
| 4 | fix as already done in SVN trunk. Moreover, an other SVN trunk bug | ||
| 5 | fix has been integrated. We now try to convert already read buffer | ||
| 6 | even if latest file read failed. | ||
| 7 | |||
| 1 | 8 | 2008-01-11 Petr Ovtchenkov <complement@users.sourceforge.net> | |
| 2 | 9 | ||
| 3 | 10 | * src/num_put_float.cpp, stlport/stl/_cstdlib.h, stlport/stl/config/_hpux.h: |
src/fstream.cpp
(5 / 5)
|   | |||
| 1151 | 1151 | && __this->_M_always_noconv | |
| 1152 | 1152 | && __this->_M_base._M_in_binary_mode()) { | |
| 1153 | 1153 | // If we've mmapped part of the file already, then unmap it. | |
| 1154 | if (__this->_M_mmap_base) { | ||
| 1154 | if (__this->_M_mmap_base) | ||
| 1155 | 1155 | __this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len); | |
| 1156 | __this->_M_mmap_base = 0; | ||
| 1157 | __this->_M_mmap_len = 0; | ||
| 1158 | __this->setg(__STATIC_CAST(char*, 0), __STATIC_CAST(char*, 0), __STATIC_CAST(char*, 0)); | ||
| 1159 | } | ||
| 1160 | 1156 | ||
| 1161 | 1157 | // Determine the position where we start mapping. It has to be | |
| 1162 | 1158 | // a multiple of the page size. | |
| … | … | ||
| 1175 | 1175 | return traits_type::to_int_type(*__this->gptr()); | |
| 1176 | 1176 | } else | |
| 1177 | 1177 | __this->_M_mmap_len = 0; | |
| 1178 | } | ||
| 1179 | else { | ||
| 1180 | __this->_M_mmap_base = 0; | ||
| 1181 | __this->_M_mmap_len = 0; | ||
| 1178 | 1182 | } | |
| 1179 | 1183 | } | |
| 1180 | 1184 |
stlport/stl/_fstream.c
(25 / 17)
|   | |||
| 499 | 499 | // to make progress. | |
| 500 | 500 | for (;;) { | |
| 501 | 501 | ptrdiff_t __n = _M_base._M_read(_M_ext_buf_end, _M_ext_buf_EOS - _M_ext_buf_end); | |
| 502 | _M_ext_buf_end += __n; | ||
| 502 | 503 | ||
| 503 | // Don't enter error mode for a failed read. Error mode is sticky, | ||
| 504 | // and we might succeed if we try again. | ||
| 505 | if (__n <= 0) | ||
| 504 | // If external buffer is empty there is nothing to do. | ||
| 505 | if (_M_ext_buf == _M_ext_buf_end) { | ||
| 506 | this->setg(0, 0, 0); | ||
| 506 | 507 | return traits_type::eof(); | |
| 508 | } | ||
| 507 | 509 | ||
| 508 | 510 | // Convert the external buffer to internal characters. | |
| 509 | _M_ext_buf_end += __n; | ||
| 510 | const char* __enext; | ||
| 511 | const char* __enext; | ||
| 511 | 512 | _CharT* __inext; | |
| 512 | 513 | ||
| 513 | 514 | typename _Codecvt::result __status | |
| … | … | ||
| 516 | 516 | _M_ext_buf, _M_ext_buf_end, __enext, | |
| 517 | 517 | _M_int_buf, _M_int_buf_EOS, __inext); | |
| 518 | 518 | ||
| 519 | // Error conditions: (1) Return value of error. (2) Producing internal | ||
| 520 | // characters without consuming external characters. (3) In fixed-width | ||
| 521 | // encodings, producing an internal sequence whose length is inconsistent | ||
| 522 | // with that of the internal sequence. (4) Failure to produce any | ||
| 523 | // characters if we have enough characters in the external buffer, where | ||
| 524 | // "enough" means the largest possible width of a single character. | ||
| 519 | /* Error conditions: | ||
| 520 | * (1) Return value of error. | ||
| 521 | * (2) Producing internal characters without consuming external characters. | ||
| 522 | * (3) In fixed-width encodings, producing an internal sequence whose length | ||
| 523 | * is inconsistent with that of the internal sequence. | ||
| 524 | * (4) Failure to produce any characters if we have enough characters in | ||
| 525 | * the external buffer, where "enough" means the largest possible width | ||
| 526 | * of a single character. */ | ||
| 525 | 527 | if (__status == _Codecvt::noconv) | |
| 526 | 528 | return _Noconv_input<_Traits>::_M_doit(this); | |
| 527 | 529 | else if (__status == _Codecvt::error || | |
| 528 | (__inext != _M_int_buf && __enext == _M_ext_buf) || | ||
| 529 | (_M_constant_width && | ||
| 530 | // __inext - _M_int_buf != _M_width * (__enext - _M_ext_buf)) || | ||
| 531 | (__inext - _M_int_buf) * _M_width != (__enext - _M_ext_buf)) || | ||
| 532 | (__inext == _M_int_buf && __enext - _M_ext_buf >= _M_max_width)) | ||
| 530 | (__inext != _M_int_buf && __enext == _M_ext_buf) || | ||
| 531 | (_M_constant_width && (__inext - _M_int_buf) * _M_width != (__enext - _M_ext_buf)) || | ||
| 532 | (__inext == _M_int_buf && __enext - _M_ext_buf >= _M_max_width)) | ||
| 533 | 533 | return _M_input_error(); | |
| 534 | 534 | else if (__inext != _M_int_buf) { | |
| 535 | 535 | _M_ext_buf_converted = _M_ext_buf + (__enext - _M_ext_buf); | |
| 536 | 536 | this->setg(_M_int_buf, _M_int_buf, __inext); | |
| 537 | 537 | return traits_type::to_int_type(*_M_int_buf); | |
| 538 | 538 | } | |
| 539 | // We need to go around the loop again to get more external characters. | ||
| 539 | /* We need to go around the loop again to get more external characters. | ||
| 540 | * But if the previous read failed then don't try again for now. | ||
| 541 | * Don't enter error mode for a failed read. Error mode is sticky, | ||
| 542 | * and we might succeed if we try again. */ | ||
| 543 | if (__n <= 0) { | ||
| 544 | this->setg(0, 0, 0); | ||
| 545 | return traits_type::eof(); | ||
| 546 | } | ||
| 540 | 547 | } | |
| 541 | 548 | } | |
| 542 | 549 |

