mirror of git://gcc.gnu.org/git/gcc.git
Makefile.am (target_headers): Add fpos.h
2003-07-03 Benjamin Kosnik <bkoz@redhat.com> * include/Makefile.am (target_headers): Add fpos.h (bits_headers): Remove. * include/Makefile.in: Regenerate. * configure.in: Add FPOS_INC_SRCDIR, substitute it. * configure: Regenerate. * configure.host: Add fpos_include_dir. * config/os/gnu-linux/fpos.h: New. * config/os/generic/fpos.h: Add. * include/bits/fpos.h: Remove. * config/io/c_io_stdio.h: Remove fpos_t typedef. * include/bits/fstream.tcc: Tweaks. * include/std/std_fstream.h: Same. * testsuite/27_io/fpos/1.cc (test01): Uncomment. Move to... * testsuite/27_io/fpos/mbstate_t/1.cc: ...here. * testsuite/27_io/fpos/mbstate_t/2.cc: Same. * testsuite/27_io/fpos/mbstate_t/3.cc: Same. * testsuite/27_io/fpos/1.cc: New. 2003-07-03 Benjamin Kosnik <bkoz@redhat.com> Petur Runolfsson <peturr02@ru.is> * include/std/std_streambuf.h: Remove _M_pos. * config/io/basic_file_stdio.h: Use seekpos instead of seekoff. * config/io/basic_file_stdio.cc: Same, use fseek instead of lseek, use fread/fwrite instead of read/write. * testsuite/27_io/basic_filebuf/showmanyc/char/9533-2.cc: Fix. * testsuite/27_io/basic_filebuf/sputn/char/9339.cc: Close filebufs before reading again. * testsuite/27_io/objects/char/6.cc: Tweak. Co-Authored-By: Petur Runolfsson <peturr02@ru.is> From-SVN: r68913
This commit is contained in:
parent
cc2f5d34f3
commit
cc5112c92d
|
@ -1,3 +1,38 @@
|
|||
2003-07-03 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* include/Makefile.am (target_headers): Add fpos.h
|
||||
(bits_headers): Remove.
|
||||
* include/Makefile.in: Regenerate.
|
||||
* configure.in: Add FPOS_INC_SRCDIR, substitute it.
|
||||
* configure: Regenerate.
|
||||
* configure.host: Add fpos_include_dir.
|
||||
* config/os/gnu-linux/fpos.h: New.
|
||||
* config/os/generic/fpos.h: Add.
|
||||
* include/bits/fpos.h: Remove.
|
||||
|
||||
* config/io/c_io_stdio.h: Remove fpos_t typedef.
|
||||
|
||||
* include/bits/fstream.tcc: Tweaks.
|
||||
* include/std/std_fstream.h: Same.
|
||||
|
||||
* testsuite/27_io/fpos/1.cc (test01): Uncomment. Move to...
|
||||
* testsuite/27_io/fpos/mbstate_t/1.cc: ...here.
|
||||
* testsuite/27_io/fpos/mbstate_t/2.cc: Same.
|
||||
* testsuite/27_io/fpos/mbstate_t/3.cc: Same.
|
||||
* testsuite/27_io/fpos/1.cc: New.
|
||||
|
||||
2003-07-03 Benjamin Kosnik <bkoz@redhat.com>
|
||||
Petur Runolfsson <peturr02@ru.is>
|
||||
|
||||
* include/std/std_streambuf.h: Remove _M_pos.
|
||||
* config/io/basic_file_stdio.h: Use seekpos instead of seekoff.
|
||||
* config/io/basic_file_stdio.cc: Same, use fseek instead of lseek,
|
||||
use fread/fwrite instead of read/write.
|
||||
* testsuite/27_io/basic_filebuf/showmanyc/char/9533-2.cc: Fix.
|
||||
* testsuite/27_io/basic_filebuf/sputn/char/9339.cc: Close filebufs
|
||||
before reading again.
|
||||
* testsuite/27_io/objects/char/6.cc: Tweak.
|
||||
|
||||
2003-07-03 David Edelsohn <edelsohn@gnu.org>
|
||||
|
||||
* testsuite/22_locale/num_put/put/char/7.cc: Guard with
|
||||
|
|
|
@ -1362,7 +1362,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
|
|||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Set directory for fpos.h
|
||||
FPOS_H=$fpos_include_dir
|
||||
|
||||
AC_SUBST(CSTDIO_H)
|
||||
AC_SUBST(FPOS_H)
|
||||
AC_SUBST(BASIC_FILE_H)
|
||||
AC_SUBST(BASIC_FILE_CC)
|
||||
])
|
||||
|
|
|
@ -1374,7 +1374,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
|
|||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Set directory for fpos.h
|
||||
FPOS_H=$fpos_include_dir
|
||||
|
||||
AC_SUBST(CSTDIO_H)
|
||||
AC_SUBST(FPOS_H)
|
||||
AC_SUBST(BASIC_FILE_H)
|
||||
AC_SUBST(BASIC_FILE_CC)
|
||||
])
|
||||
|
|
|
@ -207,33 +207,33 @@ namespace std
|
|||
|
||||
streamsize
|
||||
__basic_file<char>::xsgetn(char* __s, streamsize __n)
|
||||
{
|
||||
streamsize __ret;
|
||||
do
|
||||
__ret = read(this->fd(), __s, __n);
|
||||
while (__ret == -1L && errno == EINTR);
|
||||
return __ret;
|
||||
}
|
||||
{ return fread(__s, 1, __n, _M_cfile); }
|
||||
|
||||
streamsize
|
||||
__basic_file<char>::xsputn(const char* __s, streamsize __n)
|
||||
{
|
||||
streamsize __ret;
|
||||
do
|
||||
__ret = write(this->fd(), __s, __n);
|
||||
while (__ret == -1L && errno == EINTR);
|
||||
return __ret;
|
||||
}
|
||||
|
||||
streamoff
|
||||
__basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way,
|
||||
ios_base::openmode /*__mode*/)
|
||||
{ return lseek(this->fd(), __off, __way); }
|
||||
{ return fwrite(__s, 1, __n, _M_cfile); }
|
||||
|
||||
streampos
|
||||
__basic_file<char>::seekoff(streamoff off, ios_base::seekdir way,
|
||||
ios_base::openmode /*__mode*/)
|
||||
{
|
||||
streampos ret(-1);
|
||||
fpos_t tmp;
|
||||
if (!fseek(_M_cfile, off, way) && !fgetpos(_M_cfile, &tmp))
|
||||
ret = tmp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
streampos
|
||||
__basic_file<char>::seekpos(streampos pos, ios_base::openmode /*__mode*/)
|
||||
{
|
||||
streampos ret(-1);
|
||||
fpos_t tmp = pos;
|
||||
if (!fsetpos(_M_cfile, &tmp) && !fgetpos(_M_cfile, &tmp))
|
||||
ret = tmp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
streamoff
|
||||
__basic_file<char>::seekpos(streamoff __pos, ios_base::openmode /*__mode*/)
|
||||
{ return lseek(this->fd(), __pos, ios_base::beg); }
|
||||
|
||||
int
|
||||
__basic_file<char>::sync()
|
||||
{ return fflush(_M_cfile); }
|
||||
|
|
|
@ -99,12 +99,12 @@ namespace std
|
|||
streamsize
|
||||
xsgetn(char* __s, streamsize __n);
|
||||
|
||||
streamoff
|
||||
streampos
|
||||
seekoff(streamoff __off, ios_base::seekdir __way,
|
||||
ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
|
||||
streamoff
|
||||
seekpos(streamoff __pos,
|
||||
streampos
|
||||
seekpos(streampos __pos,
|
||||
ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
|
||||
int
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// underlying io library -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
|
@ -38,20 +38,19 @@
|
|||
|
||||
namespace std
|
||||
{
|
||||
// for fpos.h
|
||||
// for fpos.h
|
||||
typedef long streamoff;
|
||||
typedef ptrdiff_t streamsize; // Signed integral type
|
||||
#if _GLIBCPP_USE_WCHAR_T
|
||||
typedef ptrdiff_t wstreamsize;
|
||||
#endif
|
||||
typedef fpos_t __c_streampos;
|
||||
|
||||
typedef __gthread_mutex_t __c_lock;
|
||||
|
||||
// for basic_file.h
|
||||
// for basic_file.h
|
||||
typedef FILE __c_file;
|
||||
|
||||
// for ios_base.h
|
||||
// for ios_base.h
|
||||
struct __ios_flags
|
||||
{
|
||||
typedef short __int_type;
|
||||
|
@ -90,4 +89,4 @@ namespace std
|
|||
};
|
||||
}
|
||||
|
||||
#endif // _CPP_IO_STDIO_H
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// File position object and stream types
|
||||
// File position object and stream types, generic version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
|
@ -55,26 +56,22 @@ namespace std
|
|||
template<typename _StateT>
|
||||
class fpos
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef _StateT __state_type;
|
||||
|
||||
private:
|
||||
streamoff _M_off;
|
||||
__state_type _M_st;
|
||||
_StateT _M_st;
|
||||
|
||||
public:
|
||||
__state_type
|
||||
_StateT
|
||||
state() const { return _M_st; }
|
||||
|
||||
void
|
||||
state(__state_type __st) { _M_st = __st; }
|
||||
state(_StateT __st) { _M_st = __st; }
|
||||
|
||||
fpos(): _M_off(streamoff()), _M_st(_StateT()) { }
|
||||
|
||||
// NB: The standard defines only the implicit copy ctor and the
|
||||
// previous two members. The rest is a "conforming extension".
|
||||
fpos(): _M_off(streamoff()), _M_st(__state_type()) { }
|
||||
|
||||
fpos(streamoff __off, __state_type __st = __state_type())
|
||||
fpos(streamoff __off, _StateT __st = _StateT())
|
||||
: _M_off(__off), _M_st(__st) { }
|
||||
|
||||
operator streamoff() const { return _M_off; }
|
||||
|
@ -107,13 +104,7 @@ namespace std
|
|||
|
||||
bool
|
||||
operator!=(const fpos& __pos) const
|
||||
{ return _M_off != __pos._M_off; }
|
||||
|
||||
streamoff
|
||||
_M_position() const { return _M_off; }
|
||||
|
||||
void
|
||||
_M_position(streamoff __off) { _M_off = __off; }
|
||||
{ return !(*this == __pos); }
|
||||
};
|
||||
|
||||
/// 27.2, paragraph 10 about fpos/char_traits circularity
|
|
@ -0,0 +1,144 @@
|
|||
// File position object and stream types, GNU version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// 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 Input/output library
|
||||
//
|
||||
|
||||
/** @file fpos.h
|
||||
* This is an internal header file, included by other library headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _CPP_BITS_FPOS_H
|
||||
#define _CPP_BITS_FPOS_H 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/c++io.h>
|
||||
#include <cwchar> // For mbstate_t.
|
||||
|
||||
namespace std
|
||||
{
|
||||
// 27.4.1 Types
|
||||
|
||||
// [27.4.3] template class fpos
|
||||
/**
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _StateT>
|
||||
class fpos
|
||||
{
|
||||
private:
|
||||
fpos_t _M_pos;
|
||||
|
||||
public:
|
||||
_StateT
|
||||
state() const;
|
||||
|
||||
void
|
||||
state(_StateT __st);
|
||||
|
||||
fpos() : _M_pos(fpos_t()) { }
|
||||
|
||||
// NB: The standard defines only the implicit copy ctor and the
|
||||
// previous two members. The rest is a "conforming extension".
|
||||
fpos(streamoff __off, _StateT __st = _StateT());
|
||||
|
||||
fpos(const fpos_t& __pos) : _M_pos(__pos) { }
|
||||
|
||||
operator streamoff() const { return _M_pos.__pos; }
|
||||
|
||||
operator fpos_t() const { return _M_pos; }
|
||||
|
||||
fpos&
|
||||
operator+=(streamoff __off)
|
||||
{
|
||||
_M_pos.__pos += __off;
|
||||
return *this;
|
||||
}
|
||||
|
||||
fpos&
|
||||
operator-=(streamoff __off)
|
||||
{
|
||||
_M_pos.__pos -= __off;
|
||||
return *this;
|
||||
}
|
||||
|
||||
fpos
|
||||
operator+(streamoff __off)
|
||||
{
|
||||
fpos __t(*this);
|
||||
__t += __off;
|
||||
return __t;
|
||||
}
|
||||
|
||||
fpos
|
||||
operator-(streamoff __off)
|
||||
{
|
||||
fpos __t(*this);
|
||||
__t -= __off;
|
||||
return __t;
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const fpos& __pos) const
|
||||
{ return _M_pos.__pos == __pos._M_pos.__pos; }
|
||||
|
||||
bool
|
||||
operator!=(const fpos& __pos) const
|
||||
{ return !(*this == __pos); }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline mbstate_t
|
||||
fpos<mbstate_t>::state() const { return _M_pos.__state; }
|
||||
|
||||
template<>
|
||||
inline void
|
||||
fpos<mbstate_t>::state(mbstate_t __st) { _M_pos.__state = __st; }
|
||||
|
||||
template<>
|
||||
inline
|
||||
fpos<mbstate_t>::fpos(streamoff __off, mbstate_t __st) : _M_pos(fpos_t())
|
||||
{
|
||||
_M_pos.__pos = __off;
|
||||
_M_pos.__state = __st;
|
||||
}
|
||||
|
||||
/// 27.2, paragraph 10 about fpos/char_traits circularity
|
||||
typedef fpos<mbstate_t> streampos;
|
||||
# ifdef _GLIBCPP_USE_WCHAR_T
|
||||
/// 27.2, paragraph 10 about fpos/char_traits circularity
|
||||
typedef fpos<mbstate_t> wstreampos;
|
||||
# endif
|
||||
} // namespace std
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -30,6 +30,8 @@
|
|||
# abi_baseline_pair directory name for ABI compat testing,
|
||||
# defaults to host_cpu-host_os (as per config.guess)
|
||||
#
|
||||
# fpos_include_dir directory for definition of fpos template
|
||||
#
|
||||
# ATOMICITYH location of atomicity.h,
|
||||
# defaults to cpu_include_dir
|
||||
#
|
||||
|
@ -52,7 +54,7 @@
|
|||
# systems out there. :-)
|
||||
c_model=c_std
|
||||
c_compatibility=no
|
||||
|
||||
fpos_include_dir=generic
|
||||
|
||||
# HOST-SPECIFIC OVERRIDES
|
||||
# Set any CPU-dependent bits.
|
||||
|
@ -142,6 +144,7 @@ case "${host_os}" in
|
|||
;;
|
||||
gnu* | linux*)
|
||||
os_include_dir="os/gnu-linux"
|
||||
fpos_include_dir=$os_include_dir
|
||||
;;
|
||||
hpux*)
|
||||
os_include_dir="os/hpux"
|
||||
|
|
|
@ -443,10 +443,13 @@ GLIBCPP_CONFIGURE_TESTSUITE
|
|||
# Propagate the target-specific source directories through the build chain.
|
||||
# (Nothing currently uses cpu_include_dir directly; only ATOMICITYH
|
||||
# uses it, and it only gets used in this file.)
|
||||
OS_INC_SRCDIR=config/${os_include_dir}
|
||||
ATOMICITY_INC_SRCDIR=config/${ATOMICITYH}
|
||||
AC_SUBST(OS_INC_SRCDIR)
|
||||
OS_INC_SRCDIR=config/${os_include_dir}
|
||||
FPOS_INC_SRCDIR=config/${fpos_include_dir}
|
||||
AC_SUBST(ATOMICITY_INC_SRCDIR)
|
||||
AC_SUBST(FPOS_INC_SRCDIR)
|
||||
AC_SUBST(OS_INC_SRCDIR)
|
||||
|
||||
|
||||
# Determine cross-compile flags and all AM_CONDITIONALs.
|
||||
AC_SUBST(GLIBCPP_IS_CROSS_COMPILING)
|
||||
|
|
|
@ -116,7 +116,6 @@ bits_headers = \
|
|||
${bits_srcdir}/cpp_type_traits.h \
|
||||
${bits_srcdir}/demangle.h \
|
||||
${bits_srcdir}/deque.tcc \
|
||||
${bits_srcdir}/fpos.h \
|
||||
${bits_srcdir}/fstream.tcc \
|
||||
${bits_srcdir}/functexcept.h \
|
||||
${bits_srcdir}/gslice.h \
|
||||
|
@ -323,7 +322,8 @@ target_headers = \
|
|||
${target_srcdir}/ctype_inline.h \
|
||||
${target_srcdir}/ctype_noninline.h \
|
||||
${target_srcdir}/os_defines.h \
|
||||
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
|
||||
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h \
|
||||
${glibcpp_srcdir}/@FPOS_INC_SRCDIR@/fpos.h
|
||||
|
||||
# Non-installed target_header files.
|
||||
target_headers_noinst = \
|
||||
|
|
|
@ -91,6 +91,8 @@ DEBUG_FLAGS = @DEBUG_FLAGS@
|
|||
DLLTOOL = @DLLTOOL@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
|
||||
FPOS_H = @FPOS_H@
|
||||
FPOS_INC_SRCDIR = @FPOS_INC_SRCDIR@
|
||||
GCJ = @GCJ@
|
||||
GCJFLAGS = @GCJFLAGS@
|
||||
GLIBCPP_IS_CROSS_COMPILING = @GLIBCPP_IS_CROSS_COMPILING@
|
||||
|
@ -232,7 +234,6 @@ bits_headers = \
|
|||
${bits_srcdir}/cpp_type_traits.h \
|
||||
${bits_srcdir}/demangle.h \
|
||||
${bits_srcdir}/deque.tcc \
|
||||
${bits_srcdir}/fpos.h \
|
||||
${bits_srcdir}/fstream.tcc \
|
||||
${bits_srcdir}/functexcept.h \
|
||||
${bits_srcdir}/gslice.h \
|
||||
|
@ -433,7 +434,8 @@ target_headers = \
|
|||
${target_srcdir}/ctype_inline.h \
|
||||
${target_srcdir}/ctype_noninline.h \
|
||||
${target_srcdir}/os_defines.h \
|
||||
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
|
||||
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h \
|
||||
${glibcpp_srcdir}/@FPOS_INC_SRCDIR@/fpos.h
|
||||
|
||||
|
||||
# Non-installed target_header files.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// basic_ios locale and locale-related member functions -*- C++ -*-
|
||||
// basic_ios member functions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
//
|
||||
|
|
|
@ -98,9 +98,9 @@ namespace std
|
|||
_M_writing = false;
|
||||
_M_set_buffer(-1);
|
||||
|
||||
// 27.8.1.3,4
|
||||
if ((__mode & ios_base::ate)
|
||||
&& this->seekoff(0, ios_base::end, __mode) < 0)
|
||||
// 27.8.1.3,4
|
||||
this->close();
|
||||
else
|
||||
__ret = this;
|
||||
|
@ -203,7 +203,8 @@ namespace std
|
|||
streamsize __ilen = 0;
|
||||
if (__check_facet(_M_codecvt).always_noconv())
|
||||
{
|
||||
__elen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()), __buflen);
|
||||
__elen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()),
|
||||
__buflen);
|
||||
__ilen = __elen;
|
||||
}
|
||||
else
|
||||
|
@ -490,11 +491,8 @@ namespace std
|
|||
// Ditch any pback buffers to avoid confusion.
|
||||
_M_destroy_pback();
|
||||
|
||||
// Sync the internal and external streams.
|
||||
off_type __computed_off = __off;
|
||||
|
||||
if (this->pbase() < this->pptr()
|
||||
|| _M_last_overflowed)
|
||||
off_type __computed_off = __off;
|
||||
if (this->pbase() < this->pptr())
|
||||
{
|
||||
// Part one: update the output sequence.
|
||||
this->sync();
|
||||
|
@ -505,7 +503,7 @@ namespace std
|
|||
else if (_M_reading && __way == ios_base::cur)
|
||||
__computed_off += this->gptr() - this->egptr();
|
||||
|
||||
// Return pos_type(off_type(-1)) in case of failure.
|
||||
// Returns pos_type(off_type(-1)) in case of failure.
|
||||
__ret = _M_file.seekoff(__computed_off * __width, __way, __mode);
|
||||
|
||||
_M_reading = false;
|
||||
|
|
|
@ -218,9 +218,7 @@ namespace std
|
|||
*/
|
||||
virtual
|
||||
~basic_filebuf()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
{ this->close(); }
|
||||
|
||||
// Members:
|
||||
/**
|
||||
|
|
|
@ -183,13 +183,6 @@ namespace std
|
|||
*/
|
||||
locale _M_buf_locale;
|
||||
|
||||
/**
|
||||
* @if maint
|
||||
* Yet unused.
|
||||
* @endif
|
||||
*/
|
||||
fpos<__state_type> _M_pos;
|
||||
|
||||
public:
|
||||
/// Destructor deallocates no buffer space.
|
||||
virtual
|
||||
|
|
|
@ -27,32 +27,28 @@ void test_02()
|
|||
using namespace std;
|
||||
bool test = true;
|
||||
const char* name = "tmp_file1";
|
||||
|
||||
const char* strlit = "0123456789";
|
||||
|
||||
filebuf fbout;
|
||||
fbout.open(name, ios_base::out | ios_base::trunc);
|
||||
|
||||
filebuf fb;
|
||||
|
||||
int written = 0;
|
||||
fb.open(name, ios_base::out | ios_base::trunc);
|
||||
for (int i = 0; i < BUFSIZ; ++i)
|
||||
written += fbout.sputn(strlit, 10);
|
||||
|
||||
fbout.close();
|
||||
written += fb.sputn(strlit, 10);
|
||||
fb.close();
|
||||
|
||||
ifstream in(name);
|
||||
int sum = 0;
|
||||
bool gotsome;
|
||||
|
||||
int read = 0;
|
||||
int n = 0;
|
||||
char buf[10];
|
||||
fb.open(name, ios_base::in);
|
||||
do
|
||||
{
|
||||
char buf[100];
|
||||
int n = in.readsome(buf, sizeof(buf));
|
||||
gotsome = (n > 0);
|
||||
sum += n;
|
||||
n = fb.sgetn(buf, sizeof(buf));
|
||||
read += n;
|
||||
}
|
||||
while (gotsome);
|
||||
while (n);
|
||||
|
||||
VERIFY( sum == written );
|
||||
VERIFY( read == written );
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -31,12 +31,14 @@ void test01()
|
|||
fbuf01.open("tmp_9339", ios_base::out | ios_base::trunc);
|
||||
streamsize s1 = fbuf01.sputn("Pete Goldlust @ Carl Hammer Gallery", len);
|
||||
VERIFY( s1 == len );
|
||||
fbuf01.close();
|
||||
|
||||
filebuf fbuf02;
|
||||
char buf[256];
|
||||
fbuf02.open("tmp_9339", ios_base::in);
|
||||
streamsize s2 = fbuf02.sgetn(buf, 256);
|
||||
VERIFY( s2 == len );
|
||||
fbuf02.close();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -38,11 +38,11 @@ void test01()
|
|||
bool test = true;
|
||||
|
||||
typedef std::mbstate_t state_type;
|
||||
state_type state01;
|
||||
state_type state02;
|
||||
state_type state01 = state_type();
|
||||
state_type state02 = state_type();
|
||||
|
||||
std::streampos pos01;
|
||||
std::streampos pos02;
|
||||
std::streampos pos01(0);
|
||||
std::streampos pos02(0);
|
||||
|
||||
std::streamoff off01;
|
||||
std::streamoff off02;
|
||||
|
@ -53,15 +53,16 @@ void test01()
|
|||
// 27.4.3.1 fpos members
|
||||
// void state(state_type s);
|
||||
// state_type state();
|
||||
#if 0
|
||||
// XXX Need to have some sanity checking for the mbstate_t type, or
|
||||
// whatever the insantiating type for class fpos happens to be for
|
||||
// streampos, as things like equality operators and assignment
|
||||
// operators, increment and deincrement operators need to be in place.
|
||||
|
||||
// XXX Need to have better sanity checking for the mbstate_t type,
|
||||
// or whatever the insantiating type for class fpos happens to be
|
||||
// for streampos, as things like equality operators and assignment
|
||||
// operators, increment and deincrement operators need to be in
|
||||
// place.
|
||||
pos01.state(state02);
|
||||
state01 = pos01.state();
|
||||
VERIFY( state01 == state02 );
|
||||
#endif
|
||||
test = memcmp(&state01, &state02, sizeof(state_type)) == 0;
|
||||
VERIFY( test );
|
||||
}
|
||||
|
||||
int main()
|
|
@ -26,21 +26,31 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <streambuf>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
class Badbuf : public std::streambuf
|
||||
{
|
||||
protected:
|
||||
virtual int sync()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
{ return -1; }
|
||||
};
|
||||
|
||||
void test06()
|
||||
{
|
||||
std::ios_base::Init init;
|
||||
std::cout.rdbuf(new Badbuf);
|
||||
std::cout.exceptions(std::ios_base::badbit);
|
||||
bool test = true;
|
||||
|
||||
try
|
||||
{
|
||||
// No-op in current code.
|
||||
std::ios_base::Init init;
|
||||
std::cout.rdbuf(new Badbuf);
|
||||
std::cout.exceptions(std::ios_base::badbit);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
test = false;
|
||||
}
|
||||
VERIFY( test );
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
Loading…
Reference in New Issue