ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls.
2002-04-02 Benjamin Kosnik <bkoz@redhat.com> libstdc++/5268 * src/ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls. * testsuite/27_io/ios_init.cc (tests04): Add test. libstdc++/3983 * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. (basic_ios::_M_ios_fctype): Consistently name to _M_fctype. * include/bits/basic_ios.tcc: Same. Remove outdated comments. * include/bits/istream.tcc: Use _M_fctype, make consistent with ostream. * testsuite/27_io/ios_init.cc (tests03): Add test. From-SVN: r51777
This commit is contained in:
parent
7a145e929d
commit
40e5b28399
6 changed files with 115 additions and 40 deletions
|
@ -1,3 +1,17 @@
|
|||
2002-04-02 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
libstdc++/5268
|
||||
* src/ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls.
|
||||
* testsuite/27_io/ios_init.cc (tests04): Add test.
|
||||
|
||||
libstdc++/3983
|
||||
* include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove.
|
||||
(basic_ios::_M_ios_fctype): Consistently name to _M_fctype.
|
||||
* include/bits/basic_ios.tcc: Same. Remove outdated comments.
|
||||
* include/bits/istream.tcc: Use _M_fctype, make consistent with
|
||||
ostream.
|
||||
* testsuite/27_io/ios_init.cc (tests03): Add test.
|
||||
|
||||
2002-04-02 Phil Edwards <pme@gcc.gnu.org>
|
||||
|
||||
* include/Makefile.am (install-data-local): Use mkinstalldirs.
|
||||
|
|
|
@ -69,17 +69,13 @@ namespace std
|
|||
basic_streambuf<_CharT, _Traits>* _M_streambuf;
|
||||
|
||||
// Cached use_facet<ctype>, which is based on the current locale info.
|
||||
const __ctype_type* _M_ios_fctype;
|
||||
const __ctype_type* _M_fctype;
|
||||
// From ostream.
|
||||
const __numput_type* _M_fnumput;
|
||||
// From istream.
|
||||
const __numget_type* _M_fnumget;
|
||||
|
||||
public:
|
||||
const __ctype_type*
|
||||
_M_get_fctype_ios(void)
|
||||
{ return _M_ios_fctype; }
|
||||
|
||||
operator void*() const
|
||||
{ return this->fail() ? 0 : const_cast<basic_ios*>(this); }
|
||||
|
||||
|
|
|
@ -67,12 +67,6 @@ namespace std
|
|||
_Words* __words = (__rhs._M_word_size <= _S_local_word_size) ?
|
||||
_M_local_word : new _Words[__rhs._M_word_size];
|
||||
|
||||
// XXX This is the only reason _Callback_list was defined
|
||||
// inline. The suspicion is that this increased compilation
|
||||
// times dramatically for functions that use this member
|
||||
// function (inserters_extractors, ios_manip_fmtflags). FIX ME,
|
||||
// clean this stuff up. Callbacks are broken right now, anyway.
|
||||
|
||||
// Bump refs before doing callbacks, for safety.
|
||||
_Callback_list* __cb = __rhs._M_callbacks;
|
||||
if (__cb)
|
||||
|
@ -113,8 +107,8 @@ namespace std
|
|||
basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
|
||||
{
|
||||
char __ret = __dfault;
|
||||
if (_M_check_facet(_M_ios_fctype))
|
||||
__ret = _M_ios_fctype->narrow(__c, __dfault);
|
||||
if (_M_check_facet(_M_fctype))
|
||||
__ret = _M_fctype->narrow(__c, __dfault);
|
||||
return __ret;
|
||||
}
|
||||
|
||||
|
@ -123,8 +117,8 @@ namespace std
|
|||
basic_ios<_CharT, _Traits>::widen(char __c) const
|
||||
{
|
||||
char_type __ret = char_type();
|
||||
if (_M_check_facet(_M_ios_fctype))
|
||||
__ret = _M_ios_fctype->widen(__c);
|
||||
if (_M_check_facet(_M_fctype))
|
||||
__ret = _M_fctype->widen(__c);
|
||||
return __ret;
|
||||
}
|
||||
|
||||
|
@ -175,9 +169,9 @@ namespace std
|
|||
basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
|
||||
{
|
||||
if (has_facet<__ctype_type>(__loc))
|
||||
_M_ios_fctype = &use_facet<__ctype_type>(__loc);
|
||||
_M_fctype = &use_facet<__ctype_type>(__loc);
|
||||
else
|
||||
_M_ios_fctype = 0;
|
||||
_M_fctype = 0;
|
||||
// Should be filled in by ostream and istream, respectively.
|
||||
if (has_facet<__numput_type>(__loc))
|
||||
_M_fnumput = &use_facet<__numput_type>(__loc);
|
||||
|
|
|
@ -50,12 +50,13 @@ namespace std
|
|||
if (!__noskipws && (__in.flags() & ios_base::skipws))
|
||||
{
|
||||
const __int_type __eof = traits_type::eof();
|
||||
const __ctype_type* __ctype = __in._M_get_fctype_ios();
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
__int_type __c = __sb->sgetc();
|
||||
|
||||
while (__c != __eof && __ctype->is(ctype_base::space, __c))
|
||||
__c = __sb->snextc();
|
||||
|
||||
if (__in._M_check_facet(__in._M_fctype))
|
||||
while (__c != __eof
|
||||
&& __in._M_fctype->is(ctype_base::space, __c))
|
||||
__c = __sb->snextc();
|
||||
|
||||
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||
//195. Should basic_istream::sentry's constructor ever set eofbit?
|
||||
|
@ -1098,12 +1099,12 @@ namespace std
|
|||
if (__num == 0)
|
||||
__num = numeric_limits<streamsize>::max();
|
||||
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
const __ctype_type* __ctype = __in._M_get_fctype_ios();
|
||||
int_type __c = __sb->sbumpc();
|
||||
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
|
||||
const int_type __eof = _Traits::eof();
|
||||
bool __testsp = __ctype->is(ctype_base::space, __c);
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
int_type __c = __sb->sbumpc();
|
||||
bool __testeof = __c == __eof;
|
||||
bool __testsp = __ctype.is(ctype_base::space, __c);
|
||||
|
||||
while (__extracted < __num - 1 && !__testeof && !__testsp)
|
||||
{
|
||||
|
@ -1111,7 +1112,7 @@ namespace std
|
|||
++__extracted;
|
||||
__c = __sb->sbumpc();
|
||||
__testeof = __c == __eof;
|
||||
__testsp = __ctype->is(ctype_base::space, __c);
|
||||
__testsp = __ctype.is(ctype_base::space, __c);
|
||||
}
|
||||
|
||||
if (!__testeof)
|
||||
|
@ -1150,8 +1151,8 @@ namespace std
|
|||
typedef typename __istream_type::int_type __int_type;
|
||||
typedef typename __istream_type::char_type __char_type;
|
||||
|
||||
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
const __ctype_type* __ctype = __in._M_get_fctype_ios();
|
||||
const __int_type __eof = _Traits::eof();
|
||||
__int_type __c;
|
||||
bool __testeof;
|
||||
|
@ -1160,8 +1161,8 @@ namespace std
|
|||
do
|
||||
{
|
||||
__c = __sb->sbumpc();
|
||||
__testeof = __c == __eof;
|
||||
__testsp = __ctype->is(ctype_base::space, __c);
|
||||
__testeof = __c == __eof;
|
||||
__testsp = __ctype.is(ctype_base::space, __c);
|
||||
}
|
||||
while (!__testeof && __testsp);
|
||||
|
||||
|
@ -1195,12 +1196,12 @@ namespace std
|
|||
__size_type __n;
|
||||
__n = __w > 0 ? static_cast<__size_type>(__w) : __str.max_size();
|
||||
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
const __ctype_type* __ctype = __in._M_get_fctype_ios();
|
||||
__int_type __c = __sb->sbumpc();
|
||||
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
|
||||
const __int_type __eof = _Traits::eof();
|
||||
bool __testsp = __ctype->is(ctype_base::space, __c);
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
__int_type __c = __sb->sbumpc();
|
||||
bool __testeof = __c == __eof;
|
||||
bool __testsp = __ctype.is(ctype_base::space, __c);
|
||||
|
||||
while (__extracted < __n && !__testeof && !__testsp)
|
||||
{
|
||||
|
@ -1208,7 +1209,7 @@ namespace std
|
|||
++__extracted;
|
||||
__c = __sb->sbumpc();
|
||||
__testeof = __c == __eof;
|
||||
__testsp = __ctype->is(ctype_base::space, __c);
|
||||
__testsp = __ctype.is(ctype_base::space, __c);
|
||||
}
|
||||
if (!__testeof)
|
||||
__sb->sputbackc(__c);
|
||||
|
|
|
@ -190,16 +190,10 @@ namespace std
|
|||
// 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.
|
||||
cout.flush();
|
||||
cerr.flush();
|
||||
clog.flush();
|
||||
buf_cout.~filebuf();
|
||||
buf_cin.~filebuf();
|
||||
buf_cerr.~filebuf();
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
wcout.flush();
|
||||
wcerr.flush();
|
||||
wclog.flush();
|
||||
buf_wcout.~wfilebuf();
|
||||
buf_wcin.~wfilebuf();
|
||||
buf_wcerr.~wfilebuf();
|
||||
|
|
|
@ -132,6 +132,80 @@ void test02()
|
|||
VERIFY( test );
|
||||
}
|
||||
|
||||
// libstdc++/3983
|
||||
void test03()
|
||||
{
|
||||
using namespace std;
|
||||
bool test = true;
|
||||
|
||||
// input streams
|
||||
basic_istringstream<unsigned char> iss_uc;
|
||||
unsigned char arr[6] = { 'a', 'b', 'c', 'd', 'e' };
|
||||
|
||||
// Sentry uses locale info, so have to try one formatted input.
|
||||
try
|
||||
{
|
||||
int i;
|
||||
iss_uc >> i;
|
||||
}
|
||||
catch (bad_cast& obj)
|
||||
{ }
|
||||
catch (exception& obj)
|
||||
{ test = false; }
|
||||
|
||||
try
|
||||
{
|
||||
iss_uc >> arr;
|
||||
}
|
||||
catch (bad_cast& obj)
|
||||
{ }
|
||||
catch (exception& obj)
|
||||
{ test = false; }
|
||||
|
||||
try
|
||||
{
|
||||
iss_uc >> ws;
|
||||
}
|
||||
catch (bad_cast& obj)
|
||||
{ }
|
||||
catch (exception& obj)
|
||||
{ test = false; }
|
||||
|
||||
try
|
||||
{
|
||||
basic_string<unsigned char> s_uc(arr);
|
||||
iss_uc >> s_uc;
|
||||
}
|
||||
catch (bad_cast& obj)
|
||||
{ }
|
||||
catch (exception& obj)
|
||||
{ test = false; }
|
||||
|
||||
// output streams
|
||||
basic_ostringstream<unsigned char> oss_uc;
|
||||
|
||||
try
|
||||
{
|
||||
bool b = true;
|
||||
oss_uc << b;
|
||||
}
|
||||
catch (bad_cast& obj)
|
||||
{ }
|
||||
catch (exception& obj)
|
||||
{ test = false; }
|
||||
|
||||
VERIFY( test );
|
||||
}
|
||||
|
||||
// libstdc++/5268
|
||||
int test04()
|
||||
{
|
||||
std::stringbuf b1;
|
||||
std::cout.rdbuf( &b1 );
|
||||
std::cout << "hello\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !__GXX_WEAK__
|
||||
// Explicitly instantiate for systems with no COMDAT or weak support.
|
||||
template
|
||||
|
@ -147,5 +221,7 @@ int main()
|
|||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
test04();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue