00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef _FSTREAM_TCC
00041 #define _FSTREAM_TCC 1
00042
00043 #pragma GCC system_header
00044
00045 namespace std
00046 {
00047 template<typename _CharT, typename _Traits>
00048 void
00049 basic_filebuf<_CharT, _Traits>::
00050 _M_allocate_internal_buffer()
00051 {
00052
00053
00054 if (!_M_buf_allocated && !_M_buf)
00055 {
00056 _M_buf = new char_type[_M_buf_size];
00057 _M_buf_allocated = true;
00058 }
00059 }
00060
00061 template<typename _CharT, typename _Traits>
00062 void
00063 basic_filebuf<_CharT, _Traits>::
00064 _M_destroy_internal_buffer() throw()
00065 {
00066 if (_M_buf_allocated)
00067 {
00068 delete [] _M_buf;
00069 _M_buf = NULL;
00070 _M_buf_allocated = false;
00071 }
00072 delete [] _M_ext_buf;
00073 _M_ext_buf = NULL;
00074 _M_ext_buf_size = 0;
00075 _M_ext_next = NULL;
00076 _M_ext_end = NULL;
00077 }
00078
00079 template<typename _CharT, typename _Traits>
00080 basic_filebuf<_CharT, _Traits>::
00081 basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock),
00082 _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(),
00083 _M_state_last(), _M_buf(NULL), _M_buf_size(BUFSIZ),
00084 _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(),
00085 _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
00086 _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0),
00087 _M_ext_end(0)
00088 {
00089 if (has_facet<__codecvt_type>(this->_M_buf_locale))
00090 _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
00091 }
00092
00093 template<typename _CharT, typename _Traits>
00094 typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
00095 basic_filebuf<_CharT, _Traits>::
00096 open(const char* __s, ios_base::openmode __mode)
00097 {
00098 __filebuf_type *__ret = NULL;
00099 if (!this->is_open())
00100 {
00101 _M_file.open(__s, __mode);
00102 if (this->is_open())
00103 {
00104 _M_allocate_internal_buffer();
00105 _M_mode = __mode;
00106
00107
00108 _M_reading = false;
00109 _M_writing = false;
00110 _M_set_buffer(-1);
00111
00112
00113 _M_state_last = _M_state_cur = _M_state_beg;
00114
00115
00116 if ((__mode & ios_base::ate)
00117 && this->seekoff(0, ios_base::end, __mode)
00118 == pos_type(off_type(-1)))
00119 this->close();
00120 else
00121 __ret = this;
00122 }
00123 }
00124 return __ret;
00125 }
00126
00127 template<typename _CharT, typename _Traits>
00128 typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
00129 basic_filebuf<_CharT, _Traits>::
00130 close() throw()
00131 {
00132 __filebuf_type* __ret = NULL;
00133 if (this->is_open())
00134 {
00135 bool __testfail = false;
00136 try
00137 {
00138 if (!_M_terminate_output())
00139 __testfail = true;
00140 }
00141 catch(...)
00142 { __testfail = true; }
00143
00144
00145 _M_mode = ios_base::openmode(0);
00146 _M_pback_init = false;
00147 _M_destroy_internal_buffer();
00148 _M_reading = false;
00149 _M_writing = false;
00150 _M_set_buffer(-1);
00151 _M_state_last = _M_state_cur = _M_state_beg;
00152
00153 if (!_M_file.close())
00154 __testfail = true;
00155
00156 if (!__testfail)
00157 __ret = this;
00158 }
00159 return __ret;
00160 }
00161
00162 template<typename _CharT, typename _Traits>
00163 streamsize
00164 basic_filebuf<_CharT, _Traits>::
00165 showmanyc()
00166 {
00167 streamsize __ret = -1;
00168 const bool __testin = _M_mode & ios_base::in;
00169 if (__testin && this->is_open())
00170 {
00171
00172
00173 __ret = this->egptr() - this->gptr();
00174 if (__check_facet(_M_codecvt).encoding() >= 0)
00175 __ret += _M_file.showmanyc() / _M_codecvt->max_length();
00176 }
00177 return __ret;
00178 }
00179
00180 template<typename _CharT, typename _Traits>
00181 typename basic_filebuf<_CharT, _Traits>::int_type
00182 basic_filebuf<_CharT, _Traits>::
00183 underflow()
00184 {
00185 int_type __ret = traits_type::eof();
00186 const bool __testin = _M_mode & ios_base::in;
00187 if (__testin && !_M_writing)
00188 {
00189
00190
00191
00192 _M_destroy_pback();
00193
00194 if (this->gptr() < this->egptr())
00195 return traits_type::to_int_type(*this->gptr());
00196
00197
00198 const size_t __buflen = _M_buf_size > 1
00199 ? _M_buf_size - 1 : 1;
00200
00201
00202 bool __got_eof = false;
00203
00204 streamsize __ilen = 0;
00205 codecvt_base::result __r = codecvt_base::ok;
00206 if (__check_facet(_M_codecvt).always_noconv())
00207 {
00208 __ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()),
00209 __buflen);
00210 if (__ilen == 0)
00211 __got_eof = true;
00212 }
00213 else
00214 {
00215
00216
00217 const int __enc = _M_codecvt->encoding();
00218 streamsize __blen;
00219 streamsize __rlen;
00220 if (__enc > 0)
00221 __blen = __rlen = __buflen * __enc;
00222 else
00223 {
00224 __blen = __buflen + _M_codecvt->max_length() - 1;
00225 __rlen = __buflen;
00226 }
00227 const streamsize __remainder = _M_ext_end - _M_ext_next;
00228 __rlen = __rlen > __remainder ? __rlen - __remainder : 0;
00229
00230
00231
00232 if (_M_reading && this->egptr() == this->eback() && __remainder)
00233 __rlen = 0;
00234
00235
00236
00237 if (_M_ext_buf_size < __blen)
00238 {
00239 char* __buf = new char[__blen];
00240 if (__remainder)
00241 std::memcpy(__buf, _M_ext_next, __remainder);
00242
00243 delete [] _M_ext_buf;
00244 _M_ext_buf = __buf;
00245 _M_ext_buf_size = __blen;
00246 }
00247 else if (__remainder)
00248 std::memmove(_M_ext_buf, _M_ext_next, __remainder);
00249
00250 _M_ext_next = _M_ext_buf;
00251 _M_ext_end = _M_ext_buf + __remainder;
00252 _M_state_last = _M_state_cur;
00253
00254 do
00255 {
00256 if (__rlen > 0)
00257 {
00258
00259
00260
00261 if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
00262 {
00263 __throw_ios_failure(__N("basic_filebuf::underflow "
00264 "codecvt::max_length() "
00265 "is not valid"));
00266 }
00267 streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
00268 if (__elen == 0)
00269 __got_eof = true;
00270 else if (__elen == -1)
00271 break;
00272 _M_ext_end += __elen;
00273 }
00274
00275 char_type* __iend;
00276 __r = _M_codecvt->in(_M_state_cur, _M_ext_next,
00277 _M_ext_end, _M_ext_next, this->eback(),
00278 this->eback() + __buflen, __iend);
00279 if (__r == codecvt_base::noconv)
00280 {
00281 size_t __avail = _M_ext_end - _M_ext_buf;
00282 __ilen = std::min(__avail, __buflen);
00283 traits_type::copy(this->eback(),
00284 reinterpret_cast<char_type*>(_M_ext_buf), __ilen);
00285 _M_ext_next = _M_ext_buf + __ilen;
00286 }
00287 else
00288 __ilen = __iend - this->eback();
00289
00290
00291
00292
00293 if (__r == codecvt_base::error)
00294 break;
00295
00296 __rlen = 1;
00297 }
00298 while (__ilen == 0 && !__got_eof);
00299 }
00300
00301 if (__ilen > 0)
00302 {
00303 _M_set_buffer(__ilen);
00304 _M_reading = true;
00305 __ret = traits_type::to_int_type(*this->gptr());
00306 }
00307 else if (__got_eof)
00308 {
00309
00310
00311
00312 _M_set_buffer(-1);
00313 _M_reading = false;
00314
00315
00316 if (__r == codecvt_base::partial)
00317 __throw_ios_failure(__N("basic_filebuf::underflow "
00318 "incomplete character in file"));
00319 }
00320 else if (__r == codecvt_base::error)
00321 __throw_ios_failure(__N("basic_filebuf::underflow "
00322 "invalid byte sequence in file"));
00323 else
00324 __throw_ios_failure(__N("basic_filebuf::underflow "
00325 "error reading the file"));
00326 }
00327 return __ret;
00328 }
00329
00330 template<typename _CharT, typename _Traits>
00331 typename basic_filebuf<_CharT, _Traits>::int_type
00332 basic_filebuf<_CharT, _Traits>::
00333 pbackfail(int_type __i)
00334 {
00335 int_type __ret = traits_type::eof();
00336 const bool __testin = _M_mode & ios_base::in;
00337 if (__testin && !_M_writing)
00338 {
00339
00340
00341 const bool __testpb = _M_pback_init;
00342 const bool __testeof = traits_type::eq_int_type(__i, __ret);
00343 int_type __tmp;
00344 if (this->eback() < this->gptr())
00345 {
00346 this->gbump(-1);
00347 __tmp = traits_type::to_int_type(*this->gptr());
00348 }
00349 else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1)))
00350 {
00351 __tmp = this->underflow();
00352 if (traits_type::eq_int_type(__tmp, __ret))
00353 return __ret;
00354 }
00355 else
00356 {
00357
00358
00359
00360
00361
00362 return __ret;
00363 }
00364
00365
00366
00367 if (!__testeof && traits_type::eq_int_type(__i, __tmp))
00368 __ret = __i;
00369 else if (__testeof)
00370 __ret = traits_type::not_eof(__i);
00371 else if (!__testpb)
00372 {
00373 _M_create_pback();
00374 _M_reading = true;
00375 *this->gptr() = traits_type::to_char_type(__i);
00376 __ret = __i;
00377 }
00378 }
00379 return __ret;
00380 }
00381
00382 template<typename _CharT, typename _Traits>
00383 typename basic_filebuf<_CharT, _Traits>::int_type
00384 basic_filebuf<_CharT, _Traits>::
00385 overflow(int_type __c)
00386 {
00387 int_type __ret = traits_type::eof();
00388 const bool __testeof = traits_type::eq_int_type(__c, __ret);
00389 const bool __testout = _M_mode & ios_base::out;
00390 if (__testout && !_M_reading)
00391 {
00392 if (this->pbase() < this->pptr())
00393 {
00394
00395 if (!__testeof)
00396 {
00397 *this->pptr() = traits_type::to_char_type(__c);
00398 this->pbump(1);
00399 }
00400
00401
00402
00403 if (_M_convert_to_external(this->pbase(),
00404 this->pptr() - this->pbase()))
00405 {
00406 _M_set_buffer(0);
00407 __ret = traits_type::not_eof(__c);
00408 }
00409 }
00410 else if (_M_buf_size > 1)
00411 {
00412
00413
00414
00415 _M_set_buffer(0);
00416 _M_writing = true;
00417 if (!__testeof)
00418 {
00419 *this->pptr() = traits_type::to_char_type(__c);
00420 this->pbump(1);
00421 }
00422 __ret = traits_type::not_eof(__c);
00423 }
00424 else
00425 {
00426
00427 char_type __conv = traits_type::to_char_type(__c);
00428 if (__testeof || _M_convert_to_external(&__conv, 1))
00429 {
00430 _M_writing = true;
00431 __ret = traits_type::not_eof(__c);
00432 }
00433 }
00434 }
00435 return __ret;
00436 }
00437
00438 template<typename _CharT, typename _Traits>
00439 bool
00440 basic_filebuf<_CharT, _Traits>::
00441 _M_convert_to_external(_CharT* __ibuf, streamsize __ilen)
00442 {
00443
00444 streamsize __elen;
00445 streamsize __plen;
00446 if (__check_facet(_M_codecvt).always_noconv())
00447 {
00448 __elen = _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
00449 __plen = __ilen;
00450 }
00451 else
00452 {
00453
00454
00455 streamsize __blen = __ilen * _M_codecvt->max_length();
00456 char* __buf = static_cast<char*>(__builtin_alloca(__blen));
00457
00458 char* __bend;
00459 const char_type* __iend;
00460 codecvt_base::result __r;
00461 __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen,
00462 __iend, __buf, __buf + __blen, __bend);
00463
00464 if (__r == codecvt_base::ok || __r == codecvt_base::partial)
00465 __blen = __bend - __buf;
00466 else if (__r == codecvt_base::noconv)
00467 {
00468
00469 __buf = reinterpret_cast<char*>(__ibuf);
00470 __blen = __ilen;
00471 }
00472 else
00473 __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external "
00474 "conversion error"));
00475
00476 __elen = _M_file.xsputn(__buf, __blen);
00477 __plen = __blen;
00478
00479
00480 if (__r == codecvt_base::partial && __elen == __plen)
00481 {
00482 const char_type* __iresume = __iend;
00483 streamsize __rlen = this->pptr() - __iend;
00484 __r = _M_codecvt->out(_M_state_cur, __iresume,
00485 __iresume + __rlen, __iend, __buf,
00486 __buf + __blen, __bend);
00487 if (__r != codecvt_base::error)
00488 {
00489 __rlen = __bend - __buf;
00490 __elen = _M_file.xsputn(__buf, __rlen);
00491 __plen = __rlen;
00492 }
00493 else
00494 __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external "
00495 "conversion error"));
00496 }
00497 }
00498 return __elen == __plen;
00499 }
00500
00501 template<typename _CharT, typename _Traits>
00502 streamsize
00503 basic_filebuf<_CharT, _Traits>::
00504 xsgetn(_CharT* __s, streamsize __n)
00505 {
00506
00507 streamsize __ret = 0;
00508 if (_M_pback_init)
00509 {
00510 if (__n > 0 && this->gptr() == this->eback())
00511 {
00512 *__s++ = *this->gptr();
00513 this->gbump(1);
00514 __ret = 1;
00515 --__n;
00516 }
00517 _M_destroy_pback();
00518 }
00519
00520
00521
00522
00523 const bool __testin = _M_mode & ios_base::in;
00524 const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1
00525 : 1;
00526 if (__n > __buflen && __check_facet(_M_codecvt).always_noconv()
00527 && __testin && !_M_writing)
00528 {
00529
00530 const streamsize __avail = this->egptr() - this->gptr();
00531 if (__avail != 0)
00532 {
00533 if (__avail == 1)
00534 *__s = *this->gptr();
00535 else
00536 traits_type::copy(__s, this->gptr(), __avail);
00537 __s += __avail;
00538 this->gbump(__avail);
00539 __ret += __avail;
00540 __n -= __avail;
00541 }
00542
00543 const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s),
00544 __n);
00545 if (__len == -1)
00546 __throw_ios_failure(__N("basic_filebuf::xsgetn "
00547 "error reading the file"));
00548 __ret += __len;
00549 if (__len == __n)
00550 {
00551 _M_set_buffer(0);
00552 _M_reading = true;
00553 }
00554 else if (__len == 0)
00555 {
00556
00557
00558
00559 _M_set_buffer(-1);
00560 _M_reading = false;
00561 }
00562 }
00563 else
00564 __ret += __streambuf_type::xsgetn(__s, __n);
00565
00566 return __ret;
00567 }
00568
00569 template<typename _CharT, typename _Traits>
00570 streamsize
00571 basic_filebuf<_CharT, _Traits>::
00572 xsputn(const _CharT* __s, streamsize __n)
00573 {
00574
00575
00576
00577 streamsize __ret = 0;
00578 const bool __testout = _M_mode & ios_base::out;
00579 if (__check_facet(_M_codecvt).always_noconv()
00580 && __testout && !_M_reading)
00581 {
00582
00583 const streamsize __chunk = 1ul << 10;
00584 streamsize __bufavail = this->epptr() - this->pptr();
00585
00586
00587 if (!_M_writing && _M_buf_size > 1)
00588 __bufavail = _M_buf_size - 1;
00589
00590 const streamsize __limit = std::min(__chunk, __bufavail);
00591 if (__n >= __limit)
00592 {
00593 const streamsize __buffill = this->pptr() - this->pbase();
00594 const char* __buf = reinterpret_cast<const char*>(this->pbase());
00595 __ret = _M_file.xsputn_2(__buf, __buffill,
00596 reinterpret_cast<const char*>(__s),
00597 __n);
00598 if (__ret == __buffill + __n)
00599 {
00600 _M_set_buffer(0);
00601 _M_writing = true;
00602 }
00603 if (__ret > __buffill)
00604 __ret -= __buffill;
00605 else
00606 __ret = 0;
00607 }
00608 else
00609 __ret = __streambuf_type::xsputn(__s, __n);
00610 }
00611 else
00612 __ret = __streambuf_type::xsputn(__s, __n);
00613 return __ret;
00614 }
00615
00616 template<typename _CharT, typename _Traits>
00617 typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
00618 basic_filebuf<_CharT, _Traits>::
00619 setbuf(char_type* __s, streamsize __n)
00620 {
00621 if (!this->is_open())
00622 if (__s == 0 && __n == 0)
00623 _M_buf_size = 1;
00624 else if (__s && __n > 0)
00625 {
00626
00627
00628
00629
00630
00631
00632
00633
00634 _M_buf = __s;
00635 _M_buf_size = __n;
00636 }
00637 return this;
00638 }
00639
00640
00641
00642
00643 template<typename _CharT, typename _Traits>
00644 typename basic_filebuf<_CharT, _Traits>::pos_type
00645 basic_filebuf<_CharT, _Traits>::
00646 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
00647 {
00648 int __width = 0;
00649 if (_M_codecvt)
00650 __width = _M_codecvt->encoding();
00651 if (__width < 0)
00652 __width = 0;
00653
00654 pos_type __ret = pos_type(off_type(-1));
00655 const bool __testfail = __off != 0 && __width <= 0;
00656 if (this->is_open() && !__testfail)
00657 {
00658
00659 _M_destroy_pback();
00660
00661
00662
00663
00664
00665
00666 __state_type __state = _M_state_beg;
00667 off_type __computed_off = __off * __width;
00668 if (_M_reading && __way == ios_base::cur)
00669 {
00670 if (_M_codecvt->always_noconv())
00671 __computed_off += this->gptr() - this->egptr();
00672 else
00673 {
00674
00675
00676
00677 const int __gptr_off =
00678 _M_codecvt->length(_M_state_last, _M_ext_buf, _M_ext_next,
00679 this->gptr() - this->eback());
00680 __computed_off += _M_ext_buf + __gptr_off - _M_ext_end;
00681
00682
00683
00684 __state = _M_state_last;
00685 }
00686 }
00687 __ret = _M_seek(__computed_off, __way, __state);
00688 }
00689 return __ret;
00690 }
00691
00692
00693
00694
00695
00696 template<typename _CharT, typename _Traits>
00697 typename basic_filebuf<_CharT, _Traits>::pos_type
00698 basic_filebuf<_CharT, _Traits>::
00699 seekpos(pos_type __pos, ios_base::openmode)
00700 {
00701 pos_type __ret = pos_type(off_type(-1));
00702 if (this->is_open())
00703 {
00704
00705 _M_destroy_pback();
00706 __ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state());
00707 }
00708 return __ret;
00709 }
00710
00711 template<typename _CharT, typename _Traits>
00712 typename basic_filebuf<_CharT, _Traits>::pos_type
00713 basic_filebuf<_CharT, _Traits>::
00714 _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state)
00715 {
00716 pos_type __ret = pos_type(off_type(-1));
00717 if (_M_terminate_output())
00718 {
00719
00720 __ret = pos_type(_M_file.seekoff(__off, __way));
00721 _M_reading = false;
00722 _M_writing = false;
00723 _M_ext_next = _M_ext_end = _M_ext_buf;
00724 _M_set_buffer(-1);
00725 _M_state_cur = __state;
00726 __ret.state(_M_state_cur);
00727 }
00728 return __ret;
00729 }
00730
00731 template<typename _CharT, typename _Traits>
00732 bool
00733 basic_filebuf<_CharT, _Traits>::
00734 _M_terminate_output()
00735 {
00736
00737 bool __testvalid = true;
00738 if (this->pbase() < this->pptr())
00739 {
00740 const int_type __tmp = this->overflow();
00741 if (traits_type::eq_int_type(__tmp, traits_type::eof()))
00742 __testvalid = false;
00743 }
00744
00745
00746 if (_M_writing && !__check_facet(_M_codecvt).always_noconv()
00747 && __testvalid)
00748 {
00749
00750
00751
00752 const size_t __blen = 128;
00753 char __buf[__blen];
00754 codecvt_base::result __r;
00755 streamsize __ilen = 0;
00756
00757 do
00758 {
00759 char* __next;
00760 __r = _M_codecvt->unshift(_M_state_cur, __buf,
00761 __buf + __blen, __next);
00762 if (__r == codecvt_base::error)
00763 __testvalid = false;
00764 else if (__r == codecvt_base::ok ||
00765 __r == codecvt_base::partial)
00766 {
00767 __ilen = __next - __buf;
00768 if (__ilen > 0)
00769 {
00770 const streamsize __elen = _M_file.xsputn(__buf, __ilen);
00771 if (__elen != __ilen)
00772 __testvalid = false;
00773 }
00774 }
00775 }
00776 while (__r == codecvt_base::partial && __ilen > 0 && __testvalid);
00777
00778 if (__testvalid)
00779 {
00780
00781
00782
00783
00784 const int_type __tmp = this->overflow();
00785 if (traits_type::eq_int_type(__tmp, traits_type::eof()))
00786 __testvalid = false;
00787 }
00788 }
00789 return __testvalid;
00790 }
00791
00792 template<typename _CharT, typename _Traits>
00793 int
00794 basic_filebuf<_CharT, _Traits>::
00795 sync()
00796 {
00797
00798
00799 int __ret = 0;
00800 if (this->pbase() < this->pptr())
00801 {
00802 const int_type __tmp = this->overflow();
00803 if (traits_type::eq_int_type(__tmp, traits_type::eof()))
00804 __ret = -1;
00805 }
00806 return __ret;
00807 }
00808
00809 template<typename _CharT, typename _Traits>
00810 void
00811 basic_filebuf<_CharT, _Traits>::
00812 imbue(const locale& __loc)
00813 {
00814 bool __testvalid = true;
00815
00816 const __codecvt_type* _M_codecvt_tmp = 0;
00817 if (__builtin_expect(has_facet<__codecvt_type>(__loc), true))
00818 _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc);
00819
00820 if (this->is_open())
00821 {
00822
00823 if ((_M_reading || _M_writing)
00824 && __check_facet(_M_codecvt).encoding() == -1)
00825 __testvalid = false;
00826 else
00827 {
00828 if (_M_reading)
00829 {
00830 if (__check_facet(_M_codecvt).always_noconv())
00831 {
00832 if (_M_codecvt_tmp
00833 && !__check_facet(_M_codecvt_tmp).always_noconv())
00834 __testvalid = this->seekoff(0, ios_base::cur, _M_mode)
00835 != pos_type(off_type(-1));
00836 }
00837 else
00838 {
00839
00840 _M_ext_next = _M_ext_buf
00841 + _M_codecvt->length(_M_state_last, _M_ext_buf, _M_ext_next,
00842 this->gptr() - this->eback());
00843 const streamsize __remainder = _M_ext_end - _M_ext_next;
00844 if (__remainder)
00845 std::memmove(_M_ext_buf, _M_ext_next, __remainder);
00846
00847 _M_ext_next = _M_ext_buf;
00848 _M_ext_end = _M_ext_buf + __remainder;
00849 _M_set_buffer(-1);
00850 _M_state_last = _M_state_cur = _M_state_beg;
00851 }
00852 }
00853 else if (_M_writing && (__testvalid = _M_terminate_output()))
00854 _M_set_buffer(-1);
00855 }
00856 }
00857
00858 if (__testvalid)
00859 _M_codecvt = _M_codecvt_tmp;
00860 else
00861 _M_codecvt = 0;
00862 }
00863
00864
00865
00866
00867 #if _GLIBCXX_EXTERN_TEMPLATE
00868 extern template class basic_filebuf<char>;
00869 extern template class basic_ifstream<char>;
00870 extern template class basic_ofstream<char>;
00871 extern template class basic_fstream<char>;
00872
00873 #ifdef _GLIBCXX_USE_WCHAR_T
00874 extern template class basic_filebuf<wchar_t>;
00875 extern template class basic_ifstream<wchar_t>;
00876 extern template class basic_ofstream<wchar_t>;
00877 extern template class basic_fstream<wchar_t>;
00878 #endif
00879 #endif
00880 }
00881
00882 #endif