2000-04-22 04:33:34 +08:00
|
|
|
// Iostreams base classes -*- C++ -*-
|
|
|
|
|
2002-01-25 05:14:41 +08:00
|
|
|
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
|
|
|
|
// Free Software Foundation, Inc.
|
2000-04-22 04:33:34 +08:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING. If not, write to the Free
|
|
|
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
// USA.
|
|
|
|
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
|
|
|
//
|
|
|
|
// ISO C++ 14882: 27.4 Iostreams base classes
|
|
|
|
//
|
|
|
|
|
Makefile.am (std_headers): Remove cXXX from list.
2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (std_headers): Remove cXXX from list.
(c_base_srcdir): No bits subdirectory.
(c_base_builddir): Same.
(c_base_headers): Adjust names, add ciso646.
(bits_headers): Remove std_xxx.h headers.
* include/Makefile.in: Regenerate.
* include/ext/iterator: Adjust includes.
* include/ext/ropeimpl.h: Same.
* include/ext/stl_hash_fun.h: Same.
* include/ext/algorithm: Same.
* include/backward/bvector.h: Adjust includes.
* include/backward/vector.h: Same.
* include/backward/strstream: Same.
* include/backward/streambuf.h: Same.
* include/backward/stack.h: Same.
* include/backward/set.h: Same.
* include/backward/queue.h: Same.
* include/backward/multiset.h: Same.
* include/backward/multimap.h: Same.
* include/backward/map.h: Same.
* include/backward/list.h: Same.
* include/backward/iterator.h: Same.
* include/backward/iostream.h: Same.
* include/backward/iomanip.h: Same.
* include/backward/fstream.h: Same.
* include/backward/deque.h: Same.
* include/backward/complex.h: Same.
* include/bits/std_algorithm.h: Move to...
* include/std/algorithm: ...here.
* include/bits/std_iosfwd.h, std_locale.h, std_stack.h,
std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h,
std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h,
std_deque.h, std_istream.h, std_numeric.h, std_string.h,
std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h,
std_queue.h, std_valarray.h, std_functional.h, std_limits.h,
std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h:
Same.
* include/c_std/bits/std_cassert.h: Move to...
* include/c_std/cassert: Here.
* include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c_std/cmath: Adjust cmath.tcc include.
* include/c_std/cstdlib: Adjust includes.
* include/c_std/cwchar: Same.
* include/c_std/ctime: Same.
* include/c_std/cstring: Same.
* include/c_std/cstdio: Same.
* include/c_std/bits: Remove directory.
* include/c/bits/std_cassert.h: Move to...
* include/c/cassert: Here.
* include/c/std_cctype.h, std_cerrno.h, std_cfloat.h,
std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h,
std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h,
std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h,
std_cwctype.h: Same.
* include/c/bits: Remove directory.
* include/std/cwctype: Remove.
* include/std/cwchar: Remove.
* include/std/ctime: Remove.
* include/std/cstring: Remove.
* include/std/cstdlib: Remove.
* include/std/cstdio: Remove.
* include/std/cstddef: Remove.
* include/std/cstdarg: Remove.
* include/std/csignal: Remove.
* include/std/csetjmp: Remove.
* include/std/cmath: Remove.
* include/std/clocale: Remove.
* include/std/climits: Remove.
* include/std/ciso646: Remove.
* include/std/cfloat: Remove.
* include/std/cerrno: Remove.
* include/std/cctype: Remove.
* include/std/cassert: Remove.
* include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h>
files and subsituting <.xxx>
* include/bits/valarray_array.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_algobase.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/pthread_allocimpl.h: Same.
* include/bits/ostream.tcc: Same.
* include/bits/localefwd.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/bits/locale_facets.h: Same.
* include/bits/istream.tcc: Same.
* include/bits/char_traits.h: Same.
* include/bits/boost_concept_check.h: Same.
* include/bits/basic_file.h: Same.
* include/std/bitset: Same.
* include/std/complex: Same.
* include/std/fstream: Same.
* include/std/functional: Same.
* include/std/ios: Same.
* include/std/iostream: Same.
* include/std/ostream: Same.
* include/std/sstream: Same.
* include/std/streambuf: Same.
* include/std/string: Same.
* include/std/iterator: Same.
* include/std/valarray: Same.
* src/ios.cc: Adjust includes.
* src/valarray-inst.cc: Same.
* src/string-inst.cc: Same.
* src/stl-inst.cc: Same.
* src/stdexcept.cc: Same.
* src/misc-inst.cc: Same.
* src/localename.cc: Same.
* src/locale-inst.cc: Same.
* src/locale.cc: Same.
* src/limits.cc: Same.
* src/concept-inst.cc: Same.
* src/complex_io.cc: Same.
* src/codecvt.cc: Same.
* src/bitset.cc: Same.
* src/cmath.cc: Same.
From-SVN: r48544
2002-01-05 05:27:36 +08:00
|
|
|
#include <ios>
|
|
|
|
#include <ostream>
|
|
|
|
#include <istream>
|
|
|
|
#include <fstream>
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2002-01-25 05:14:41 +08:00
|
|
|
#include <bits/atomicity.h>
|
|
|
|
|
2001-01-06 10:44:11 +08:00
|
|
|
namespace std
|
|
|
|
{
|
2001-06-06 09:31:58 +08:00
|
|
|
// Extern declarations for global objects in src/globals.cc.
|
|
|
|
extern istream cin;
|
|
|
|
extern ostream cout;
|
|
|
|
extern ostream cerr;
|
|
|
|
extern ostream clog;
|
|
|
|
extern filebuf buf_cout;
|
|
|
|
extern filebuf buf_cin;
|
|
|
|
extern filebuf buf_cerr;
|
|
|
|
|
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
|
|
|
extern wistream wcin;
|
|
|
|
extern wostream wcout;
|
|
|
|
extern wostream wcerr;
|
|
|
|
extern wostream wclog;
|
|
|
|
extern wfilebuf buf_wcout;
|
|
|
|
extern wfilebuf buf_wcin;
|
|
|
|
extern wfilebuf buf_wcerr;
|
|
|
|
#endif
|
|
|
|
|
2000-09-01 16:58:07 +08:00
|
|
|
// Definitions for static const data members of __ios_flags.
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_boolalpha;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_dec;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_fixed;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_hex;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_internal;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_left;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_oct;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_right;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_scientific;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_showbase;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_showpoint;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_showpos;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_skipws;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_unitbuf;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_uppercase;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_adjustfield;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_basefield;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_floatfield;
|
|
|
|
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_badbit;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_eofbit;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_failbit;
|
|
|
|
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_app;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_ate;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_bin;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_in;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_out;
|
|
|
|
const __ios_flags::__int_type __ios_flags::_S_trunc;
|
|
|
|
|
|
|
|
// Definitions for static const members of ios_base.
|
2000-04-22 04:33:34 +08:00
|
|
|
const ios_base::fmtflags ios_base::boolalpha;
|
|
|
|
const ios_base::fmtflags ios_base::dec;
|
|
|
|
const ios_base::fmtflags ios_base::fixed;
|
|
|
|
const ios_base::fmtflags ios_base::hex;
|
|
|
|
const ios_base::fmtflags ios_base::internal;
|
|
|
|
const ios_base::fmtflags ios_base::left;
|
|
|
|
const ios_base::fmtflags ios_base::oct;
|
|
|
|
const ios_base::fmtflags ios_base::right;
|
|
|
|
const ios_base::fmtflags ios_base::scientific;
|
|
|
|
const ios_base::fmtflags ios_base::showbase;
|
|
|
|
const ios_base::fmtflags ios_base::showpoint;
|
|
|
|
const ios_base::fmtflags ios_base::showpos;
|
|
|
|
const ios_base::fmtflags ios_base::skipws;
|
|
|
|
const ios_base::fmtflags ios_base::unitbuf;
|
|
|
|
const ios_base::fmtflags ios_base::uppercase;
|
|
|
|
const ios_base::fmtflags ios_base::adjustfield;
|
|
|
|
const ios_base::fmtflags ios_base::basefield;
|
|
|
|
const ios_base::fmtflags ios_base::floatfield;
|
|
|
|
|
|
|
|
const ios_base::iostate ios_base::badbit;
|
|
|
|
const ios_base::iostate ios_base::eofbit;
|
|
|
|
const ios_base::iostate ios_base::failbit;
|
|
|
|
const ios_base::iostate ios_base::goodbit;
|
|
|
|
|
|
|
|
const ios_base::openmode ios_base::app;
|
|
|
|
const ios_base::openmode ios_base::ate;
|
|
|
|
const ios_base::openmode ios_base::binary;
|
|
|
|
const ios_base::openmode ios_base::in;
|
|
|
|
const ios_base::openmode ios_base::out;
|
|
|
|
const ios_base::openmode ios_base::trunc;
|
|
|
|
|
|
|
|
const ios_base::seekdir ios_base::beg;
|
|
|
|
const ios_base::seekdir ios_base::cur;
|
|
|
|
const ios_base::seekdir ios_base::end;
|
|
|
|
|
2001-01-11 01:24:11 +08:00
|
|
|
const int ios_base::_S_local_words;
|
2000-09-01 16:58:07 +08:00
|
|
|
int ios_base::Init::_S_ios_base_init = 0;
|
2001-01-11 01:24:11 +08:00
|
|
|
bool ios_base::Init::_S_synced_with_stdio = true;
|
2000-09-01 16:58:07 +08:00
|
|
|
|
2001-01-17 15:44:57 +08:00
|
|
|
ios_base::failure::failure(const string& __str) throw()
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
|
|
|
strncpy(_M_name, __str.c_str(), _M_bufsize);
|
|
|
|
_M_name[_M_bufsize - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
2001-01-17 15:44:57 +08:00
|
|
|
ios_base::failure::~failure() throw()
|
2000-11-23 12:53:40 +08:00
|
|
|
{ }
|
|
|
|
|
|
|
|
const char*
|
|
|
|
ios_base::failure::what() const throw()
|
|
|
|
{ return _M_name; }
|
|
|
|
|
2001-04-04 09:02:26 +08:00
|
|
|
void
|
|
|
|
ios_base::Init::_S_ios_create(bool __sync)
|
|
|
|
{
|
2001-07-03 04:50:40 +08:00
|
|
|
int __out_bufsize = __sync ? 0 : static_cast<int>(BUFSIZ);
|
|
|
|
int __in_bufsize = __sync ? 1 : static_cast<int>(BUFSIZ);
|
|
|
|
|
|
|
|
#if _GLIBCPP_AVOID_FSEEK
|
|
|
|
// Platforms that prefer to avoid fseek() calls on streams only
|
|
|
|
// get their desire when the C++-layer input buffer size is 1.
|
|
|
|
// This hack hurts performance but keeps correctness across
|
|
|
|
// all types of streams that might be attached to (e.g.) cin.
|
|
|
|
__in_bufsize = 1;
|
|
|
|
#endif
|
2001-06-06 09:31:58 +08:00
|
|
|
|
|
|
|
// NB: The file globals.cc creates the four standard files
|
2001-05-08 11:07:56 +08:00
|
|
|
// with NULL buffers. At this point, we swap out the dummy NULL
|
2001-06-06 09:31:58 +08:00
|
|
|
// [io]stream objects and buffers with the real deal.
|
2001-07-03 04:50:40 +08:00
|
|
|
new (&buf_cout) filebuf(stdout, ios_base::out, __out_bufsize);
|
|
|
|
new (&buf_cin) filebuf(stdin, ios_base::in, __in_bufsize);
|
|
|
|
new (&buf_cerr) filebuf(stderr, ios_base::out, __out_bufsize);
|
2001-06-06 09:31:58 +08:00
|
|
|
new (&cout) ostream(&buf_cout);
|
|
|
|
new (&cin) istream(&buf_cin);
|
|
|
|
new (&cerr) ostream(&buf_cerr);
|
|
|
|
new (&clog) ostream(&buf_cerr);
|
2001-04-04 09:02:26 +08:00
|
|
|
cin.tie(&cout);
|
|
|
|
cerr.flags(ios_base::unitbuf);
|
|
|
|
|
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2001-07-03 04:50:40 +08:00
|
|
|
new (&buf_wcout) wfilebuf(stdout, ios_base::out, __out_bufsize);
|
|
|
|
new (&buf_wcin) wfilebuf(stdin, ios_base::in, __in_bufsize);
|
|
|
|
new (&buf_wcerr) wfilebuf(stderr, ios_base::out, __out_bufsize);
|
2001-06-06 09:31:58 +08:00
|
|
|
new (&wcout) wostream(&buf_wcout);
|
|
|
|
new (&wcin) wistream(&buf_wcin);
|
|
|
|
new (&wcerr) wostream(&buf_wcerr);
|
|
|
|
new (&wclog) wostream(&buf_wcerr);
|
2001-04-04 09:02:26 +08:00
|
|
|
wcin.tie(&wcout);
|
|
|
|
wcerr.flags(ios_base::unitbuf);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ios_base::Init::_S_ios_destroy()
|
|
|
|
{
|
2001-06-06 09:31:58 +08:00
|
|
|
// Explicitly call dtors to free any memory that is dynamically
|
|
|
|
// allocated by filebuf ctor or member functions, but don't
|
|
|
|
// deallocate all memory by calling operator delete.
|
2001-04-04 09:02:26 +08:00
|
|
|
cout.flush();
|
|
|
|
cerr.flush();
|
|
|
|
clog.flush();
|
2001-06-06 09:31:58 +08:00
|
|
|
buf_cout.~filebuf();
|
|
|
|
buf_cin.~filebuf();
|
|
|
|
buf_cerr.~filebuf();
|
2000-04-22 04:33:34 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2001-04-04 09:02:26 +08:00
|
|
|
wcout.flush();
|
|
|
|
wcerr.flush();
|
|
|
|
wclog.flush();
|
2001-06-06 09:31:58 +08:00
|
|
|
buf_wcout.~wfilebuf();
|
|
|
|
buf_wcin.~wfilebuf();
|
|
|
|
buf_wcerr.~wfilebuf();
|
2000-04-22 04:33:34 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-06-06 09:31:58 +08:00
|
|
|
ios_base::Init::Init()
|
|
|
|
{
|
2001-07-04 10:39:02 +08:00
|
|
|
if (_S_ios_base_init == 0)
|
2001-06-06 09:31:58 +08:00
|
|
|
{
|
|
|
|
// Standard streams default to synced with "C" operations.
|
|
|
|
ios_base::Init::_S_synced_with_stdio = true;
|
|
|
|
_S_ios_create(ios_base::Init::_S_synced_with_stdio);
|
|
|
|
}
|
2001-07-04 10:39:02 +08:00
|
|
|
++_S_ios_base_init;
|
2001-06-06 09:31:58 +08:00
|
|
|
}
|
|
|
|
|
2000-04-22 04:33:34 +08:00
|
|
|
ios_base::Init::~Init()
|
|
|
|
{
|
2000-09-01 16:58:07 +08:00
|
|
|
if (--_S_ios_base_init == 0)
|
2001-04-04 09:02:26 +08:00
|
|
|
_S_ios_destroy();
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 27.4.2.5 ios_base storage functions
|
|
|
|
int
|
|
|
|
ios_base::xalloc() throw()
|
|
|
|
{
|
|
|
|
// XXX should be a symbol. (Reserve 0..3 for builtins.)
|
2002-01-25 05:14:41 +08:00
|
|
|
static _Atomic_word top = 0;
|
|
|
|
return __exchange_and_add(&top, 1) + 4;
|
|
|
|
// Implementation note: Initialize top to zero to ensure that
|
|
|
|
// initialization occurs before main() is started.
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 27.4.2.5 iword/pword storage
|
|
|
|
ios_base::_Words&
|
|
|
|
ios_base::_M_grow_words(int ix)
|
|
|
|
{
|
|
|
|
// Precondition: _M_word_limit <= ix
|
|
|
|
_Words zero = { 0, 0 };
|
|
|
|
int newlimit = _S_local_words;
|
|
|
|
_Words* words = _M_word_array;
|
|
|
|
int i = 0;
|
|
|
|
if (_S_local_words <= ix)
|
|
|
|
{
|
|
|
|
newlimit = ix+1;
|
|
|
|
try
|
|
|
|
{ words = new _Words[ix+1]; }
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
_M_dummy = zero; // XXX MT? Not on "normal" machines.
|
|
|
|
// XXX now in basic_ios
|
|
|
|
// _M_clear(_M_rdstate() | badbit); // may throw
|
|
|
|
return _M_dummy;
|
|
|
|
}
|
2000-12-20 16:04:41 +08:00
|
|
|
for (; i < _M_word_limit; i++)
|
|
|
|
words[i] = _M_words[i];
|
2002-02-26 12:55:48 +08:00
|
|
|
if (_M_words && _M_words != _M_word_array)
|
2000-12-20 16:04:41 +08:00
|
|
|
delete [] _M_words;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
do { words[i] = zero; } while (++i < newlimit);
|
|
|
|
_M_words = words;
|
|
|
|
_M_word_limit = newlimit;
|
|
|
|
return words[ix];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called only by basic_ios<>::init.
|
|
|
|
void
|
|
|
|
ios_base::_M_init()
|
|
|
|
{
|
|
|
|
// NB: May be called more than once
|
|
|
|
_M_precision = 6;
|
2001-01-06 10:44:11 +08:00
|
|
|
_M_width = 0;
|
|
|
|
_M_flags = skipws | dec;
|
2000-04-22 04:33:34 +08:00
|
|
|
_M_callbacks = 0;
|
|
|
|
_M_words = 0;
|
|
|
|
_M_word_limit = 0;
|
2000-07-19 16:04:38 +08:00
|
|
|
_M_ios_locale = locale();
|
2000-04-22 04:33:34 +08:00
|
|
|
// No init needed for _M_word_array or _M_dummy.
|
|
|
|
}
|
|
|
|
|
|
|
|
// 27.4.2.3 ios_base locale functions
|
|
|
|
locale
|
|
|
|
ios_base::imbue(const locale& __loc)
|
|
|
|
{
|
2000-07-19 16:04:38 +08:00
|
|
|
locale __old = _M_ios_locale;
|
|
|
|
_M_ios_locale = __loc;
|
2000-04-22 04:33:34 +08:00
|
|
|
_M_call_callbacks(imbue_event);
|
|
|
|
return __old;
|
|
|
|
}
|
|
|
|
|
|
|
|
ios_base::ios_base()
|
|
|
|
{
|
2002-02-26 12:55:48 +08:00
|
|
|
// Do nothing: basic_ios::init() does it.
|
|
|
|
// NB: _M_callbacks and _M_words must be zero for non-initialized
|
|
|
|
// ios_base to go through ~ios_base gracefully.
|
|
|
|
_M_callbacks = 0;
|
|
|
|
_M_words = 0;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 27.4.2.7 ios_base constructors/destructors
|
|
|
|
ios_base::~ios_base()
|
|
|
|
{
|
|
|
|
_M_call_callbacks(erase_event);
|
|
|
|
_M_dispose_callbacks();
|
2002-02-26 12:55:48 +08:00
|
|
|
if (_M_words && _M_words != _M_word_array)
|
2000-04-22 04:33:34 +08:00
|
|
|
delete [] _M_words;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ios_base::register_callback(event_callback __fn, int __index)
|
|
|
|
{ _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
|
|
|
|
|
|
|
|
void
|
|
|
|
ios_base::_M_call_callbacks(event __e) throw()
|
|
|
|
{
|
2002-02-26 12:55:48 +08:00
|
|
|
_Callback_list* __p = _M_callbacks;
|
|
|
|
while (__p)
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2002-02-26 12:55:48 +08:00
|
|
|
try
|
|
|
|
{ (*__p->_M_fn) (__e, *this, __p->_M_index); }
|
|
|
|
catch (...)
|
|
|
|
{ }
|
|
|
|
__p = __p->_M_next;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ios_base::_M_dispose_callbacks(void)
|
|
|
|
{
|
|
|
|
_Callback_list* __p = _M_callbacks;
|
|
|
|
while (__p && __p->_M_remove_reference() == 0)
|
|
|
|
{
|
|
|
|
_Callback_list* __next = __p->_M_next;
|
|
|
|
delete __p;
|
|
|
|
__p = __next;
|
|
|
|
}
|
|
|
|
_M_callbacks = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ios_base::sync_with_stdio(bool __sync)
|
|
|
|
{
|
|
|
|
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
|
|
|
// 49. Underspecification of ios_base::sync_with_stdio
|
2001-01-11 01:24:11 +08:00
|
|
|
bool __ret = ios_base::Init::_S_synced_with_stdio;
|
2001-01-06 10:44:11 +08:00
|
|
|
#endif
|
2000-07-19 08:57:38 +08:00
|
|
|
|
2001-01-06 10:44:11 +08:00
|
|
|
// Turn off sync with C FILE* for cin, cout, cerr, clog iff
|
|
|
|
// currently synchronized.
|
2000-07-26 14:51:38 +08:00
|
|
|
if (!__sync && __ret)
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2001-01-11 01:24:11 +08:00
|
|
|
ios_base::Init::_S_synced_with_stdio = false;
|
2001-04-04 09:02:26 +08:00
|
|
|
ios_base::Init::_S_ios_destroy();
|
|
|
|
ios_base::Init::_S_ios_create(ios_base::Init::_S_synced_with_stdio);
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
2000-07-26 14:51:38 +08:00
|
|
|
return __ret;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
} // namespace std
|
|
|
|
|