summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-25 06:36:32 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-25 06:36:32 +0000
commitda9b3b51a4e221a071d52186112357e6e0ce00c3 (patch)
tree147b43df3b19f4ab2a95375185b83cdba58dbace /libstdc++-v3/include
parent8250ae22de60a5a6da47c1d02628a78dd689d251 (diff)
downloadppe42-gcc-da9b3b51a4e221a071d52186112357e6e0ce00c3.tar.gz
ppe42-gcc-da9b3b51a4e221a071d52186112357e6e0ce00c3.zip
2002-01-24 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/27_io/ostream_inserter_char.cc (test07): New. 2002-01-24 Benjamin Kosnik <bkoz@redhat.com> * include/bits/basic_ios.h (basic_ios::_M_check_facet): Make const, tweak. (basic_ios::fill(char_type)): Use fill(). * include/bits/basic_ios.tcc (basic_ios::widen): Use _M_check_facet. (basic_ios::narrow): Same. (basic_ios::_M_cache_facets): Explicitly set cached facets to zero if they are invalid. (basic_ios::init): Comment. * testsuite/27_io/ios_init.cc (test02): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49205 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/basic_ios.h16
-rw-r--r--libstdc++-v3/include/bits/basic_ios.tcc39
2 files changed, 38 insertions, 17 deletions
diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h
index cc393aaf311..f680a508206 100644
--- a/libstdc++-v3/include/bits/basic_ios.h
+++ b/libstdc++-v3/include/bits/basic_ios.h
@@ -1,6 +1,6 @@
// Iostreams base classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002 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
@@ -62,12 +62,11 @@ namespace std
typedef num_get<_CharT, __istreambuf_iter> __numget_type;
// Data members:
- private:
+ protected:
basic_ostream<_CharT, _Traits>* _M_tie;
char_type _M_fill;
iostate _M_exception;
- protected:
basic_streambuf<_CharT, _Traits>* _M_streambuf;
iostate _M_streambuf_state;
@@ -174,7 +173,7 @@ namespace std
inline char_type
fill(char_type __ch)
{
- char_type __old = _M_fill;
+ char_type __old = this->fill();
_M_fill = __ch;
return __old;
}
@@ -198,14 +197,11 @@ namespace std
init(basic_streambuf<_CharT, _Traits>* __sb);
bool
- _M_check_facet(const locale::facet* __f)
+ _M_check_facet(const locale::facet* __f) const
{
- bool __ret = false;
- if (__f)
- __ret = true;
- else
+ if (!__f)
__throw_bad_cast();
- return __ret;
+ return true;
}
void
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc
index 47d940bd69c..d1f5d19b33c 100644
--- a/libstdc++-v3/include/bits/basic_ios.tcc
+++ b/libstdc++-v3/include/bits/basic_ios.tcc
@@ -1,6 +1,6 @@
// basic_ios locale and locale-related member functions -*- C++ -*-
-// Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2001, 2002 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
@@ -91,12 +91,22 @@ namespace std
template<typename _CharT, typename _Traits>
char
basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
- { return _M_ios_fctype->narrow(__c, __dfault); }
+ {
+ char __ret;
+ if (_M_check_facet(_M_ios_fctype))
+ __ret = _M_ios_fctype->narrow(__c, __dfault);
+ return __ret;
+ }
template<typename _CharT, typename _Traits>
_CharT
basic_ios<_CharT, _Traits>::widen(char __c) const
- { return _M_ios_fctype->widen(__c); }
+ {
+ char_type __ret;
+ if (_M_check_facet(_M_ios_fctype))
+ __ret = _M_ios_fctype->widen(__c);
+ return __ret;
+ }
// Locales:
template<typename _CharT, typename _Traits>
@@ -119,7 +129,19 @@ namespace std
ios_base::_M_init();
_M_cache_facets(_M_ios_locale);
_M_tie = 0;
+
+ // NB: The 27.4.4.1 Postconditions Table only specifies
+ // requirements after basic_ios::init() has been called. As part
+ // of this, fill() must return widen(' '), which needs an imbued
+ // ctype facet of char_type to return without throwing an
+ // exception. This is not a required facet, so streams with
+ // char_type != [char, wchar_t] will not have it by
+ // default. However, because fill()'s signature is const, this
+ // data member cannot be lazily initialized. Thus, thoughts of
+ // using a non-const helper function in ostream inserters is
+ // really besides the point.
_M_fill = this->widen(' ');
+
_M_exception = goodbit;
_M_streambuf = __sb;
_M_streambuf_state = __sb ? goodbit : badbit;
@@ -131,15 +153,18 @@ namespace std
{
if (has_facet<__ctype_type>(__loc))
_M_ios_fctype = &use_facet<__ctype_type>(__loc);
+ else
+ _M_ios_fctype = 0;
// Should be filled in by ostream and istream, respectively.
if (has_facet<__numput_type>(__loc))
_M_fnumput = &use_facet<__numput_type>(__loc);
+ else
+ _M_fnumput = 0;
if (has_facet<__numget_type>(__loc))
_M_fnumget = &use_facet<__numget_type>(__loc);
+ else
+ _M_fnumget = 0;
}
} // namespace std
-#endif // _CPP_BITS_BASICIOS_TCC
-
-
-
+#endif
OpenPOWER on IntegriCloud