+2003-10-16 Petur Runolfsson <peturr02@ru.is>
+
+ PR libstdc++/8610
+ PR libstdc++/11450
+ PR libstdc++/11543
+ PR libstdc++/12065
+ * config/io/basic_file_stdio.cc (__basic_file::seekoff):
+ Change return value from streampos to streamoff.
+ (__basic_file::seekpos): Delete.
+ * config/io/basic_file_stdio.h: Same.
+ * config/io/c_io_stdio.h: Remove streamoff and wstreamsize typedefs.
+ * include/Makefile.am (bits_headers): Add bits/postypes.h.
+ * include/bits/char_traits.h: Include bits/postypes.h instead of
+ bits/fpos.h.
+ * include/bits/fstream.tcc (basic_filebuf::open,
+ basic_filebuf::pbackfail): Don't use < or >= to compare pos_type
+ values, use == and != instead.
+ (basic_filebuf::_M_seek): Use explicit conversion from streamoff
+ to pos_type.
+ (basic_filebuf::imbue): Don't use ! on pos_type values, use
+ == instead. Don't use __check_facet(_M_codecvt) unless is_open().
+ * include/bits/postypes.h: New file.
+ Add __streamoff_base_type typedef, streamsize.
+ (streamoff, streampos, wstreampos): Define typedefs, with
+ streamoff defined as...
+ (streamoff): New class. Document implementation defined
+ aspects.
+ (fpos): New implementation. Document implementation defined
+ aspects.
+ * include/bits/sstream.tcc (basic_stringbuf::seekpos): Use
+ explicit conversion from pos_type to off_type.
+ * include/std/std_iosfwd.h: Include bits/postypes.h instead
+ of bits/fpos.h.
+ * testsuite/27_io/basic_filebuf/seekoff/char/11543.cc: New test.
+ * testsuite/27_io/basic_filebuf/seekoff/wchar_t/11543.cc: New test.
+ * testsuite/27_io/fpos/11450.cc: New test.
+ * testsuite/27_io/fpos/mbstate_t/12065.cc: New test.
+ * testsuite/27_io/fpos/mbstate_t/4_neg.cc: New test.
+ * testsuite/27_io/types/3.cc: New test.
+
+2003-10-16 Benjamin Kosnik <bkoz@redhat.com>
+
+ * configure.host: Remove fpos_include_dir.
+ * configure.ac: Remove FPOS_INC_SRCDIR.
+ * configure: Regenerate.
+ * acinclude.m4 (GLIBCXX_ENABLE_CSTDIO): Remove FPOS_H.
+ * aclocal.m4: Regenerate.
+ * include/Makefile.am (host_headers): Remove fpos.h.
+ (bits_headers): Add postypes.h.
+ * include/Makefile.in: Regenerate.
+ * config/os/gnu-linux/fposh: Remove.
+ * config/os/generic/fpos.h: Remove.
+
+ * testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc: Fixup.
+ * testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc: Same.
+ * testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc: Same.
+ * testsuite/27_io/basic_istream/seekg/char/2.cc: Same.
+ * testsuite/27_io/basic_stringbuf/seekoff/char/1.cc: Same.
+ * testsuite/27_io/basic_stringbuf/seekpos/char/1.cc: Same.
+ * testsuite/27_io/fpos/mbstate_t/3.cc: Same.
+ * testsuite/27_io/objects/char/10.cc: Same.
+
2003-10-16 Paolo Carlini <pcarlini@suse.de>
* src/locale.cc (locale::locale(const char*)): ... one
;;
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)
])
;;
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)
])
return __ret;
}
- streampos
+ streamoff
__basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way)
{ return lseek(this->fd(), __off, __way); }
- streampos
- __basic_file<char>::seekpos(streampos __pos)
- { return lseek(this->fd(), __pos, ios_base::beg); }
-
int
__basic_file<char>::sync()
{ return fflush(_M_cfile); }
streamsize
xsgetn(char* __s, streamsize __n);
- streampos
+ streamoff
seekoff(streamoff __off, ios_base::seekdir __way);
- streampos
- seekpos(streampos __pos);
-
int
sync();
namespace std
{
- // for fpos.h
- typedef long streamoff;
- typedef ptrdiff_t streamsize; // Signed integral type
-#if _GLIBCXX_USE_WCHAR_T
- typedef ptrdiff_t wstreamsize;
-#endif
-
typedef __gthread_mutex_t __c_lock;
// for basic_file.h
+++ /dev/null
-// File position object and stream types, generic 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:
- streamoff _M_off;
- _StateT _M_st;
-
- public:
- _StateT
- state() const { return _M_st; }
-
- void
- 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(streamoff __off, _StateT __st = _StateT())
- : _M_off(__off), _M_st(__st) { }
-
- operator streamoff() const { return _M_off; }
-
- fpos&
- operator+=(streamoff __off) { _M_off += __off; return *this; }
-
- fpos&
- operator-=(streamoff __off) { _M_off -= __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_off == __pos._M_off; }
-
- bool
- operator!=(const fpos& __pos) const
- { return !(*this == __pos); }
- };
-
- /// 27.2, paragraph 10 about fpos/char_traits circularity
- typedef fpos<mbstate_t> streampos;
-# ifdef _GLIBCXX_USE_WCHAR_T
- /// 27.2, paragraph 10 about fpos/char_traits circularity
- typedef fpos<mbstate_t> wstreampos;
-# endif
-} // namespace std
-
-#endif
+++ /dev/null
-// 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 _GLIBCXX_USE_WCHAR_T
- /// 27.2, paragraph 10 about fpos/char_traits circularity
- typedef fpos<mbstate_t> wstreampos;
-# endif
-} // namespace std
-
-#endif
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libtool_VERSION multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot glibcxx_builddir glibcxx_srcdir toplevel_srcdir CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LN_S AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBTOOL CXXCPP CPPFLAGS enable_shared enable_static GLIBCXX_HOSTED_TRUE GLIBCXX_HOSTED_FALSE LIBUNWIND_FLAG GLIBCXX_BUILD_PCH_TRUE GLIBCXX_BUILD_PCH_FALSE glibcxx_PCHFLAGS CSTDIO_H FPOS_H BASIC_FILE_H BASIC_FILE_CC CPP EGREP check_msgfmt glibcxx_MOFILES glibcxx_POFILES glibcxx_localedir USE_NLS CLOCALE_H CCODECVT_H CMESSAGES_H CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_H CTIME_CC CLOCALE_CC CLOCALE_INTERNAL_H C_INCLUDE_DIR GLIBCXX_C_HEADERS_C_TRUE GLIBCXX_C_HEADERS_C_FALSE GLIBCXX_C_HEADERS_C_STD_TRUE GLIBCXX_C_HEADERS_C_STD_FALSE GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE glibcxx_thread_h DEBUG_FLAGS GLIBCXX_BUILD_DEBUG_TRUE GLIBCXX_BUILD_DEBUG_FALSE EXTRA_CXX_FLAGS WERROR SECTION_FLAGS SECTION_LDFLAGS OPT_LDFLAGS LIBMATHOBJS SYMVER_MAP port_specific_symbol_files GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE baseline_dir GLIBCXX_TEST_WCHAR_T_TRUE GLIBCXX_TEST_WCHAR_T_FALSE GLIBCXX_TEST_ABI_TRUE GLIBCXX_TEST_ABI_FALSE ATOMICITY_INC_SRCDIR FPOS_INC_SRCDIR OS_INC_SRCDIR glibcxx_prefixdir gxx_include_dir glibcxx_toolexecdir glibcxx_toolexeclibdir GLIBCXX_INCLUDES TOPLEVEL_INCLUDES OPTIMIZE_CXXFLAGS WARN_FLAGS LIBSUPCXX_PICFLAGS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libtool_VERSION multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot glibcxx_builddir glibcxx_srcdir toplevel_srcdir CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LN_S AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBTOOL CXXCPP CPPFLAGS enable_shared enable_static GLIBCXX_HOSTED_TRUE GLIBCXX_HOSTED_FALSE LIBUNWIND_FLAG GLIBCXX_BUILD_PCH_TRUE GLIBCXX_BUILD_PCH_FALSE glibcxx_PCHFLAGS CSTDIO_H BASIC_FILE_H BASIC_FILE_CC CPP EGREP check_msgfmt glibcxx_MOFILES glibcxx_POFILES glibcxx_localedir USE_NLS CLOCALE_H CCODECVT_H CMESSAGES_H CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_H CTIME_CC CLOCALE_CC CLOCALE_INTERNAL_H C_INCLUDE_DIR GLIBCXX_C_HEADERS_C_TRUE GLIBCXX_C_HEADERS_C_FALSE GLIBCXX_C_HEADERS_C_STD_TRUE GLIBCXX_C_HEADERS_C_STD_FALSE GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE glibcxx_thread_h DEBUG_FLAGS GLIBCXX_BUILD_DEBUG_TRUE GLIBCXX_BUILD_DEBUG_FALSE EXTRA_CXX_FLAGS WERROR SECTION_FLAGS SECTION_LDFLAGS OPT_LDFLAGS LIBMATHOBJS SYMVER_MAP port_specific_symbol_files GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE baseline_dir GLIBCXX_TEST_WCHAR_T_TRUE GLIBCXX_TEST_WCHAR_T_FALSE GLIBCXX_TEST_ABI_TRUE GLIBCXX_TEST_ABI_FALSE ATOMICITY_INC_SRCDIR OS_INC_SRCDIR glibcxx_prefixdir gxx_include_dir glibcxx_toolexecdir glibcxx_toolexeclibdir GLIBCXX_INCLUDES TOPLEVEL_INCLUDES OPTIMIZE_CXXFLAGS WARN_FLAGS LIBSUPCXX_PICFLAGS LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
;;
esac
- FPOS_H=$fpos_include_dir
-
-
# uses it, and it only gets used in this file.)
ATOMICITY_INC_SRCDIR=config/${atomicity_include_dir}
OS_INC_SRCDIR=config/${os_include_dir}
-FPOS_INC_SRCDIR=config/${fpos_include_dir}
-
s,@GLIBCXX_BUILD_PCH_FALSE@,$GLIBCXX_BUILD_PCH_FALSE,;t t
s,@glibcxx_PCHFLAGS@,$glibcxx_PCHFLAGS,;t t
s,@CSTDIO_H@,$CSTDIO_H,;t t
-s,@FPOS_H@,$FPOS_H,;t t
s,@BASIC_FILE_H@,$BASIC_FILE_H,;t t
s,@BASIC_FILE_CC@,$BASIC_FILE_CC,;t t
s,@CPP@,$CPP,;t t
s,@GLIBCXX_TEST_ABI_TRUE@,$GLIBCXX_TEST_ABI_TRUE,;t t
s,@GLIBCXX_TEST_ABI_FALSE@,$GLIBCXX_TEST_ABI_FALSE,;t t
s,@ATOMICITY_INC_SRCDIR@,$ATOMICITY_INC_SRCDIR,;t t
-s,@FPOS_INC_SRCDIR@,$FPOS_INC_SRCDIR,;t t
s,@OS_INC_SRCDIR@,$OS_INC_SRCDIR,;t t
s,@glibcxx_prefixdir@,$glibcxx_prefixdir,;t t
s,@gxx_include_dir@,$gxx_include_dir,;t t
# uses it, and it only gets used in this file.)
ATOMICITY_INC_SRCDIR=config/${atomicity_include_dir}
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 AM_CONDITIONALs.
# 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
-#
# atomicity_include_dir location of atomicity.h,
# defaults to cpu_include_dir
#
# systems out there. :-)
c_model=c_std
c_compatibility=no
-fpos_include_dir="os/generic"
# HOST-SPECIFIC OVERRIDES
# Set any CPU-dependent bits.
;;
gnu* | linux*)
os_include_dir="os/gnu-linux"
- fpos_include_dir=$os_include_dir
;;
hpux*)
os_include_dir="os/hpux"
${bits_srcdir}/localefwd.h \
${bits_srcdir}/mask_array.h \
${bits_srcdir}/ostream.tcc \
+ ${bits_srcdir}/postypes.h \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
${bits_srcdir}/slice_array.h \
${host_srcdir}/ctype_inline.h \
${host_srcdir}/ctype_noninline.h \
${host_srcdir}/os_defines.h \
- ${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h \
- ${glibcxx_srcdir}/$(FPOS_INC_SRCDIR)/fpos.h
+ ${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h
# Non-installed host_header files.
host_headers_noinst = \
-# Makefile.in generated by automake 1.7.6 from Makefile.am.
+# Makefile.in generated by automake 1.7.8 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
-FPOS_H = @FPOS_H@
-FPOS_INC_SRCDIR = @FPOS_INC_SRCDIR@
GLIBCXX_BUILD_DEBUG_FALSE = @GLIBCXX_BUILD_DEBUG_FALSE@
GLIBCXX_BUILD_DEBUG_TRUE = @GLIBCXX_BUILD_DEBUG_TRUE@
GLIBCXX_BUILD_PCH_FALSE = @GLIBCXX_BUILD_PCH_FALSE@
${bits_srcdir}/localefwd.h \
${bits_srcdir}/mask_array.h \
${bits_srcdir}/ostream.tcc \
+ ${bits_srcdir}/postypes.h \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
${bits_srcdir}/slice_array.h \
${c_compatibility_srcdir}/wchar.h \
${c_compatibility_srcdir}/wctype.h
-@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
# Some of the different "C" header models need extra files.
# Some "C" header schemes require the "C" compatibility headers.
# For --enable-cheaders=c_std
@GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc
+@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
${host_srcdir}/ctype_inline.h \
${host_srcdir}/ctype_noninline.h \
${host_srcdir}/os_defines.h \
- ${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h \
- ${glibcxx_srcdir}/$(FPOS_INC_SRCDIR)/fpos.h
+ ${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h
# Non-installed host_header files.
pch_output_builddir = ${host_builddir}/stdc++.h.gch
pch_source = ${glibcxx_srcdir}/include/stdc++.h
PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS)
-@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input}
@GLIBCXX_BUILD_PCH_FALSE@pch_build =
-@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch
+@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input}
@GLIBCXX_BUILD_PCH_FALSE@pch_install =
+@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch
# List of all timestamp files. By keeping only one copy of this list, both
# CLEANFILES and all-local are kept up-to-date.
depcomp =
am__depfiles_maybe =
DIST_SOURCES =
-DIST_COMMON = $(top_srcdir)/fragment.am Makefile.am Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/fragment.am \
+ Makefile.am
all: all-am
.SUFFIXES:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-
+ -rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-
+ -rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
#include <cstring> // For memmove, memset, memchr
#include <bits/stl_algobase.h>// For copy, lexicographical_compare, fill_n
-#include <bits/fpos.h> // For streampos
+#include <bits/postypes.h> // For streampos
namespace __gnu_cxx
{
// 27.8.1.3,4
if ((__mode & ios_base::ate)
- && this->seekoff(0, ios_base::end, __mode) < 0)
+ && this->seekoff(0, ios_base::end, __mode)
+ == pos_type(off_type(-1)))
this->close();
else
__ret = this;
this->gbump(-1);
__tmp = traits_type::to_int_type(*this->gptr());
}
- else if (this->seekoff(-1, ios_base::cur) >= 0)
+ else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1)))
{
__tmp = this->underflow();
if (traits_type::eq_int_type(__tmp, __ret))
}
// Returns pos_type(off_type(-1)) in case of failure.
- pos_type __ret = _M_file.seekoff(__off, __way);
+ pos_type __ret (_M_file.seekoff(__off, __way));
_M_reading = false;
_M_writing = false;
basic_filebuf<_CharT, _Traits>::
imbue(const locale& __loc)
{
- const bool __testbeg = !this->seekoff(0, ios_base::cur, this->_M_mode);
- const bool __teststate = __check_facet(_M_codecvt).encoding() == -1;
-
- if (this->_M_buf_locale != __loc
- && (!this->is_open() || (__testbeg && !__teststate)))
+ if (this->_M_buf_locale != __loc)
{
- this->_M_buf_locale = __loc;
- if (__builtin_expect(has_facet<__codecvt_type>(__loc), true))
- _M_codecvt = &use_facet<__codecvt_type>(__loc);
- else
- _M_codecvt = 0;
-
- // NB This may require the reconversion of previously
- // converted chars. This in turn may cause the
- // reconstruction of the original file. YIKES!! This
- // implementation interprets this requirement as requiring
- // the file position be at the beginning, and a stateless
- // encoding, or that the filebuf be closed. Opinions may differ.
+ bool __testfail = false;
+ if (this->is_open())
+ {
+ const bool __testbeg =
+ this->seekoff(0, ios_base::cur, this->_M_mode) ==
+ pos_type(off_type(0));
+ const bool __teststate =
+ __check_facet(_M_codecvt).encoding() == -1;
+
+ __testfail = !__testbeg || __teststate;
+ }
+
+ if (!__testfail)
+ {
+ this->_M_buf_locale = __loc;
+ if (__builtin_expect(has_facet<__codecvt_type>(__loc), true))
+ _M_codecvt = &use_facet<__codecvt_type>(__loc);
+ else
+ _M_codecvt = 0;
+
+ // NB This may require the reconversion of previously
+ // converted chars. This in turn may cause the
+ // reconstruction of the original file. YIKES!! This
+ // implementation interprets this requirement as requiring
+ // the file position be at the beginning, and a stateless
+ // encoding, or that the filebuf be closed. Opinions may differ.
+ }
}
_M_last_overflowed = false;
}
--- /dev/null
+// Position types -*- 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.4.1 - Types
+// ISO C++ 14882: 27.4.3 - Template class fpos
+//
+
+/** @file postypes.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef _GLIBCXX_POSTYPES_H
+#define _GLIBCXX_POSTYPES_H 1
+
+#pragma GCC system_header
+
+#include <cwchar> // For mbstate_t
+
+namespace std
+{
+ // The types streamoff, streampos and wstreampos and the class
+ // template fpos<> are described in clauses 21.1.2, 21.1.3, 27.1.2,
+ // 27.2, 27.4.1, 27.4.3 and D.6. Despite all this verbage, the
+ // behaviour of these types is mostly implementation defined or
+ // unspecified. The behaviour in this implementation is as noted
+ // below.
+ typedef long __streamoff_base_type;
+ typedef ptrdiff_t streamsize; // Signed integral type
+
+ template<typename _StateT>
+ class fpos;
+
+ // Class streamoff is an implementation defined type that meets the
+ // requirements for streamoff. It stores an offset as a signed
+ // integer. Note: this class is an implementation detail.
+ class streamoff
+ {
+ private:
+ __streamoff_base_type _M_off;
+
+ public:
+ // Nothing in the standard requires that streamoff can be default
+ // constructed. In this implementation a default constructor that
+ // stores the value 0 is provided.
+ streamoff()
+ : _M_off(0) { }
+
+ // The standard only requires that streamoff can be constructed
+ // from streamsize using the constructor syntax. This
+ // implementation also allows implicit conversion from integer
+ // types to streamoff.
+ streamoff(__streamoff_base_type __off)
+ : _M_off(__off) { }
+
+ // The standard requires that streamoff can be constructed from
+ // instances of fpos using the constructor syntax, but gives no
+ // semantics for this construction. In this implementation it
+ // extracts the offset stored by the fpos object.
+ // Note: In versions of GCC up to and including GCC 3.3, implicit
+ // conversion from fpos to streamoff was allowed. This constructor
+ // has now been made explicit to improve type safety.
+ template<typename _StateT>
+ explicit
+ streamoff(const fpos<_StateT>&);
+
+ // The standard requires that streamsize can be constructed from
+ // streamoff using the constructor syntax. This implementation
+ // also allows implicit conversion. This allows streamoff objects
+ // to be used in arithmetic expressions and to be compared against
+ // each other and integer types.
+ operator __streamoff_base_type() const
+ { return _M_off; }
+
+ // This implementation allows the use of operators +=, -=, ++ and
+ // -- on streamoff objects.
+ streamoff&
+ operator+=(__streamoff_base_type __off)
+ {
+ _M_off += __off;
+ return *this;
+ }
+
+ streamoff&
+ operator-=(__streamoff_base_type __off)
+ {
+ _M_off -= __off;
+ return *this;
+ }
+ };
+
+ // In clauses 21.1.3.1 and 27.4.1 streamoff is described as an
+ // implementation defined type. In this implementation it is a
+ // distinct class type.
+ // Note: In versions of GCC up to and including GCC 3.3, streamoff
+ // was typedef long.
+ typedef class streamoff streamoff;
+
+ // The standard fails to place any requiremens on the template
+ // argument StateT. In this implementation StateT must be
+ // DefaultConstructible, CopyConstructible and Assignable. The
+ // standard only requires that fpos should contain a member of type
+ // StateT. In this implementation it also contains an offset stored
+ // as a signed integer.
+ template<typename _StateT>
+ class fpos
+ {
+ private:
+ friend class streamoff;
+
+ __streamoff_base_type _M_off;
+ _StateT _M_state;
+
+ public:
+ // The standard doesn't require that fpos objects can be default
+ // constructed. This implementation provides a default
+ // constructor that initializes the offset to 0 and default
+ // constructs the state.
+ fpos()
+ : _M_off(0), _M_state() { }
+
+ // The standard requires implicit conversion from integers to
+ // fpos, but gives no meaningful semantics for this
+ // conversion. In this implementation this constructor stores
+ // the integer as the offset and default constructs the state.
+ fpos(__streamoff_base_type __off)
+ : _M_off(__off), _M_state() { }
+
+ // The standard requires that fpos objects can be constructed
+ // from streamoff objects using the constructor syntax, and
+ // fails to give any meaningful semantics. In this
+ // implementation implicit conversion is also allowed, and this
+ // constructor stores the streamoff as the offset and default
+ // constructs the state.
+ fpos(const streamoff& __off)
+ : _M_off(__off), _M_state() { }
+
+ void
+ state(_StateT __st)
+ { _M_state = __st; }
+
+ _StateT
+ state() const
+ { return _M_state; }
+
+ // The standard only requires that operator== must be an
+ // equivalence relation. In this implementation two fpos<StateT>
+ // objects belong to the same equivalence class if the contained
+ // offsets compare equal.
+ bool
+ operator==(const fpos& __other) const
+ { return _M_off == __other._M_off; }
+
+ bool
+ operator!=(const fpos& __other) const
+ { return _M_off != __other._M_off; }
+
+ // The standard requires that this operator must be defined, but
+ // gives no semantics. In this implemenation it just adds it's
+ // argument to the stored offset and returns *this.
+ fpos&
+ operator+=(const streamoff& __off)
+ {
+ _M_off += __off;
+ return *this;
+ }
+
+ // The standard requires that this operator must be defined, but
+ // gives no semantics. In this implemenation it just subtracts
+ // it's argument from the stored offset and returns *this.
+ fpos&
+ operator-=(const streamoff& __off)
+ {
+ _M_off -= __off;
+ return *this;
+ }
+
+ // The standard requires that this operator must be defined, but
+ // defines it's semantics only in terms of operator-. In this
+ // implementation it constructs a copy of *this, adds the
+ // argument to that copy using operator+= and then returns the
+ // copy.
+ fpos
+ operator+(const streamoff& __off) const
+ {
+ fpos __pos(*this);
+ __pos += __off;
+ return __pos;
+ }
+
+ // The standard requires that this operator must be defined, but
+ // defines it's semantics only in terms of operator+. In this
+ // implementation it constructs a copy of *this, subtracts the
+ // argument from that copy using operator-= and then returns the
+ // copy.
+ fpos
+ operator-(const streamoff& __off) const
+ {
+ fpos __pos(*this);
+ __pos -= __off;
+ return __pos;
+ }
+
+ // The standard requires that this operator must be defined, but
+ // defines it's semantics only in terms of operator+. In this
+ // implementation it returns the difference between the offset
+ // stored in *this and in the argument.
+ streamoff
+ operator-(const fpos& __other) const
+ { return _M_off - __other._M_off; }
+ };
+
+ template<typename _StateT>
+ inline
+ streamoff::streamoff(const fpos<_StateT>& __pos)
+ : _M_off(__pos._M_off) { }
+
+ // Clauses 21.1.3.1 and 21.1.3.2 describe streampos and wstreampos
+ // as implementation defined types, but clause 27.2 requires that
+ // they must both be typedefs for fpos<mbstate_t>
+ typedef fpos<mbstate_t> streampos;
+ typedef fpos<mbstate_t> wstreampos;
+} // namespace std
+
+#endif
if (_M_string.capacity())
{
- off_type __pos = __sp; // Use streamoff operator to do conversion.
+ off_type __pos (__sp);
const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
char_type* __beg = __testin ? this->eback() : this->pbase();
#include <bits/c++config.h>
#include <bits/c++locale.h>
+#include <bits/c++io.h>
#include <cctype> // For isspace, etc.
#include <bits/stringfwd.h> // For string forward declarations.
-#include <bits/fpos.h>
+#include <bits/postypes.h>
#include <bits/functexcept.h>
namespace std
strmsz_1 = fb.in_avail();
pt_1 = fb.pubseekoff(2, ios_base::beg);
strmsz_2 = fb.in_avail();
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '9' );
//cur
pt_2 = fb.pubseekoff(2, ios_base::cur);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '1' );
//end
pt_2 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb.sputc('\n');
strmsz_1 = fb.sputn("because because because. . .", 28);
strmsz_1 = fb.in_avail();
pt_1 = fb.pubseekoff(2, ios_base::beg);
strmsz_2 = fb.in_avail();
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '9' );
//cur
pt_2 = fb.pubseekoff(2, ios_base::cur);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '1' );
//end
pt_2 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb.sputc('\n');
strmsz_1 = fb.sputn("because because because. . .", 28);
strmsz_1 = fb.in_avail();
pt_1 = fb.pubseekoff(2, ios_base::beg);
strmsz_2 = fb.in_avail();
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == traits_type::eof() );
//cur
pt_2 = fb.pubseekoff(2, ios_base::cur);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == traits_type::eof() );
//end
pt_2 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb.sputc('\n');
strmsz_1 = fb.sputn("because because because. . .", 28);
--- /dev/null
+// Copyright (C) 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.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+struct MyState
+{
+};
+
+struct MyCharTraits : std::char_traits<char>
+{
+ typedef std::fpos<MyState> pos_type;
+ typedef MyState state_type;
+};
+
+namespace std
+{
+ template <>
+ class codecvt<char, char, MyState> :
+ public locale::facet, public codecvt_base
+ {
+ public:
+ typedef char intern_type;
+ typedef char extern_type;
+ typedef MyState state_type;
+
+ explicit codecvt(size_t refs = 0)
+ : locale::facet(refs) { }
+
+ result out(state_type& state, const intern_type* from,
+ const intern_type* from_end, const intern_type*& from_next,
+ extern_type* to, extern_type* to_limit,
+ extern_type*& to_next) const
+ { return do_out(state, from, from_end, from_next,
+ to, to_limit, to_next); }
+
+ result unshift(state_type& state, extern_type* to, extern_type* to_limit,
+ extern_type*& to_next) const
+ { return do_unshift(state, to, to_limit, to_next); }
+
+ result in(state_type& state, const extern_type* from,
+ const extern_type* from_end, const extern_type*& from_next,
+ intern_type* to, intern_type* to_limit,
+ intern_type*& to_next) const
+ { return do_in(state, from, from_end, from_next,
+ to, to_limit, to_next); }
+
+ int encoding() const throw()
+ { return do_encoding(); }
+
+ bool always_noconv() const throw()
+ { return do_always_noconv(); }
+
+ int length(state_type& state, const extern_type* from,
+ const extern_type* end, size_t max) const
+ { return do_length(state, from, end, max); }
+
+ int max_length() const throw()
+ { return do_max_length(); }
+
+ static locale::id id;
+
+ protected:
+ virtual ~codecvt();
+
+ virtual result do_out(state_type&, const intern_type* from,
+ const intern_type*, const intern_type*& from_next,
+ extern_type* to, extern_type*,
+ extern_type*& to_next) const
+ {
+ from_next = from;
+ to_next = to;
+ return noconv;
+ }
+
+ virtual result do_in(state_type&, const extern_type* from,
+ const extern_type*, const extern_type*& from_next,
+ intern_type* to, intern_type*,
+ intern_type*& to_next) const
+ {
+ from_next = from;
+ to_next = to;
+ return noconv;
+ }
+
+ virtual result do_unshift(state_type&, extern_type*, extern_type*,
+ extern_type*&) const
+ { return noconv; }
+
+ virtual int do_encoding() const throw()
+ { return 1; }
+
+ virtual bool do_always_noconv() const throw()
+ { return true; }
+
+ virtual int do_length(state_type&, const extern_type* from,
+ const extern_type* end, size_t max) const
+ {
+ size_t len = end - from;
+ return std::min(max, len);
+ }
+
+ virtual int do_max_length() const throw()
+ { return 1; }
+ };
+
+ locale::id codecvt<char, char, MyState>::id;
+
+ codecvt<char, char, MyState>::~codecvt()
+ { }
+}
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::locale loc(std::locale::classic(),
+ new std::codecvt<char, char, MyState>);
+ std::basic_filebuf<char, MyCharTraits> fb;
+ fb.pubimbue(loc);
+ fb.open("tmp_11543", std::ios_base::out);
+ VERIFY( fb.is_open() );
+ MyCharTraits::pos_type pos = fb.pubseekoff(0, std::ios_base::beg);
+ VERIFY( pos != MyCharTraits::pos_type(MyCharTraits::off_type(-1)) );
+ fb.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
strmsz_1 = fb.in_avail();
pt_1 = fb.pubseekoff(2, ios_base::beg);
strmsz_2 = fb.in_avail();
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '9' );
//cur
pt_2 = fb.pubseekoff(2, ios_base::cur);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '1' );
//end
pt_2 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb.sputc('\n');
strmsz_1 = fb.sputn("because because because. . .", 28);
strmsz_1 = fb.in_avail();
pt_1 = fb.pubseekoff(2, ios_base::beg);
strmsz_2 = fb.in_avail();
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '9' );
//cur
pt_2 = fb.pubseekoff(2, ios_base::cur);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == '1' );
//end
pt_2 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb.sputc('\n');
strmsz_1 = fb.sputn("because because because. . .", 28);
strmsz_1 = fb.in_avail();
pt_1 = fb.pubseekoff(2, ios_base::beg);
strmsz_2 = fb.in_avail();
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == traits_type::eof() );
//cur
pt_2 = fb.pubseekoff(2, ios_base::cur);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == traits_type::eof() );
//end
pt_2 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb.sputc('\n');
strmsz_1 = fb.sputn("because because because. . .", 28);
--- /dev/null
+// Copyright (C) 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.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+struct MyState
+{
+};
+
+struct MyCharTraits : std::char_traits<wchar_t>
+{
+ typedef std::fpos<MyState> pos_type;
+ typedef MyState state_type;
+};
+
+namespace std
+{
+ template <>
+ class codecvt<wchar_t, char, MyState> :
+ public locale::facet, public codecvt_base
+ {
+ public:
+ typedef wchar_t intern_type;
+ typedef char extern_type;
+ typedef MyState state_type;
+
+ explicit codecvt(size_t refs = 0)
+ : locale::facet(refs) { }
+
+ result out(state_type& state, const intern_type* from,
+ const intern_type* from_end, const intern_type*& from_next,
+ extern_type* to, extern_type* to_limit,
+ extern_type*& to_next) const
+ { return do_out(state, from, from_end, from_next,
+ to, to_limit, to_next); }
+
+ result unshift(state_type& state, extern_type* to, extern_type* to_limit,
+ extern_type*& to_next) const
+ { return do_unshift(state, to, to_limit, to_next); }
+
+ result in(state_type& state, const extern_type* from,
+ const extern_type* from_end, const extern_type*& from_next,
+ intern_type* to, intern_type* to_limit,
+ intern_type*& to_next) const
+ { return do_in(state, from, from_end, from_next,
+ to, to_limit, to_next); }
+
+ int encoding() const throw()
+ { return do_encoding(); }
+
+ bool always_noconv() const throw()
+ { return do_always_noconv(); }
+
+ int length(state_type& state, const extern_type* from,
+ const extern_type* end, size_t max) const
+ { return do_length(state, from, end, max); }
+
+ int max_length() const throw()
+ { return do_max_length(); }
+
+ static locale::id id;
+
+ protected:
+ virtual ~codecvt();
+
+ virtual result do_out(state_type&, const intern_type*,
+ const intern_type*, const intern_type*&,
+ extern_type*, extern_type*, extern_type*&) const
+ { return error; }
+
+ virtual result do_in(state_type&, const extern_type*, const extern_type*,
+ const extern_type*&, intern_type*, intern_type*,
+ intern_type*&) const
+ { return error; }
+
+ virtual result do_unshift(state_type&, extern_type*, extern_type*,
+ extern_type*&) const
+ { return noconv; }
+
+ virtual int do_encoding() const throw()
+ { return 1; }
+
+ virtual bool do_always_noconv() const throw()
+ { return false; }
+
+ virtual int do_length(state_type&, const extern_type* from,
+ const extern_type* end, size_t max) const
+ {
+ size_t len = end - from;
+ return std::min(max, len);
+ }
+
+ virtual int do_max_length() const throw()
+ { return 1; }
+ };
+
+ locale::id codecvt<wchar_t, char, MyState>::id;
+
+ codecvt<wchar_t, char, MyState>::~codecvt()
+ { }
+}
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::locale loc(std::locale::classic(),
+ new std::codecvt<wchar_t, char, MyState>);
+ std::basic_filebuf<wchar_t, MyCharTraits> fb;
+ fb.pubimbue(loc);
+ fb.open("tmp_11543", std::ios_base::out);
+ VERIFY( fb.is_open() );
+ MyCharTraits::pos_type pos = fb.pubseekoff(0, std::ios_base::beg);
+ VERIFY( pos != MyCharTraits::pos_type(MyCharTraits::off_type(-1)) );
+ fb.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
// beg
pt_1 = fb.pubseekoff(78, ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == 't' );
c3 = fb.sgetc();
fb.pubsync(); //resets pointers
pt_2 = fb.pubseekpos(pt_1);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); //current in pointer +1
VERIFY( c2 == traits_type::eof() );
// end
pt_1 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
// beg
pt_1 = fb.pubseekoff(78, ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == 't' );
c3 = fb.sgetc();
fb.pubsync(); //resets pointers
pt_2 = fb.pubseekpos(pt_1);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); //current in pointer +1
VERIFY( c2 == c3 );
// end
pt_1 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
// beg
pt_1 = fb.pubseekoff(78, ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == traits_type::eof() );
c3 = fb.sgetc();
fb.pubsync(); //resets pointers
pt_2 = fb.pubseekpos(pt_1);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); //current in pointer +1
VERIFY( c2 != c3 );
// end
pt_1 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
// beg
pt_1 = fb.pubseekoff(78, ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == 't' );
c3 = fb.sgetc();
fb.pubsync(); //resets pointers
pt_2 = fb.pubseekpos(pt_1);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); //current in pointer +1
VERIFY( c2 == traits_type::eof() );
// end
pt_1 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
// beg
pt_1 = fb.pubseekoff(78, ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == 't' );
c3 = fb.sgetc();
fb.pubsync(); //resets pointers
pt_2 = fb.pubseekpos(pt_1);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); //current in pointer +1
VERIFY( c2 == c3 );
// end
pt_1 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
// beg
pt_1 = fb.pubseekoff(78, ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); //current in pointer +1
VERIFY( c1 == traits_type::eof() );
c3 = fb.sgetc();
fb.pubsync(); //resets pointers
pt_2 = fb.pubseekpos(pt_1);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); //current in pointer +1
VERIFY( c2 != c3 );
// end
pt_1 = fb.pubseekoff(0, ios_base::end);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
int count1 = ist.gcount();
ist.seekg(pos);
int count2 = ist.gcount();
- ist.seekg(pos, ios::beg);
+ VERIFY( count1 == count2 );
+ ist.seekg(ios::off_type(pos), ios::beg);
count2 = ist.gcount();
VERIFY( count1 == count2 );
}
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 >= 0 );
c1 = strb_01.snextc(); //current in pointer +1
VERIFY( c1 == 'o' );
VERIFY( strb_01.str() == str_tmp );
//cur
pt_1 = strb_01.pubseekoff(2, std::ios_base::cur);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 == -1 ); // can't seekoff for in and out + cur in sstreams
pt_1 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
pt_2 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_2 == off_1 + 2 );
c1 = strb_01.snextc(); //current in pointer + 1
VERIFY( c1 == ' ' );
VERIFY( strb_01.str() == str_tmp );
//end
pt_2 = strb_01.pubseekoff(2, std::ios_base::end);
- off_1 = pt_2;
+ off_1 = off_type(pt_2);
VERIFY( off_1 == -1 ); // not a valid position
VERIFY( strb_01.str() == str_tmp );
// end part two (from the filebuf tests)
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
VERIFY( off_1 >= 0 );
pt_1 = strb_01.pubseekoff(0, std::ios_base::cur, std::ios_base::out);
- off_1 = pt_1;
+ off_1 = off_type(pt_1);
c1 = strb_01.snextc(); //current in pointer +1
VERIFY( c1 == 'o' );
c2 = strb_01.sputc('x'); //test current out pointer
VERIFY( strb_01.str() == str_tmp );
strb_01.pubsync(); //resets pointers
pt_2 = strb_01.pubseekpos(pt_1, std::ios_base::in|std::ios_base::out);
- off_2 = pt_2;
+ off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = strb_01.snextc(); //current in pointer +1
VERIFY( c1 == c3 );
--- /dev/null
+// Copyright (C) 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.
+
+// 27.4.3 fpos
+
+#include <ios>
+#include <testsuite_hooks.h>
+
+// libstdc++/11450
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::fpos<int> p;
+ VERIFY( p.state() == 0 );
+ p.state(42);
+ VERIFY( p.state() == 42 );
+
+ std::fpos<int> q = p + static_cast<std::streamoff>(1);
+ VERIFY( q.state() == 42 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 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.
+
+// 27.4.3 fpos
+
+#include <typeinfo>
+#include <ios>
+#include <testsuite_hooks.h>
+
+// libstdc++/12065
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::streampos p(0);
+ const std::streampos q(0);
+ std::streamoff o(0);
+
+ VERIFY( typeid(p + o) == typeid(std::streampos) );
+ VERIFY( typeid(q + o) == typeid(std::streampos) );
+ VERIFY( typeid(p - o) == typeid(std::streampos) );
+ VERIFY( typeid(q - o) == typeid(std::streampos) );
+ VERIFY( typeid(p - q) == typeid(std::streamoff) );
+ VERIFY( typeid(q - p) == typeid(std::streamoff) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
std::streamoff off01;
// casts to const streamoff
- // (yes, I know this is weak code)
const std::streampos pos01 = 0;
- off01 = pos01;
+ off01 = std::streamoff(pos01);
// equality/inequality with const args
const std::streampos pos02(54);
--- /dev/null
+// Copyright (C) 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.
+
+// 27.4.3 fpos
+
+// { dg-do compile }
+
+#include <ios>
+
+void test04()
+{
+ std::streampos pos;
+ long n;
+
+ // Implicit conversion
+ n = pos; // { dg-error "cannot convert" }
+
+ // Explicit conversion
+ n = static_cast<long>(pos); // { dg-error "invalid static_cast" }
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
streamoff n = p2 - p1;
VERIFY( n > 0 );
- for (streamoff i = 0; i < n; ++i)
+ for (int i = 0; i < n; ++i)
{
streampos p3 = cin.tellg();
VERIFY( streamoff(p3) == i );
--- /dev/null
+// Copyright (C) 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.
+
+// 27.4.3 streamoff
+
+#include <ios>
+#include <limits>
+#include <testsuite_hooks.h>
+
+void check(std::streamsize n)
+{
+ bool test __attribute__((unused)) = true;
+
+ VERIFY( std::streamsize(std::streamoff(n)) == n );
+}
+
+void test03()
+{
+ check(0);
+ check(-1);
+ check(1);
+ check(std::numeric_limits<std::streamsize>::min());
+ check(std::numeric_limits<std::streamsize>::min() + 1);
+ check(std::numeric_limits<std::streamsize>::min() / 2);
+ check(std::numeric_limits<std::streamsize>::max());
+ check(std::numeric_limits<std::streamsize>::max() - 1);
+ check(std::numeric_limits<std::streamsize>::max() / 2);
+}
+
+int main()
+{
+ test03();
+ return 0;
+}