gcc/libstdc++-v3/include/bits/fstream.tcc

796 lines
23 KiB
Plaintext
Raw Normal View History

// File based streams -*- C++ -*-
cp-tree.h (lang_type_class): Remove is_partial_instantiation. * cp-tree.h (lang_type_class): Remove is_partial_instantiation. (PARTIAL_INSTANTIATION_P): Remove. (IMPLICIT_TYPENAME_P): Likewise. (IMPLICIT_TYPENAME_TYPE_DECL_P): Likewise. (build_typename_type): Remove declaration. (parmlist_is_exprlist): Likewise. * decl.c (build_typename_type): Make it static, remove third parameter. (push_class_binding): Don't do implicit typename stuff. (make_typename_type): Likewise. (lookup_name_real): Likewise. (grokdeclarator): Don't try to convert declarations into initializations. Don't do implicit typename stuff. (parmlist_is_exprlist): Remove. (xref_basetypes): Simplify. * decl2.c (grokfield): Don't try to convert declarations into initializations. (build_anon_union_vars): Do this while processing templates, too. (finish_anon_union): Likewise. * error.c (dump_type): Remove implicit typename handling. * parser.c (cp_parser_diagnose_invalid_type_name): New method. (cp_parser_primary_expression): Correct handling of names not found by unqualified name lookup in templates. (cp_parser_nested_name_specifier_opt): Avoid checking dependency of types when possible. (cp_parser_simple_declaration): Complain intelligently about some invalid declarations. (cp_parser_member_declaration): Likewise. (cp_parser_constructor_declarator_p): Don't check when we're in a function scope. * pt.c (instantiate_class_template): Remove PARTIAL_INSTANTIATION_P gunk. * search.c (lookup_field_r): Don't build implicit typenames. (marked_pushdecls_p): Don't enter dependent base types. (unmarked_pushdecls_p): Likewise. * semantics.c (begin_class_definition): Remove implicit typename stuff. * config/locale/gnu/messages_members.h: Use this-> to refer to unqualified members of base clasess. * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Likewise. * include/bits/codecvt.h: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/fstream.tcc: Likewise. * include/bits/istream.tcc: Likewise. * include/bits/list.tcc: Likewise. * include/bits/locale_facets.h: Likewise. * include/bits/ostream.tcc: Likewise. * include/bits/sstream.tcc: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_tree.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/ext/ropeimpl.h: Likewise. * include/ext/stdio_filebuf.h: Likewise. * include/ext/stl_rope.h: Likewise. * include/std/std_fstream.h: Likewise. * include/std/std_sstream.h: Likewise. Co-Authored-By: Jeffrey Oldham <oldham@codesourcery.com> From-SVN: r61403
2003-01-16 21:30:50 +01:00
// Copyright (C) 1997, 1998, 1999, 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
// 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 _FSTREAM_TCC
#define _FSTREAM_TCC 1
#pragma GCC system_header
namespace std
{
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
_M_allocate_internal_buffer()
{
// Allocate internal buffer only if one doesn't already exist
// (either allocated or provided by the user via setbuf).
if (!_M_buf_allocated && !this->_M_buf)
{
PR libstdc++/9404, PR libstdc++/9701 (partial) 2003-02-24 Paolo Carlini <pcarlini@unitus.it> Nathan Myers <ncm@cantrip.org> PR libstdc++/9404, PR libstdc++/9701 (partial) (aka pptr == epptr implies overflow) * include/bits/fstream.tcc (_M_allocate_internal_buffer): Consistently, _M_out_end points to the end of the buffer just created. (overflow): Tweak to use _M_out_buf_size(). (_M_convert_to_external): The role of the old _M_out_end is now played by _M_out_lim. (_M_really_overflow): Likewise. (seekoff): Likewise. (setbuf): _M_out_end points to the end of the external buffer. * include/bits/sstream.tcc (overflow): Rewrote, taking into account the resolution of DR 169 (TC). (seekoff): Use _M_string.capacity(); ios_base::end is now _M_out_lim. (seekpos): Use _M_string.capacity(); tweak. * include/bits/streambuf.tcc (sputc, xsputn): Remove comments. * include/std/std_fstream.h (sync): The role of the old _M_out_end is now played by _M_out_lim. (_M_set_indeterminate): Use _M_set_determinate. (_M_set_determinate): _M_out_end is now _M_out_lim. (_M_is_indeterminate): Likewise. * include/std/std_sstream.h (str()): _M_out_end is now _M_out_lim. (_M_stringbuf_init): Don't set _M_buf_size, unused for sstreams, which have the information readily available as _M_string.capacity(); for ate and app modes, pass the string size to _M_really_sync. (_M_really_sync): Consistently set _M_out_end and _M_out_lim, to point to the end of the buffer (i.e., epptr) and to the string end, respectively. * include/std/std_streambuf.h: tweak comments, add _M_out_lim, which points to the right limit of the used put area. (_M_out_cur_move): The role of the old _M_out_end is now played by _M_out_lim. (_M_out_buf_size): Simplify: now (when _M_out_cur) return simply _M_out_end - _M_out_cur (i.e., pptr), _very_ close to the letter of the standard. (basic_streambuf()): Initialize _M_out_lim too. * testsuite/27_io/filebuf_virtuals.cc (test10): Trivial tweak. * testsuite/27_io/filebuf_virtuals.cc (test11): Add. * testsuite/27_io/stringbuf_virtuals.cc (test09): Add. Co-Authored-By: Nathan Myers <ncm@cantrip.org> From-SVN: r63367
2003-02-24 19:22:58 +01:00
this->_M_buf = new char_type[this->_M_buf_size];
_M_buf_allocated = true;
}
}
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
_M_destroy_internal_buffer() throw()
{
if (_M_buf_allocated)
{
cp-tree.h (lang_type_class): Remove is_partial_instantiation. * cp-tree.h (lang_type_class): Remove is_partial_instantiation. (PARTIAL_INSTANTIATION_P): Remove. (IMPLICIT_TYPENAME_P): Likewise. (IMPLICIT_TYPENAME_TYPE_DECL_P): Likewise. (build_typename_type): Remove declaration. (parmlist_is_exprlist): Likewise. * decl.c (build_typename_type): Make it static, remove third parameter. (push_class_binding): Don't do implicit typename stuff. (make_typename_type): Likewise. (lookup_name_real): Likewise. (grokdeclarator): Don't try to convert declarations into initializations. Don't do implicit typename stuff. (parmlist_is_exprlist): Remove. (xref_basetypes): Simplify. * decl2.c (grokfield): Don't try to convert declarations into initializations. (build_anon_union_vars): Do this while processing templates, too. (finish_anon_union): Likewise. * error.c (dump_type): Remove implicit typename handling. * parser.c (cp_parser_diagnose_invalid_type_name): New method. (cp_parser_primary_expression): Correct handling of names not found by unqualified name lookup in templates. (cp_parser_nested_name_specifier_opt): Avoid checking dependency of types when possible. (cp_parser_simple_declaration): Complain intelligently about some invalid declarations. (cp_parser_member_declaration): Likewise. (cp_parser_constructor_declarator_p): Don't check when we're in a function scope. * pt.c (instantiate_class_template): Remove PARTIAL_INSTANTIATION_P gunk. * search.c (lookup_field_r): Don't build implicit typenames. (marked_pushdecls_p): Don't enter dependent base types. (unmarked_pushdecls_p): Likewise. * semantics.c (begin_class_definition): Remove implicit typename stuff. * config/locale/gnu/messages_members.h: Use this-> to refer to unqualified members of base clasess. * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Likewise. * include/bits/codecvt.h: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/fstream.tcc: Likewise. * include/bits/istream.tcc: Likewise. * include/bits/list.tcc: Likewise. * include/bits/locale_facets.h: Likewise. * include/bits/ostream.tcc: Likewise. * include/bits/sstream.tcc: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_tree.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/ext/ropeimpl.h: Likewise. * include/ext/stdio_filebuf.h: Likewise. * include/ext/stl_rope.h: Likewise. * include/std/std_fstream.h: Likewise. * include/std/std_sstream.h: Likewise. Co-Authored-By: Jeffrey Oldham <oldham@codesourcery.com> From-SVN: r61403
2003-01-16 21:30:50 +01:00
delete [] this->_M_buf;
this->_M_buf = NULL;
_M_buf_allocated = false;
}
delete [] _M_ext_buf;
_M_ext_buf = NULL;
_M_ext_buf_size = 0;
_M_ext_next = NULL;
_M_ext_end = NULL;
}
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
_M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(),
_M_state_last(), _M_buf(NULL), _M_buf_size(BUFSIZ),
_M_buf_allocated(false), _M_reading(false), _M_writing(false),
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
_M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
_M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0),
_M_ext_end(0)
{
re PR libstdc++/9024 (Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)) 2003-06-05 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9024 * include/bits/fstream.tcc (_M_underflow): Fix for unbuffered. * include/bits/stl_algobase.h: Tweak. * include/std/std_fstream.h: Move _M_buf_size to... * include/std/std_streambuf.h: ...here. Modify. * include/bits/streambuf.tcc: Same. * testsuite/testsuite_hooks.h: Tweak. * testsuite/testsuite_io.h (constraint_filebuf): New. * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/3.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: New. * testsuite/data/sgetc.txt: New. * testsuite/data/sgetn.txt: New. From-SVN: r67524
2003-06-06 02:19:17 +02:00
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
open(const char* __s, ios_base::openmode __mode)
{
__filebuf_type *__ret = NULL;
if (!this->is_open())
{
re PR libstdc++/4164 (33 Memory Leak when using iostream) 2002-04-15 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/4164 Valgrind fixes. * config/io/basic_file_stdio.cc (__basic_file::~__basic_file): Call close. (__basic_file::close): Call fflush. Correct return if fclose ok. (__basic_file::is_open): Make const. Change __c_file_type to __c_file. * config/io/basic_file_stdio.h: Change __c_file_type to __c_file. (__basic_file::is_open): Make const. * config/io/c_io_stdio.h: Change __c_file_type to __c_file. * include/std/std_fstream.h (filebuf::_M_allocate_file): Remove. (filebuf::_M_unbuf): Add. (filebuf::_M_file): Change to non-pointer. (filebuf::_M_allocate_pback_buffer): Remove. * include/bits/fstream.tcc (filebuf::_M_allocate_file): Remove. (filebuf::_M_allocate_internal_buffer): Use _M_unbuf. Change initialization list for _M_file change. (filebuf::_M_allocate_pback_buffer): Remove. Change _M_file usage to reflect non-pointer data member. * config/locale/generic/c_locale.cc (locale::facet::_S_create_c_locale): Add parameter. * config/locale/generic/collate_members.cc: Change _M_compare_helper to _M_compare. Change _M_transform_helper to _M_transform. * config/locale/generic/monetary_members.cc: Changeup data types. Add dtors. * config/locale/generic/numeric_members.cc: Add dtors. * config/locale/generic/time_members.cc: Add dtors. * config/locale/gnu/c_locale.cc: Add parameter. * config/locale/gnu/collate_members.cc:Change _M_compare_helper to _M_compare. Change _M_transform_helper to _M_transform. * config/locale/gnu/ctype_members.cc: Better error checking. * config/os/gnu-linux/bits/ctype_noninline.h: Better error checking. * config/locale/gnu/messages_members.cc: Tweak comment. * config/locale/gnu/monetary_members.cc: Change data types. Add dtors. * config/locale/gnu/numeric_members.cc: Add dtors, better error checking. * config/locale/gnu/time_members.cc: Same. * config/locale/ieee_1003.1-2001/c_locale.cc (locale::facet::_S_create_c_locale): Add parameter. * config/locale/ieee_1003.1-2001/c_locale.h: Correct typedef. * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Remove bogus ctor. * include/bits/locale_facets.h (moneypunct): Use string literals. Don't define dtor. (numpunct): Same. (__timepunct): Same. (locale::_Impl::_M_facets): Change from vector to array. (locale::_Impl::_M_names): Change from array of strings to array of string literals. (locale::facet::_S_create_c_locale): Add parameter. (locale::locale::_S_num_facets): Move to... (locale::_Impl::_M_facets_size): Here. * include/bits/locale_facets.tcc: Fixups for _M_facets, _M_name changes. * include/bits/localefwd.h: (locale::id::_M_id): Add member function. (locale::_Impl::_Impl(facet**, size_t, bool)): Add. (locale::_Impl::_Impl(string, size_t)): Change to (locale::_Impl::_Impl(const char*, size_t)): This. * include/bits/streambuf.tcc (streambuf::_S_pback_size): Define. * include/std/std_streambuf.h (streambuf::_M_pback_size): Change to (streambuf::_S_pback_size): This. * src/globals.cc: Add pre-allocations for "C" facets. * src/locale-inst.cc: Remove vector instantiations. * src/locale.cc: Remove vector include. Fixups for _M_names, _M_facets changes. * src/localename.cc: Same. * include/bits/stl_vector.h: Fix odd formatting. * include/bits/basic_string.tcc: Tweak comment. * libsupc++/new: Make sure parameters are uglified. * libsupc++/typeinfo: Same. * testsuite/22_locale/num_get_members_char.cc: Fixup. * testsuite/22_locale/num_get_members_wchar_t.cc: Same. * testsuite/27_io/filebuf_members.cc: Same. From-SVN: r52345
2002-04-16 02:45:36 +02:00
_M_file.open(__s, __mode);
if (this->is_open())
{
_M_allocate_internal_buffer();
cp-tree.h (lang_type_class): Remove is_partial_instantiation. * cp-tree.h (lang_type_class): Remove is_partial_instantiation. (PARTIAL_INSTANTIATION_P): Remove. (IMPLICIT_TYPENAME_P): Likewise. (IMPLICIT_TYPENAME_TYPE_DECL_P): Likewise. (build_typename_type): Remove declaration. (parmlist_is_exprlist): Likewise. * decl.c (build_typename_type): Make it static, remove third parameter. (push_class_binding): Don't do implicit typename stuff. (make_typename_type): Likewise. (lookup_name_real): Likewise. (grokdeclarator): Don't try to convert declarations into initializations. Don't do implicit typename stuff. (parmlist_is_exprlist): Remove. (xref_basetypes): Simplify. * decl2.c (grokfield): Don't try to convert declarations into initializations. (build_anon_union_vars): Do this while processing templates, too. (finish_anon_union): Likewise. * error.c (dump_type): Remove implicit typename handling. * parser.c (cp_parser_diagnose_invalid_type_name): New method. (cp_parser_primary_expression): Correct handling of names not found by unqualified name lookup in templates. (cp_parser_nested_name_specifier_opt): Avoid checking dependency of types when possible. (cp_parser_simple_declaration): Complain intelligently about some invalid declarations. (cp_parser_member_declaration): Likewise. (cp_parser_constructor_declarator_p): Don't check when we're in a function scope. * pt.c (instantiate_class_template): Remove PARTIAL_INSTANTIATION_P gunk. * search.c (lookup_field_r): Don't build implicit typenames. (marked_pushdecls_p): Don't enter dependent base types. (unmarked_pushdecls_p): Likewise. * semantics.c (begin_class_definition): Remove implicit typename stuff. * config/locale/gnu/messages_members.h: Use this-> to refer to unqualified members of base clasess. * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Likewise. * include/bits/codecvt.h: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/fstream.tcc: Likewise. * include/bits/istream.tcc: Likewise. * include/bits/list.tcc: Likewise. * include/bits/locale_facets.h: Likewise. * include/bits/ostream.tcc: Likewise. * include/bits/sstream.tcc: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_tree.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/ext/ropeimpl.h: Likewise. * include/ext/stdio_filebuf.h: Likewise. * include/ext/stl_rope.h: Likewise. * include/std/std_fstream.h: Likewise. * include/std/std_sstream.h: Likewise. Co-Authored-By: Jeffrey Oldham <oldham@codesourcery.com> From-SVN: r61403
2003-01-16 21:30:50 +01:00
this->_M_mode = __mode;
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
// Setup initial buffer to 'uncommitted' mode.
_M_reading = false;
_M_writing = false;
_M_set_buffer(-1);
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
// Reset to initial state.
_M_state_last = _M_state_cur = _M_state_beg;
// 27.8.1.3,4
if ((__mode & ios_base::ate)
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
&& this->seekoff(0, ios_base::end, __mode)
[multiple changes] 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. From-SVN: r72582
2003-10-17 00:37:53 +02:00
== pos_type(off_type(-1)))
this->close();
else
__ret = this;
}
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
close() throw()
{
__filebuf_type* __ret = NULL;
if (this->is_open())
{
bool __testfail = false;
try
{
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
if (!_M_terminate_output())
__testfail = true;
}
catch(...)
{
__testfail = true;
}
// NB: Do this here so that re-opened filebufs will be cool...
this->_M_mode = ios_base::openmode(0);
this->_M_pback_init = false;
_M_destroy_internal_buffer();
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
_M_reading = false;
_M_writing = false;
_M_set_buffer(-1);
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
_M_state_last = _M_state_cur = _M_state_beg;
if (!_M_file.close())
__testfail = true;
if (!__testfail)
re PR libstdc++/4164 (33 Memory Leak when using iostream) 2002-04-15 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/4164 Valgrind fixes. * config/io/basic_file_stdio.cc (__basic_file::~__basic_file): Call close. (__basic_file::close): Call fflush. Correct return if fclose ok. (__basic_file::is_open): Make const. Change __c_file_type to __c_file. * config/io/basic_file_stdio.h: Change __c_file_type to __c_file. (__basic_file::is_open): Make const. * config/io/c_io_stdio.h: Change __c_file_type to __c_file. * include/std/std_fstream.h (filebuf::_M_allocate_file): Remove. (filebuf::_M_unbuf): Add. (filebuf::_M_file): Change to non-pointer. (filebuf::_M_allocate_pback_buffer): Remove. * include/bits/fstream.tcc (filebuf::_M_allocate_file): Remove. (filebuf::_M_allocate_internal_buffer): Use _M_unbuf. Change initialization list for _M_file change. (filebuf::_M_allocate_pback_buffer): Remove. Change _M_file usage to reflect non-pointer data member. * config/locale/generic/c_locale.cc (locale::facet::_S_create_c_locale): Add parameter. * config/locale/generic/collate_members.cc: Change _M_compare_helper to _M_compare. Change _M_transform_helper to _M_transform. * config/locale/generic/monetary_members.cc: Changeup data types. Add dtors. * config/locale/generic/numeric_members.cc: Add dtors. * config/locale/generic/time_members.cc: Add dtors. * config/locale/gnu/c_locale.cc: Add parameter. * config/locale/gnu/collate_members.cc:Change _M_compare_helper to _M_compare. Change _M_transform_helper to _M_transform. * config/locale/gnu/ctype_members.cc: Better error checking. * config/os/gnu-linux/bits/ctype_noninline.h: Better error checking. * config/locale/gnu/messages_members.cc: Tweak comment. * config/locale/gnu/monetary_members.cc: Change data types. Add dtors. * config/locale/gnu/numeric_members.cc: Add dtors, better error checking. * config/locale/gnu/time_members.cc: Same. * config/locale/ieee_1003.1-2001/c_locale.cc (locale::facet::_S_create_c_locale): Add parameter. * config/locale/ieee_1003.1-2001/c_locale.h: Correct typedef. * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Remove bogus ctor. * include/bits/locale_facets.h (moneypunct): Use string literals. Don't define dtor. (numpunct): Same. (__timepunct): Same. (locale::_Impl::_M_facets): Change from vector to array. (locale::_Impl::_M_names): Change from array of strings to array of string literals. (locale::facet::_S_create_c_locale): Add parameter. (locale::locale::_S_num_facets): Move to... (locale::_Impl::_M_facets_size): Here. * include/bits/locale_facets.tcc: Fixups for _M_facets, _M_name changes. * include/bits/localefwd.h: (locale::id::_M_id): Add member function. (locale::_Impl::_Impl(facet**, size_t, bool)): Add. (locale::_Impl::_Impl(string, size_t)): Change to (locale::_Impl::_Impl(const char*, size_t)): This. * include/bits/streambuf.tcc (streambuf::_S_pback_size): Define. * include/std/std_streambuf.h (streambuf::_M_pback_size): Change to (streambuf::_S_pback_size): This. * src/globals.cc: Add pre-allocations for "C" facets. * src/locale-inst.cc: Remove vector instantiations. * src/locale.cc: Remove vector include. Fixups for _M_names, _M_facets changes. * src/localename.cc: Same. * include/bits/stl_vector.h: Fix odd formatting. * include/bits/basic_string.tcc: Tweak comment. * libsupc++/new: Make sure parameters are uglified. * libsupc++/typeinfo: Same. * testsuite/22_locale/num_get_members_char.cc: Fixup. * testsuite/22_locale/num_get_members_wchar_t.cc: Same. * testsuite/27_io/filebuf_members.cc: Same. From-SVN: r52345
2002-04-16 02:45:36 +02:00
__ret = this;
}
return __ret;
}
template<typename _CharT, typename _Traits>
streamsize
basic_filebuf<_CharT, _Traits>::
showmanyc()
{
streamsize __ret = -1;
const bool __testin = this->_M_mode & ios_base::in;
if (__testin && this->is_open())
{
// For a stateful encoding (-1) the pending sequence might be just
// shift and unshift prefixes with no actual character.
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
__ret = this->egptr() - this->gptr();
if (__check_facet(_M_codecvt).encoding() >= 0)
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
return __ret;
}
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
2003-05-12 20:12:27 +02:00
basic_filebuf<_CharT, _Traits>::
underflow()
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
{
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (__testin && !_M_writing)
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
{
// Check for pback madness, and if so swich back to the
// normal buffers and jet outta here before expensive
// fileops happen...
_M_destroy_pback();
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (this->gptr() < this->egptr())
return traits_type::to_int_type(*this->gptr());
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
// Get and convert input sequence.
const size_t __buflen = this->_M_buf_size > 1
? this->_M_buf_size - 1 : 1;
// Will be set to true if ::read() returns 0 indicating EOF.
bool __got_eof = false;
// Number of internal characters produced.
streamsize __ilen = 0;
if (__check_facet(_M_codecvt).always_noconv())
{
__ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()),
__buflen);
if (__ilen == 0)
__got_eof = true;
}
else
{
// Worst-case number of external bytes.
// XXX Not done encoding() == -1.
const int __enc = _M_codecvt->encoding();
streamsize __blen; // Minimum buffer size.
streamsize __rlen; // Number of chars to read.
if (__enc > 0)
__blen = __rlen = __buflen * __enc;
else
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
{
__blen = __buflen + _M_codecvt->max_length() - 1;
__rlen = __buflen;
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
}
const streamsize __remainder = _M_ext_end - _M_ext_next;
__rlen = __rlen > __remainder ? __rlen - __remainder : 0;
// Allocate buffer if necessary and move unconverted
// bytes to front.
if (_M_ext_buf_size < __blen)
{
char* __buf = new char[__blen];
if (__remainder > 0)
std::memcpy(__buf, _M_ext_next, __remainder);
delete [] _M_ext_buf;
_M_ext_buf = __buf;
_M_ext_buf_size = __blen;
}
else if (__remainder > 0)
std::memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
_M_state_last = _M_state_cur;
do
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
{
if (__rlen > 0)
{
// Sanity check!
// This may fail if the return value of
// codecvt::max_length() is bogus.
if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
{
__throw_ios_failure("codecvt::max_length() "
"is not valid");
}
streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
if (__elen == 0)
__got_eof = true;
_M_ext_end += __elen;
}
char_type* __iend;
codecvt_base::result __r;
__r = _M_codecvt->in(_M_state_cur, _M_ext_next,
_M_ext_end, _M_ext_next, this->eback(),
this->eback() + __buflen, __iend);
if (__r == codecvt_base::ok || __r == codecvt_base::partial)
__ilen = __iend - this->eback();
else if (__r == codecvt_base::noconv)
{
size_t __avail = _M_ext_end - _M_ext_buf;
__ilen = std::min(__avail, __buflen);
traits_type::copy(this->eback(),
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
reinterpret_cast<char_type*>(_M_ext_buf), __ilen);
_M_ext_next = _M_ext_buf + __ilen;
}
else
{
__ilen = 0;
break;
}
__rlen = 1;
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
}
while (!__got_eof && __ilen == 0);
re PR libstdc++/9024 (Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)) 2003-06-05 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9024 * include/bits/fstream.tcc (_M_underflow): Fix for unbuffered. * include/bits/stl_algobase.h: Tweak. * include/std/std_fstream.h: Move _M_buf_size to... * include/std/std_streambuf.h: ...here. Modify. * include/bits/streambuf.tcc: Same. * testsuite/testsuite_hooks.h: Tweak. * testsuite/testsuite_io.h (constraint_filebuf): New. * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/3.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: New. * testsuite/data/sgetc.txt: New. * testsuite/data/sgetn.txt: New. From-SVN: r67524
2003-06-06 02:19:17 +02:00
}
if (__ilen > 0)
re PR libstdc++/9024 (Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)) 2003-06-05 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9024 * include/bits/fstream.tcc (_M_underflow): Fix for unbuffered. * include/bits/stl_algobase.h: Tweak. * include/std/std_fstream.h: Move _M_buf_size to... * include/std/std_streambuf.h: ...here. Modify. * include/bits/streambuf.tcc: Same. * testsuite/testsuite_hooks.h: Tweak. * testsuite/testsuite_io.h (constraint_filebuf): New. * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/3.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: New. * testsuite/data/sgetc.txt: New. * testsuite/data/sgetn.txt: New. From-SVN: r67524
2003-06-06 02:19:17 +02:00
{
_M_set_buffer(__ilen);
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
_M_reading = true;
__ret = traits_type::to_int_type(*this->gptr());
}
else if (__got_eof)
{
// If the actual end of file is reached, set 'uncommitted'
// mode, thus allowing an immediate write without an
// intervening seek.
_M_set_buffer(-1);
_M_reading = false;
}
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
pbackfail(int_type __i)
{
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (__testin && !_M_writing)
{
// Remember whether the pback buffer is active, otherwise below
// we may try to store in it a second char (libstdc++/9761).
const bool __testpb = this->_M_pback_init;
const bool __testeof = traits_type::eq_int_type(__i, __ret);
int_type __tmp;
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (this->eback() < this->gptr())
{
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
this->gbump(-1);
__tmp = traits_type::to_int_type(*this->gptr());
}
[multiple changes] 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. From-SVN: r72582
2003-10-17 00:37:53 +02:00
else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1)))
{
__tmp = this->underflow();
if (traits_type::eq_int_type(__tmp, __ret))
return __ret;
}
else
re PR libstdc++/9024 (Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)) 2003-06-05 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9024 * include/bits/fstream.tcc (_M_underflow): Fix for unbuffered. * include/bits/stl_algobase.h: Tweak. * include/std/std_fstream.h: Move _M_buf_size to... * include/std/std_streambuf.h: ...here. Modify. * include/bits/streambuf.tcc: Same. * testsuite/testsuite_hooks.h: Tweak. * testsuite/testsuite_io.h (constraint_filebuf): New. * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/3.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: New. * testsuite/data/sgetc.txt: New. * testsuite/data/sgetn.txt: New. From-SVN: r67524
2003-06-06 02:19:17 +02:00
{
// At the beginning of the buffer, need to make a
// putback position available. But the seek may fail
// (f.i., at the beginning of a file, see
// libstdc++/9439) and in that case we return
// traits_type::eof().
return __ret;
}
// Try to put back __i into input sequence in one of three ways.
// Order these tests done in is unspecified by the standard.
if (!__testeof && traits_type::eq_int_type(__i, __tmp))
__ret = __i;
else if (__testeof)
__ret = traits_type::not_eof(__i);
else if (!__testpb)
{
_M_create_pback();
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
_M_reading = true;
*this->gptr() = traits_type::to_char_type(__i);
__ret = __i;
}
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
overflow(int_type __c)
{
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = this->_M_mode & ios_base::out;
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (__testout && !_M_reading)
{
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (this->pbase() < this->pptr())
{
// If appropriate, append the overflow char.
if (!__testeof)
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
{
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
// Convert pending sequence to external representation,
// output.
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
if (_M_convert_to_external(this->pbase(),
this->pptr() - this->pbase())
&& (!__testeof || (__testeof && !_M_file.sync())))
{
_M_set_buffer(0);
__ret = traits_type::not_eof(__c);
}
}
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
else if (this->_M_buf_size > 1)
{
// Overflow in 'uncommitted' mode: set _M_writing, set
// the buffer to the initial 'write' mode, and put __c
// into the buffer.
_M_set_buffer(0);
_M_writing = true;
if (!__testeof)
{
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
__ret = traits_type::not_eof(__c);
}
else
{
// Unbuffered.
char_type __conv = traits_type::to_char_type(__c);
if (__testeof || _M_convert_to_external(&__conv, 1))
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
{
_M_writing = true;
__ret = traits_type::not_eof(__c);
}
}
}
return __ret;
}
template<typename _CharT, typename _Traits>
2003-05-12 20:12:27 +02:00
bool
basic_filebuf<_CharT, _Traits>::
2003-05-12 20:12:27 +02:00
_M_convert_to_external(_CharT* __ibuf, streamsize __ilen)
{
2003-05-12 20:12:27 +02:00
// Sizes of external and pending output.
streamsize __elen = 0;
streamsize __plen = 0;
if (__check_facet(_M_codecvt).always_noconv())
{
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
__elen += _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
__plen += __ilen;
}
else
{
// Worst-case number of external bytes needed.
// XXX Not done encoding() == -1.
streamsize __blen = __ilen * _M_codecvt->max_length();
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
char* __bend;
const char_type* __iend;
codecvt_base::result __r;
__r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen,
__iend, __buf, __buf + __blen, __bend);
if (__r == codecvt_base::ok || __r == codecvt_base::partial)
__blen = __bend - __buf;
else if (__r == codecvt_base::noconv)
{
// Same as the always_noconv case above.
__buf = reinterpret_cast<char*>(__ibuf);
__blen = __ilen;
}
else
{
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
// Result == error.
__blen = 0;
}
if (__blen)
{
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
__elen += _M_file.xsputn(__buf, __blen);
__plen += __blen;
}
// Try once more for partial conversions.
if (__r == codecvt_base::partial)
{
const char_type* __iresume = __iend;
Nathan C. 2003-06-24 Paolo Carlini <pcarlini@unitus.it> Nathan C. Myers <ncm-nospam@cantrip.org> * include/std/std_fstream.h (_M_filepos): Remove. (_M_reading, _M_writing): New, encode the various I/O modes: 'read', 'write' and 'uncommitted'. (sync): If there is something to flush, do it, then go to 'uncommitted' mode. * include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal with three different cases: __off > 0 (upon underflow), __off == 0 (upon overflow), __off == -1 (upon open, setbuf, seekoff/pos). (_M_underflow): Don't call overflow, set _M_reading to true on success, tweak. (pbackfail): Set _M_reading to true on pback creation, tweak. (overflow): Don't seek, deal with overflow in 'uncommitted' mode, set _M_writing to true on success, tweak. (seekoff): Simplify, set _M_reading, _M_writing to false, call _M_set_buffer(-1) ('uncommitted'). (open, close, setbuf): Set _M_reading, _M_writing to false and call _M_set_buffer(-1), tweak. (basic_filebuf): Don't set _M_buf_unified. (_M_destroy_internal_buffer): Don't call setg and setp. * include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading, _M_writing and _M_set_buffer(-1). * include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur, _M_out_lim, _M_buf_unified): Remove. (basic_streambuf): Don't set _M_out_lim and _M_buf_unified. (setp): Don't set _M_out_lim. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for the new logic ('read', 'write' and 'uncommitted' modes): e.g., upon open the mode is 'uncommitted' and therefore the put area pointers are null. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto. * testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto. * testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto. * include/bits/fstream.tcc (showmanyc): Use only the documented derivation interface to basic_streambuf (gptr(), setg(), etc.) to work right with user specializations. * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc, xsgetn, xsputn, __copy_streambufs): Likewise. * include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc): Likewise. * include/std/std_fstream.h (_M_create_pback, _M_destroy_pback, xsgetn): Likewise. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
2003-06-24 15:48:11 +02:00
streamsize __rlen = this->pptr() - __iend;
__r = _M_codecvt->out(_M_state_cur, __iresume,
__iresume + __rlen, __iend, __buf,
__buf + __blen, __bend);
if (__r != codecvt_base::error)
{
__rlen = __bend - __buf;
[multiple changes] 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
2003-05-11 06:20:57 +02:00
__elen += _M_file.xsputn(__buf, __rlen);
__plen += __rlen;
}
}
}
2003-05-12 20:12:27 +02:00
return __elen && __elen == __plen;
}
template<typename _CharT, typename _Traits>
streamsize
basic_filebuf<_CharT, _Traits>::
xsputn(const _CharT* __s, streamsize __n)
{
streamsize __ret = 0;
// Optimization in the always_noconv() case, to be generalized in the
// future: when __n is sufficiently large we write directly instead of
// using the buffer.
const bool __testout = this->_M_mode & ios_base::out;
if (__testout && !_M_reading
&& __check_facet(_M_codecvt).always_noconv())
{
// Measurement would reveal the best choice.
const streamsize __chunk = 1ul << 10;
streamsize __bufavail = this->epptr() - this->pptr();
// Don't mistake 'uncommitted' mode buffered with unbuffered.
if (!_M_writing && this->_M_buf_size > 1)
__bufavail = this->_M_buf_size - 1;
const streamsize __limit = std::min(__chunk, __bufavail);
if (__n >= __limit)
{
const streamsize __buffill = this->pptr() - this->pbase();
const char* __buf = reinterpret_cast<const char*>(this->pbase());
__ret = _M_file.xsputn_2(__buf, __buffill,
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
reinterpret_cast<const char*>(__s),
__n);
if (__ret == __buffill + __n)
{
_M_set_buffer(0);
_M_writing = true;
}
if (__ret > __buffill)
__ret -= __buffill;
else
__ret = 0;
}
else
__ret = __streambuf_type::xsputn(__s, __n);
}
else
__ret = __streambuf_type::xsputn(__s, __n);
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
basic_filebuf<_CharT, _Traits>::
setbuf(char_type* __s, streamsize __n)
{
if (!this->is_open())
if (__s == 0 && __n == 0)
this->_M_buf_size = 1;
else if (__s && __n > 0)
{
// This is implementation-defined behavior, and assumes that
// an external char_type array of length __n exists and has
// been pre-allocated. If this is not the case, things will
// quickly blow up. When __n > 1, __n - 1 positions will be
// used for the get area, __n - 1 for the put area and 1
// position to host the overflow char of a full put area.
// When __n == 1, 1 position will be used for the get area
// and 0 for the put area, as in the unbuffered case above.
this->_M_buf = __s;
this->_M_buf_size = __n;
}
return this;
}
// According to 27.8.1.4 p11 - 13, seekoff should ignore the last
// argument (of type openmode).
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
{
pos_type __ret = pos_type(off_type(-1));
int __width = 0;
if (_M_codecvt)
__width = _M_codecvt->encoding();
if (__width < 0)
__width = 0;
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
const bool __testfail = __off != 0 && __width <= 0;
if (this->is_open() && !__testfail)
{
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
// Correct state at destination. Note that this is the correct
// state for the current position during output, because
// codecvt::unshift() returns the state to the initial state.
// This is also the correct state at the end of the file because
// an unshift sequence should have been written at the end.
__state_type __state = _M_state_beg;
off_type __computed_off = __off * __width;
if (_M_reading && __way == ios_base::cur)
{
if (_M_codecvt->always_noconv())
__computed_off += this->gptr() - this->egptr();
else
{
// Calculate offset from _M_ext_buf that corresponds
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
// to gptr(). Note: uses _M_state_last, which
// corresponds to eback().
const int __gptr_off =
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
_M_codecvt->length(_M_state_last, _M_ext_buf, _M_ext_next,
this->gptr() - this->eback());
__computed_off += _M_ext_buf + __gptr_off - _M_ext_end;
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
// _M_state_last is modified by codecvt::length() so
// it now corresponds to gptr().
__state = _M_state_last;
}
}
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
__ret = _M_seek(__computed_off, __way, __state);
}
return __ret;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 171. Strange seekpos() semantics due to joint position
// According to the resolution of DR 171, seekpos should ignore the last
// argument (of type openmode).
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
seekpos(pos_type __pos, ios_base::openmode)
{
pos_type __ret = pos_type(off_type(-1));
if (this->is_open())
{
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
__ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state());
}
return __ret;
}
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
_M_seek(off_type __off, ios_base::seekdir __way, __state_type __state)
{
pos_type __ret = pos_type(off_type(-1));
if (_M_terminate_output())
{
// Returns pos_type(off_type(-1)) in case of failure.
__ret = pos_type(_M_file.seekoff(__off, __way));
_M_reading = false;
_M_writing = false;
_M_ext_next = _M_ext_end = _M_ext_buf;
_M_set_buffer(-1);
_M_state_cur = __state;
__ret.state(_M_state_cur);
}
return __ret;
}
template<typename _CharT, typename _Traits>
bool
basic_filebuf<_CharT, _Traits>::
_M_terminate_output()
{
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
bool __testvalid = true;
// Part one: update the output sequence.
if (this->pbase() < this->pptr())
{
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__testvalid = false;
}
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
// Part two: output unshift sequence.
if (_M_writing && !__check_facet(_M_codecvt).always_noconv()
&& __testvalid)
{
// Note: this value is arbitrary, since there is no way to
// get the length of the unshift sequence from codecvt,
// without calling unshift.
const size_t __blen = 128;
char __buf[__blen];
codecvt_base::result __r;
streamsize __ilen = 0;
do
{
char* __next;
__r = _M_codecvt->unshift(_M_state_cur, __buf,
__buf + __blen, __next);
if (__r == codecvt_base::error)
__testvalid = false;
else if (__r == codecvt_base::ok ||
__r == codecvt_base::partial)
{
__ilen = __next - __buf;
if (__ilen > 0)
{
const streamsize __elen = _M_file.xsputn(__buf, __ilen);
if (__elen != __ilen)
__testvalid = false;
}
}
}
while (__r == codecvt_base::partial && __ilen > 0 && __testvalid);
if (__testvalid)
{
// This second call to overflow() is required by the standard,
// but it's not clear why it's needed, since the output buffer
// should be empty by this point (it should have been emptied
// in the first call to overflow()).
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__testvalid = false;
}
}
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
return __testvalid;
}
template<typename _CharT, typename _Traits>
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
int
basic_filebuf<_CharT, _Traits>::
re PR libstdc++/12790 (basic_filebuf doesn't handle stateful encodings) 2003-11-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12790 * include/bits/fstream.tcc: Delete _M_last_overflowed. (basic_filebuf::basic_filebuf): Initialize _M_state_last. (basic_filebuf::open, basic_filebuf::close): Assign _M_state_beg to _M_state_cur and _M_state_last. (basic_filebuf::close): Call _M_terminate_output to handle unshift and flushing. (basic_filebuf::underflow): Assign _M_state_last, throw exception instead of calling abort when codecvt::max_length() is bad. (basic_filebuf::seekoff): Use _M_state_last when calling codecvt::length(), pass correct state to _M_seek. (basic_filebuf::seekpos): Pass __pos.state() to _M_seek. (basic_filebuf::_M_seek): Add __state_type parameter, set _M_state_cur correctly, store the resulting state in the return value and use _M_terminate_output to handle flushing and unshift. (basic_filebuf::_M_terminate_output): Flush contents of output buffer, if any, then call codecvt::unshift as needed and output the result. (basic_filebuf::sync): Move here, don't modify _M_writing or _M_reading. * include/std/std_fstream.h (basic_filebuf::_M_state_last): Declare it. (basic_filebuf::_M_last_overflowed): Delete. (basic_filebuf::_M_seek): Add __state_type parameter. (basic_filebuf::sync): Declare only. (basic_filebuf::_M_output_unshift): Delete. (basic_filebuf::_M_terminate_output): Declare it. * testsuite/testsuite_character.h: Define character class and state class plus char_traits and codecvt specializations for same for testing support for stateful encodings. * testsuite/27_io/basic_filebuf/close/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-1.cc, * testsuite/27_io/basic_filebuf/close/char/12790-2.cc, * testsuite/27_io/basic_filebuf/close/char/12790-3.cc, * testsuite/27_io/basic_filebuf/close/char/12790-4.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/open/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/seekoff/wchar_t/3.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-3.cc, * testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc, * testsuite/27_io/basic_filebuf/sync/char/1.cc, * testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: New tests. * testsuite/27_io/basic_filebuf/3.cc, * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc, * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc, * testsuite/27_io/basic_fstream/3.cc, * testsuite/27_io/basic_ifstream/3.cc, * testsuite/27_io/basic_ofstream/3.cc: Use streamoff as off_type and fpos<state_type> as pos_type. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc, * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Check that sync does *not* set _M_writing to false. From-SVN: r73245
2003-11-04 06:27:41 +01:00
sync()
{
int __ret = 0;
// Make sure that the internal buffer resyncs its idea of
// the file position with the external file.
// NB: _M_file.sync() will be called within.
if (this->pbase() < this->pptr())
{
const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__ret = -1;
}
return __ret;
}
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
imbue(const locale& __loc)
{
[multiple changes] 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. From-SVN: r72582
2003-10-17 00:37:53 +02:00
if (this->_M_buf_locale != __loc)
{
[multiple changes] 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. From-SVN: r72582
2003-10-17 00:37:53 +02:00
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.
}
}
}
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.
#if _GLIBCXX_EXTERN_TEMPLATE
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
extern template class basic_filebuf<char>;
extern template class basic_ifstream<char>;
extern template class basic_ofstream<char>;
extern template class basic_fstream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
extern template class basic_filebuf<wchar_t>;
extern template class basic_ifstream<wchar_t>;
extern template class basic_ofstream<wchar_t>;
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
extern template class basic_fstream<wchar_t>;
#endif
#endif
} // namespace std
#endif