Commit e5f7b16f4b419f75e48e4a920d1b830a596e27e0

  • avatar
  • dums <dums @01b27279-081b-0410…d9d9e0fb0389.>
  • Sun Jan 13 11:12:03 CET 2008
  • Tree SHA1: b720881
  • Parent SHA1: 67a9bb5 (On HPUX IA64 gcc have <wchar.h> and <cwchar> files, but they are conflict with <stl/_mbstate_t.h>; patch #1868233)
  • raw diff | raw patch
Complete bug #1854345 bug fix as already done in trunk. Moreover, an other SVN trunk bug fix has been integrated. We now try to convert already read buffer even if latest file read failed.

git-svn-id: https://stlport.svn.sourceforge.net/svnroot/stlport/branches/STLPORT_5_1/STLport@3386 01b27279-081b-0410-8cf9-d9d9e0fb0389
  
12008-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
182008-01-11 Petr Ovtchenkov <complement@users.sourceforge.net>
29
310 * src/num_put_float.cpp, stlport/stl/_cstdlib.h, stlport/stl/config/_hpux.h:
  
11511151 && __this->_M_always_noconv
11521152 && __this->_M_base._M_in_binary_mode()) {
11531153 // If we've mmapped part of the file already, then unmap it.
1154 if (__this->_M_mmap_base) {
1154 if (__this->_M_mmap_base)
11551155 __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 }
11601156
11611157 // Determine the position where we start mapping. It has to be
11621158 // a multiple of the page size.
11751175 return traits_type::to_int_type(*__this->gptr());
11761176 } else
11771177 __this->_M_mmap_len = 0;
1178 }
1179 else {
1180 __this->_M_mmap_base = 0;
1181 __this->_M_mmap_len = 0;
11781182 }
11791183 }
11801184
  
499499 // to make progress.
500500 for (;;) {
501501 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;
502503
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);
506507 return traits_type::eof();
508 }
507509
508510 // Convert the external buffer to internal characters.
509 _M_ext_buf_end += __n;
510 const char* __enext;
511 const char* __enext;
511512 _CharT* __inext;
512513
513514 typename _Codecvt::result __status
516516 _M_ext_buf, _M_ext_buf_end, __enext,
517517 _M_int_buf, _M_int_buf_EOS, __inext);
518518
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. */
525527 if (__status == _Codecvt::noconv)
526528 return _Noconv_input<_Traits>::_M_doit(this);
527529 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))
533533 return _M_input_error();
534534 else if (__inext != _M_int_buf) {
535535 _M_ext_buf_converted = _M_ext_buf + (__enext - _M_ext_buf);
536536 this->setg(_M_int_buf, _M_int_buf, __inext);
537537 return traits_type::to_int_type(*_M_int_buf);
538538 }
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 }
540547 }
541548}
542549