2000-10-05 13:27:02 +02:00
|
|
|
// File based streams -*- C++ -*-
|
|
|
|
|
2002-01-26 02:55:09 +01:00
|
|
|
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
|
|
|
|
// Free Software Foundation, Inc.
|
2000-10-05 13:27:02 +02:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING. If not, write to the Free
|
|
|
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
// USA.
|
|
|
|
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
|
|
|
//
|
|
|
|
// ISO C++ 14882: 27.8 File-based streams
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _CPP_BITS_FSTREAM_TCC
|
|
|
|
#define _CPP_BITS_FSTREAM_TCC 1
|
|
|
|
|
2002-02-16 20:33:43 +01:00
|
|
|
#pragma GCC system_header
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
void
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
2001-05-22 20:48:19 +02:00
|
|
|
_M_allocate_internal_buffer()
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2001-05-22 20:48:19 +02:00
|
|
|
if (!_M_buf && _M_buf_size_opt)
|
2001-01-16 08:55:26 +01:00
|
|
|
{
|
|
|
|
_M_buf_size = _M_buf_size_opt;
|
2001-05-22 20:48:19 +02:00
|
|
|
|
2002-04-30 21:04:43 +02:00
|
|
|
// Allocate internal buffer.
|
2002-05-13 15:58:00 +02:00
|
|
|
_M_buf = new char_type[_M_buf_size];
|
2002-04-30 21:04:43 +02:00
|
|
|
_M_buf_allocated = true;
|
2001-05-22 20:48:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Both close and setbuf need to deallocate internal buffers, if it exists.
|
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
void
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
_M_destroy_internal_buffer()
|
|
|
|
{
|
|
|
|
if (_M_buf_allocated)
|
|
|
|
{
|
|
|
|
delete [] _M_buf;
|
|
|
|
_M_buf = NULL;
|
|
|
|
_M_buf_allocated = false;
|
|
|
|
this->setg(NULL, NULL, NULL);
|
|
|
|
this->setp(NULL, NULL);
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
2002-04-30 21:04:43 +02:00
|
|
|
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
|
|
|
|
_M_state_cur(__state_type()), _M_state_beg(__state_type()),
|
|
|
|
_M_buf_allocated(false), _M_last_overflowed(false)
|
2002-04-16 02:45:36 +02:00
|
|
|
{ _M_buf_unified = true; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
open(const char* __s, ios_base::openmode __mode)
|
|
|
|
{
|
|
|
|
__filebuf_type *__ret = NULL;
|
|
|
|
if (!this->is_open())
|
|
|
|
{
|
2002-04-16 02:45:36 +02:00
|
|
|
_M_file.open(__s, __mode);
|
2001-01-16 08:55:26 +01:00
|
|
|
if (this->is_open())
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2001-05-22 20:48:19 +02:00
|
|
|
_M_allocate_internal_buffer();
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_mode = __mode;
|
|
|
|
_M_set_indeterminate();
|
2002-08-16 00:25:39 +02:00
|
|
|
|
2002-04-12 07:42:23 +02:00
|
|
|
if ((__mode & ios_base::ate)
|
2000-10-05 13:27:02 +02:00
|
|
|
&& this->seekoff(0, ios_base::end, __mode) < 0)
|
|
|
|
this->close();
|
|
|
|
__ret = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
close()
|
|
|
|
{
|
|
|
|
__filebuf_type *__ret = NULL;
|
|
|
|
if (this->is_open())
|
|
|
|
{
|
2002-01-26 02:55:09 +01:00
|
|
|
const int_type __eof = traits_type::eof();
|
2000-10-05 13:27:02 +02:00
|
|
|
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
|
2002-07-31 04:47:36 +02:00
|
|
|
if (__testput
|
|
|
|
&& traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
|
2002-01-26 02:55:09 +01:00
|
|
|
return __ret;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-01-26 02:55:09 +01:00
|
|
|
// NB: Do this here so that re-opened filebufs will be cool...
|
|
|
|
_M_mode = ios_base::openmode(0);
|
|
|
|
_M_destroy_internal_buffer();
|
|
|
|
_M_pback_destroy();
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
#if 0
|
|
|
|
// XXX not done
|
|
|
|
if (_M_last_overflowed)
|
|
|
|
{
|
|
|
|
_M_output_unshift();
|
2002-01-26 02:55:09 +01:00
|
|
|
_M_really_overflow(__eof);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-04-16 02:45:36 +02:00
|
|
|
if (_M_file.close())
|
|
|
|
__ret = this;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2002-04-16 02:45:36 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_last_overflowed = false;
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
streamsize
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
showmanyc()
|
|
|
|
{
|
|
|
|
streamsize __ret = -1;
|
|
|
|
bool __testin = _M_mode & ios_base::in;
|
|
|
|
|
2002-01-08 20:57:01 +01:00
|
|
|
if (__testin && this->is_open())
|
2002-08-16 00:25:39 +02:00
|
|
|
__ret = _M_in_end - _M_in_cur;
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_last_overflowed = false;
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::int_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
pbackfail(int_type __i)
|
|
|
|
{
|
|
|
|
int_type __ret = traits_type::eof();
|
|
|
|
bool __testin = _M_mode & ios_base::in;
|
|
|
|
|
|
|
|
if (__testin)
|
|
|
|
{
|
|
|
|
bool __testpb = _M_in_beg < _M_in_cur;
|
|
|
|
char_type __c = traits_type::to_char_type(__i);
|
|
|
|
bool __testeof = traits_type::eq_int_type(__i, __ret);
|
|
|
|
|
|
|
|
if (__testpb)
|
|
|
|
{
|
|
|
|
bool __testout = _M_mode & ios_base::out;
|
|
|
|
bool __testeq = traits_type::eq(__c, this->gptr()[-1]);
|
|
|
|
|
|
|
|
// Try to put back __c into input sequence in one of three ways.
|
|
|
|
// Order these tests done in is unspecified by the standard.
|
|
|
|
if (!__testeof && __testeq)
|
|
|
|
{
|
|
|
|
--_M_in_cur;
|
|
|
|
if (__testout)
|
|
|
|
--_M_out_cur;
|
|
|
|
__ret = __i;
|
|
|
|
}
|
|
|
|
else if (__testeof)
|
|
|
|
{
|
|
|
|
--_M_in_cur;
|
|
|
|
if (__testout)
|
|
|
|
--_M_out_cur;
|
|
|
|
__ret = traits_type::not_eof(__i);
|
|
|
|
}
|
|
|
|
else if (!__testeof)
|
|
|
|
{
|
|
|
|
--_M_in_cur;
|
|
|
|
if (__testout)
|
|
|
|
--_M_out_cur;
|
|
|
|
_M_pback_create();
|
|
|
|
*_M_in_cur = __c;
|
|
|
|
__ret = __i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// At the beginning of the buffer, need to make a
|
|
|
|
// putback position available.
|
|
|
|
this->seekoff(-1, ios_base::cur);
|
|
|
|
this->underflow();
|
|
|
|
if (!__testeof)
|
|
|
|
{
|
|
|
|
if (!traits_type::eq(__c, *_M_in_cur))
|
|
|
|
{
|
|
|
|
_M_pback_create();
|
|
|
|
*_M_in_cur = __c;
|
|
|
|
}
|
|
|
|
__ret = __i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
__ret = traits_type::not_eof(__i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_M_last_overflowed = false;
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::int_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
overflow(int_type __c)
|
|
|
|
{
|
|
|
|
int_type __ret = traits_type::eof();
|
2001-03-27 05:48:17 +02:00
|
|
|
bool __testput = _M_out_cur && _M_out_cur < _M_buf + _M_buf_size;
|
2000-10-05 13:27:02 +02:00
|
|
|
bool __testout = _M_mode & ios_base::out;
|
|
|
|
|
|
|
|
if (__testout)
|
|
|
|
{
|
2001-03-27 05:48:17 +02:00
|
|
|
if (__testput)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
*_M_out_cur = traits_type::to_char_type(__c);
|
|
|
|
_M_out_cur_move(1);
|
|
|
|
__ret = traits_type::not_eof(__c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
__ret = this->_M_really_overflow(__c);
|
|
|
|
}
|
|
|
|
|
|
|
|
_M_last_overflowed = false; // Set in _M_really_overflow, below.
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
2002-02-08 02:34:41 +01:00
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
void
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
_M_convert_to_external(_CharT* __ibuf, streamsize __ilen,
|
|
|
|
streamsize& __elen, streamsize& __plen)
|
|
|
|
{
|
|
|
|
const locale __loc = this->getloc();
|
|
|
|
const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc);
|
|
|
|
|
|
|
|
if (__cvt.always_noconv() && __ilen)
|
|
|
|
{
|
2002-04-16 02:45:36 +02:00
|
|
|
__elen += _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
|
2002-02-08 02:34:41 +01:00
|
|
|
__plen += __ilen;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Worst-case number of external bytes needed.
|
|
|
|
int __ext_multiplier = __cvt.encoding();
|
|
|
|
if (__ext_multiplier == -1 || __ext_multiplier == 0)
|
|
|
|
__ext_multiplier = sizeof(char_type);
|
|
|
|
streamsize __blen = __ilen * __ext_multiplier;
|
|
|
|
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
|
|
|
|
char* __bend;
|
|
|
|
const char_type* __iend;
|
|
|
|
__res_type __r = __cvt.out(_M_state_cur, __ibuf, __ibuf + __ilen,
|
|
|
|
__iend, __buf, __buf + __blen, __bend);
|
|
|
|
// Result == ok, partial, noconv
|
|
|
|
if (__r != codecvt_base::error)
|
|
|
|
__blen = __bend - __buf;
|
|
|
|
// Result == error
|
|
|
|
else
|
|
|
|
__blen = 0;
|
|
|
|
|
|
|
|
if (__blen)
|
|
|
|
{
|
2002-04-16 02:45:36 +02:00
|
|
|
__elen += _M_file.xsputn(__buf, __blen);
|
2002-02-08 02:34:41 +01:00
|
|
|
__plen += __blen;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try once more for partial conversions.
|
|
|
|
if (__r == codecvt_base::partial)
|
|
|
|
{
|
|
|
|
const char_type* __iresume = __iend;
|
|
|
|
streamsize __rlen = _M_out_end - __iend;
|
|
|
|
__r = __cvt.out(_M_state_cur, __iresume, __iresume + __rlen,
|
|
|
|
__iend, __buf, __buf + __blen, __bend);
|
|
|
|
if (__r != codecvt_base::error)
|
|
|
|
__rlen = __bend - __buf;
|
|
|
|
else
|
|
|
|
__rlen = 0;
|
|
|
|
if (__rlen)
|
|
|
|
{
|
2002-04-16 02:45:36 +02:00
|
|
|
__elen += _M_file.xsputn(__buf, __rlen);
|
2002-02-08 02:34:41 +01:00
|
|
|
__plen += __rlen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::int_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
_M_really_overflow(int_type __c)
|
|
|
|
{
|
|
|
|
int_type __ret = traits_type::eof();
|
|
|
|
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
|
2002-08-16 00:25:39 +02:00
|
|
|
bool __testunbuffered = _M_file.is_open() && !_M_buf_size_opt;
|
2001-03-27 05:48:17 +02:00
|
|
|
|
|
|
|
if (__testput || __testunbuffered)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2002-02-08 02:34:41 +01:00
|
|
|
// Sizes of external and pending output.
|
|
|
|
streamsize __elen = 0;
|
|
|
|
streamsize __plen = 0;
|
|
|
|
|
2002-04-22 22:28:05 +02:00
|
|
|
// Need to restore current position. The position of the external
|
|
|
|
// byte sequence (_M_file) corresponds to _M_filepos, and we need
|
|
|
|
// to move it to _M_out_beg for the write.
|
|
|
|
if (_M_filepos && _M_filepos != _M_out_beg)
|
|
|
|
{
|
|
|
|
off_type __off = _M_out_beg - _M_filepos;
|
|
|
|
_M_file.seekoff(__off, ios_base::cur);
|
|
|
|
}
|
|
|
|
|
2002-02-08 02:34:41 +01:00
|
|
|
// Convert internal buffer to external representation, output.
|
|
|
|
// NB: In the unbuffered case, no internal buffer exists.
|
|
|
|
if (!__testunbuffered)
|
|
|
|
_M_convert_to_external(_M_out_beg, _M_out_end - _M_out_beg,
|
|
|
|
__elen, __plen);
|
|
|
|
|
|
|
|
// Convert pending sequence to external representation, output.
|
2002-04-24 02:33:28 +02:00
|
|
|
// If eof, then just attempt sync.
|
2002-02-08 02:34:41 +01:00
|
|
|
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2002-02-08 02:34:41 +01:00
|
|
|
char_type __pending = traits_type::to_char_type(__c);
|
|
|
|
_M_convert_to_external(&__pending, 1, __elen, __plen);
|
2001-03-27 05:48:17 +02:00
|
|
|
|
2002-04-24 02:33:28 +02:00
|
|
|
// User code must flush when switching modes (thus don't sync).
|
|
|
|
if (__elen == __plen)
|
|
|
|
{
|
|
|
|
_M_set_indeterminate();
|
|
|
|
__ret = traits_type::not_eof(__c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!_M_file.sync())
|
2002-01-26 02:55:09 +01:00
|
|
|
{
|
|
|
|
_M_set_indeterminate();
|
|
|
|
__ret = traits_type::not_eof(__c);
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
_M_last_overflowed = true;
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
2001-05-22 20:48:19 +02:00
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
|
2001-05-22 20:48:19 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
setbuf(char_type* __s, streamsize __n)
|
|
|
|
{
|
|
|
|
if (!this->is_open() && __s == 0 && __n == 0)
|
|
|
|
_M_buf_size_opt = 0;
|
|
|
|
else if (__s && __n)
|
|
|
|
{
|
|
|
|
// This is implementation-defined behavior, and assumes
|
|
|
|
// that an external char_type array of length (__s + __n)
|
|
|
|
// exists and has been pre-allocated. If this is not the
|
|
|
|
// case, things will quickly blow up.
|
|
|
|
// Step 1: Destroy the current internal array.
|
|
|
|
_M_destroy_internal_buffer();
|
|
|
|
|
|
|
|
// Step 2: Use the external array.
|
|
|
|
_M_buf = __s;
|
|
|
|
_M_buf_size_opt = _M_buf_size = __n;
|
|
|
|
_M_set_indeterminate();
|
|
|
|
}
|
|
|
|
_M_last_overflowed = false;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::pos_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
|
|
|
|
{
|
|
|
|
pos_type __ret = pos_type(off_type(-1));
|
2002-04-09 10:48:33 +02:00
|
|
|
bool __testin = (ios_base::in & _M_mode & __mode) != 0;
|
|
|
|
bool __testout = (ios_base::out & _M_mode & __mode) != 0;
|
2001-03-14 21:46:34 +01:00
|
|
|
|
|
|
|
// Should probably do has_facet checks here.
|
|
|
|
int __width = use_facet<__codecvt_type>(_M_buf_locale).encoding();
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__width < 0)
|
|
|
|
__width = 0;
|
2002-04-09 08:14:32 +02:00
|
|
|
bool __testfail = __off != 0 && __width <= 0;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-04-09 10:48:33 +02:00
|
|
|
if (this->is_open() && !__testfail && (__testin || __testout))
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
// Ditch any pback buffers to avoid confusion.
|
|
|
|
_M_pback_destroy();
|
|
|
|
|
|
|
|
if (__way != ios_base::cur || __off != 0)
|
|
|
|
{
|
|
|
|
off_type __computed_off = __width * __off;
|
|
|
|
|
|
|
|
bool __testget = _M_in_cur && _M_in_beg < _M_in_end;
|
|
|
|
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
|
|
|
|
// Sync the internal and external streams.
|
|
|
|
// out
|
|
|
|
if (__testput || _M_last_overflowed)
|
|
|
|
{
|
|
|
|
// Part one: update the output sequence.
|
|
|
|
this->sync();
|
|
|
|
// Part two: output unshift sequence.
|
|
|
|
_M_output_unshift();
|
|
|
|
}
|
|
|
|
//in
|
|
|
|
else if (__testget && __way == ios_base::cur)
|
2002-04-22 22:28:05 +02:00
|
|
|
__computed_off += _M_in_cur - _M_filepos;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-04-16 02:45:36 +02:00
|
|
|
__ret = _M_file.seekoff(__computed_off, __way, __mode);
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_set_indeterminate();
|
|
|
|
}
|
|
|
|
// NB: Need to do this in case _M_file in indeterminate
|
2002-04-16 02:45:36 +02:00
|
|
|
// state, ie _M_file._offset == -1
|
2000-10-05 13:27:02 +02:00
|
|
|
else
|
|
|
|
{
|
2002-04-16 02:45:36 +02:00
|
|
|
__ret = _M_file.seekoff(__off, ios_base::cur, __mode);
|
2002-04-23 23:56:10 +02:00
|
|
|
__ret += max(_M_out_cur, _M_in_cur) - _M_filepos;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_M_last_overflowed = false;
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_filebuf<_CharT, _Traits>::pos_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
seekpos(pos_type __pos, ios_base::openmode __mode)
|
|
|
|
{
|
2002-04-09 08:14:32 +02:00
|
|
|
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
|
|
|
// 171. Strange seekpos() semantics due to joint position
|
|
|
|
return this->seekoff(off_type(__pos), ios_base::beg, __mode);
|
|
|
|
#endif
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
void
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
_M_output_unshift()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits>
|
|
|
|
void
|
|
|
|
basic_filebuf<_CharT, _Traits>::
|
|
|
|
imbue(const locale& __loc)
|
|
|
|
{
|
|
|
|
bool __testbeg = gptr() == eback() && pptr() == pbase();
|
2001-03-14 21:46:34 +01:00
|
|
|
|
|
|
|
if (__testbeg && _M_buf_locale != __loc)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
_M_buf_locale = __loc;
|
2001-03-14 21:46:34 +01:00
|
|
|
_M_buf_locale_init = true;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2001-03-14 21:46:34 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
// NB this may require the reconversion of previously
|
|
|
|
// converted chars. This in turn may cause the reconstruction
|
|
|
|
// of the original file. YIKES!!
|
|
|
|
// XXX The part in the above comment is not done.
|
|
|
|
_M_last_overflowed = false;
|
|
|
|
}
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
|
|
|
|
// Inhibit implicit instantiations for required instantiations,
|
|
|
|
// which are defined via explicit instantiations elsewhere.
|
|
|
|
// NB: This syntax is a GNU extension.
|
|
|
|
extern template class basic_filebuf<char>;
|
|
|
|
extern template class basic_filebuf<wchar_t>;
|
|
|
|
extern template class basic_ifstream<char>;
|
|
|
|
extern template class basic_ifstream<wchar_t>;
|
|
|
|
extern template class basic_ofstream<char>;
|
|
|
|
extern template class basic_ofstream<wchar_t>;
|
|
|
|
extern template class basic_fstream<char>;
|
|
|
|
extern template class basic_fstream<wchar_t>;
|
2000-10-05 13:27:02 +02:00
|
|
|
} // namespace std
|
|
|
|
|
2002-02-01 04:20:39 +01:00
|
|
|
#endif
|