diff options
Diffstat (limited to 'libstdc++-v3/include/bits/fstream.tcc')
-rw-r--r-- | libstdc++-v3/include/bits/fstream.tcc | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index f28160cec94..9022b582594 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -73,20 +73,20 @@ namespace std template<typename _CharT, typename _Traits> basic_filebuf<_CharT, _Traits>:: - basic_filebuf() : __streambuf_type(), _M_file(&_M_lock), + basic_filebuf() : __streambuf_type(), _M_file(&_M_lock), _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(), _M_state_last(), _M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false), _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0), _M_ext_end(0) - { + { if (has_facet<__codecvt_type>(this->_M_buf_locale)) _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale); } template<typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::__filebuf_type* + typename basic_filebuf<_CharT, _Traits>::__filebuf_type* basic_filebuf<_CharT, _Traits>:: open(const char* __s, ios_base::openmode __mode) { @@ -108,8 +108,8 @@ namespace std _M_state_last = _M_state_cur = _M_state_beg; // 27.8.1.3,4 - if ((__mode & ios_base::ate) - && this->seekoff(0, ios_base::end, __mode) + if ((__mode & ios_base::ate) + && this->seekoff(0, ios_base::end, __mode) == pos_type(off_type(-1))) this->close(); else @@ -120,7 +120,7 @@ namespace std } template<typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::__filebuf_type* + typename basic_filebuf<_CharT, _Traits>::__filebuf_type* basic_filebuf<_CharT, _Traits>:: close() throw() { @@ -135,7 +135,7 @@ namespace std } catch(...) { __testfail = true; } - + // NB: Do this here so that re-opened filebufs will be cool... this->_M_mode = ios_base::openmode(0); this->_M_pback_init = false; @@ -144,7 +144,7 @@ namespace std _M_writing = false; _M_set_buffer(-1); _M_state_last = _M_state_cur = _M_state_beg; - + if (!_M_file.close()) __testfail = true; @@ -155,7 +155,7 @@ namespace std } template<typename _CharT, typename _Traits> - streamsize + streamsize basic_filebuf<_CharT, _Traits>:: showmanyc() { @@ -173,7 +173,7 @@ namespace std } template<typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::int_type + typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>:: underflow() { @@ -192,15 +192,15 @@ namespace std // Get and convert input sequence. const size_t __buflen = this->_M_buf_size > 1 ? this->_M_buf_size - 1 : 1; - + // Will be set to true if ::read() returns 0 indicating EOF. bool __got_eof = false; // Number of internal characters produced. streamsize __ilen = 0; - codecvt_base::result __r = codecvt_base::ok; + codecvt_base::result __r = codecvt_base::ok; if (__check_facet(_M_codecvt).always_noconv()) { - __ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()), + __ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()), __buflen); if (__ilen == 0) __got_eof = true; @@ -226,7 +226,7 @@ namespace std // chars already present. if (_M_reading && this->egptr() == this->eback() && __remainder) __rlen = 0; - + // Allocate buffer if necessary and move unconverted // bytes to front. if (_M_ext_buf_size < __blen) @@ -269,7 +269,7 @@ namespace std char_type* __iend; __r = _M_codecvt->in(_M_state_cur, _M_ext_next, - _M_ext_end, _M_ext_next, this->eback(), + _M_ext_end, _M_ext_next, this->eback(), this->eback() + __buflen, __iend); if (__r == codecvt_base::noconv) { @@ -302,7 +302,7 @@ namespace std else if (__got_eof) { // If the actual end of file is reached, set 'uncommitted' - // mode, thus allowing an immediate write without an + // mode, thus allowing an immediate write without an // intervening seek. _M_set_buffer(-1); _M_reading = false; @@ -317,13 +317,13 @@ namespace std "invalid byte sequence in file")); else __throw_ios_failure(__N("basic_filebuf::underflow " - "error reading the file")); + "error reading the file")); } return __ret; } template<typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::int_type + typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>:: pbackfail(int_type __i) { @@ -333,7 +333,7 @@ namespace std { // Remember whether the pback buffer is active, otherwise below // we may try to store in it a second char (libstdc++/9761). - const bool __testpb = this->_M_pback_init; + const bool __testpb = this->_M_pback_init; const bool __testeof = traits_type::eq_int_type(__i, __ret); int_type __tmp; if (this->eback() < this->gptr()) @@ -367,7 +367,7 @@ namespace std { _M_create_pback(); _M_reading = true; - *this->gptr() = traits_type::to_char_type(__i); + *this->gptr() = traits_type::to_char_type(__i); __ret = __i; } } @@ -375,7 +375,7 @@ namespace std } template<typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::int_type + typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>:: overflow(int_type __c) { @@ -392,7 +392,7 @@ namespace std *this->pptr() = traits_type::to_char_type(__c); this->pbump(1); } - + // Convert pending sequence to external representation, // and output. if (_M_convert_to_external(this->pbase(), @@ -422,7 +422,7 @@ namespace std // Unbuffered. char_type __conv = traits_type::to_char_type(__c); if (__testeof || _M_convert_to_external(&__conv, 1)) - { + { _M_writing = true; __ret = traits_type::not_eof(__c); } @@ -430,7 +430,7 @@ namespace std } return __ret; } - + template<typename _CharT, typename _Traits> bool basic_filebuf<_CharT, _Traits>:: @@ -456,7 +456,7 @@ namespace std codecvt_base::result __r; __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, __iend, __buf, __buf + __blen, __bend); - + if (__r == codecvt_base::ok || __r == codecvt_base::partial) __blen = __bend - __buf; else if (__r == codecvt_base::noconv) @@ -470,20 +470,20 @@ namespace std // Result == error. __blen = 0; } - + if (__blen) { __elen += _M_file.xsputn(__buf, __blen); __plen += __blen; } - + // Try once more for partial conversions. if (__r == codecvt_base::partial) { const char_type* __iresume = __iend; streamsize __rlen = this->pptr() - __iend; __r = _M_codecvt->out(_M_state_cur, __iresume, - __iresume + __rlen, __iend, __buf, + __iresume + __rlen, __iend, __buf, __buf + __blen, __bend); if (__r != codecvt_base::error) { @@ -500,7 +500,7 @@ namespace std streamsize basic_filebuf<_CharT, _Traits>:: xsputn(const _CharT* __s, streamsize __n) - { + { // Optimization in the always_noconv() case, to be generalized in the // future: when __n is sufficiently large we write directly instead of // using the buffer. @@ -523,7 +523,7 @@ namespace std const streamsize __buffill = this->pptr() - this->pbase(); const char* __buf = reinterpret_cast<const char*>(this->pbase()); __ret = _M_file.xsputn_2(__buf, __buffill, - reinterpret_cast<const char*>(__s), + reinterpret_cast<const char*>(__s), __n); if (__ret == __buffill + __n) { @@ -539,12 +539,12 @@ namespace std __ret = __streambuf_type::xsputn(__s, __n); } else - __ret = __streambuf_type::xsputn(__s, __n); + __ret = __streambuf_type::xsputn(__s, __n); return __ret; } template<typename _CharT, typename _Traits> - typename basic_filebuf<_CharT, _Traits>::__streambuf_type* + typename basic_filebuf<_CharT, _Traits>::__streambuf_type* basic_filebuf<_CharT, _Traits>:: setbuf(char_type* __s, streamsize __n) { @@ -564,9 +564,9 @@ namespace std this->_M_buf = __s; this->_M_buf_size = __n; } - return this; + return this; } - + // According to 27.8.1.4 p11 - 13, seekoff should ignore the last // argument (of type openmode). @@ -581,9 +581,9 @@ namespace std if (__width < 0) __width = 0; - pos_type __ret = pos_type(off_type(-1)); + pos_type __ret = pos_type(off_type(-1)); const bool __testfail = __off != 0 && __width <= 0; - if (this->is_open() && !__testfail) + if (this->is_open() && !__testfail) { // Ditch any pback buffers to avoid confusion. _M_destroy_pback(); @@ -608,10 +608,10 @@ namespace std _M_codecvt->length(_M_state_last, _M_ext_buf, _M_ext_next, this->gptr() - this->eback()); __computed_off += _M_ext_buf + __gptr_off - _M_ext_end; - + // _M_state_last is modified by codecvt::length() so - // it now corresponds to gptr(). - __state = _M_state_last; + // it now corresponds to gptr(). + __state = _M_state_last; } } __ret = _M_seek(__computed_off, __way, __state); @@ -628,8 +628,8 @@ namespace std basic_filebuf<_CharT, _Traits>:: seekpos(pos_type __pos, ios_base::openmode) { - pos_type __ret = pos_type(off_type(-1)); - if (this->is_open()) + pos_type __ret = pos_type(off_type(-1)); + if (this->is_open()) { // Ditch any pback buffers to avoid confusion. _M_destroy_pback(); @@ -645,9 +645,9 @@ namespace std { pos_type __ret = pos_type(off_type(-1)); if (_M_terminate_output()) - { + { // Returns pos_type(off_type(-1)) in case of failure. - __ret = pos_type(_M_file.seekoff(__off, __way)); + __ret = pos_type(_M_file.seekoff(__off, __way)); _M_reading = false; _M_writing = false; _M_ext_next = _M_ext_end = _M_ext_buf; @@ -671,9 +671,9 @@ namespace std if (traits_type::eq_int_type(__tmp, traits_type::eof())) __testvalid = false; } - + // Part two: output unshift sequence. - if (_M_writing && !__check_facet(_M_codecvt).always_noconv() + if (_M_writing && !__check_facet(_M_codecvt).always_noconv() && __testvalid) { // Note: this value is arbitrary, since there is no way to @@ -694,7 +694,7 @@ namespace std else if (__r == codecvt_base::ok || __r == codecvt_base::partial) { - __ilen = __next - __buf; + __ilen = __next - __buf; if (__ilen > 0) { const streamsize __elen = _M_file.xsputn(__buf, __ilen); @@ -733,7 +733,7 @@ namespace std const int_type __tmp = this->overflow(); if (traits_type::eq_int_type(__tmp, traits_type::eof())) __ret = -1; - } + } return __ret; } @@ -745,8 +745,8 @@ namespace std bool __testvalid = true; const __codecvt_type* _M_codecvt_tmp = 0; - if (__builtin_expect(has_facet<__codecvt_type>(__loc), true)) - _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc); + if (__builtin_expect(has_facet<__codecvt_type>(__loc), true)) + _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc); if (this->is_open()) { @@ -768,7 +768,7 @@ namespace std else { // External position corresponding to gptr(). - _M_ext_next = _M_ext_buf + _M_ext_next = _M_ext_buf + _M_codecvt->length(_M_state_last, _M_ext_buf, _M_ext_next, this->gptr() - this->eback()); const streamsize __remainder = _M_ext_end - _M_ext_next; @@ -791,7 +791,7 @@ namespace std } // Inhibit implicit instantiations for required instantiations, - // which are defined via explicit instantiations elsewhere. + // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. #if _GLIBCXX_EXTERN_TEMPLATE extern template class basic_filebuf<char>; @@ -808,4 +808,4 @@ namespace std #endif } // namespace std -#endif +#endif |