Commit 86ade44c by Benjamin Kosnik Committed by Benjamin Kosnik

Numeric facets cleanup.


2001-11-27  Benjamin Kosnik  <bkoz@redhat.com>

	Numeric facets cleanup.
	* include/bits/locale_facets.h (__num_base::_S_atoms): Add, remove
	+ and - signs.
	(__num_base::_M_zero): Add
	(__num_base::_M_e): Add.
	(__num_base::_M_E): Add.
	* include/bits/locale_facets.tcc (num_get::_M_extract): Remove.
	(num_get::_M_extract_float): New.
	(num_get::_M_extract_int): New.
	* src/locale.cc (num_get::_M_extract): Remove.

	* include/bits/locale_facets.tcc (num_put::_M_insert_float):
	Simplify, use _M_insert.
	(num_put::do_put(bool)): Simplify, remove __pad.
	(__pad): Remove.
	(__pad_output): Change to __pad.
	* include/bits/ostream.tcc: And here.
	* src/locale-inst: Remove instantiations.

	* include/bits/locale_facets.h: Move helper functions in to class
	num_put.
	(num_put::_M_insert_float): Same, for __output_integer.
	(num_put::_M_insert_int): Same, for __output_float.
	(num_put::_M_insert): New.
	(__num_base): Add.
	(__num_base::_S_format_float): Move
	__build_float_format into class __num_base.
	(__num_base::_S_format_int): Move __build_int_format into class
	__num_base.
	* include/bits/locale_facets.tcc (__group_digits): Change to
	(__add_grouping): This.
	* src/locale-inst.cc: And here. Tweak instantiations.
	* src/misc-inst.cc: Remove instantiations.

	* include/bits/ostream.tcc (__pad_char): Rename, adjust inserters
	for new calling conventions, move to...
	* include/bits/locale_facets.tcc (__pad_output): Here. Adjust
	signature to make it useful for both ostream and num_put.
	(__pad_numeric): Remove.
	* src/misc-inst.cc: Remove instantiations.
	* src/locale-inst.cc: Same.

	* include/bits/locale_facets.h (_Numeric_get): Remove.
 	(_Numeric_put): Remove.
	(num_get::get(short)): Remove.
	(num_get::get(int)): Remove.
	(num_get::do_get(short)): Remove.
	(num_get::do_get(int)): Remove.
	* include/bits/istream.tcc (istream::operator>>(short)): Fix as
	per DR 118.
	(istream::operator>>(int)): Same.

	* include/bits/locale_facets.h (_Format_cache): Remove.
	* include/bits/locale_facets.tcc: Same.
	* src/locale.cc: Same.
	* src/locale-inst.cc: Same.
	* include/bits/ostream.tcc: Same.
	* src/ios.cc (ios_base::imbue): Remove here as well.

	* testsuite/22_locale/num_get.cc: New file.
	* testsuite/22_locale/num_get_members_char.cc: New file.
	* testsuite/22_locale/num_get_members_wchar_t.cc: New.
	* testsuite/22_locale/numpunct_members_wchar_t.cc: New file.
	* testsuite/22_locale/num_put.cc: New file.
	* testsuite/22_locale/num_put_members_char.cc: New file.
	* testsuite/22_locale/num_put_members_wchar_t.cc: New file.
	* testsuite/27_io/ostream_inserter_arith.cc: Fix.
	* testsuite/27_io/istream_extractor_arith.cc: Fix.

From-SVN: r47397
parent 59a64a46
2001-11-27 Benjamin Kosnik <bkoz@redhat.com>
Numeric facets cleanup.
* include/bits/locale_facets.h (__num_base::_S_atoms): Add, remove
+ and - signs.
(__num_base::_M_zero): Add
(__num_base::_M_e): Add.
(__num_base::_M_E): Add.
* include/bits/locale_facets.tcc (num_get::_M_extract): Remove.
(num_get::_M_extract_float): New.
(num_get::_M_extract_int): New.
* src/locale.cc (num_get::_M_extract): Remove.
* include/bits/locale_facets.tcc (num_put::_M_insert_float):
Simplify, use _M_insert.
(num_put::do_put(bool)): Simplify, remove __pad.
(__pad): Remove.
(__pad_output): Change to __pad.
* include/bits/ostream.tcc: And here.
* src/locale-inst: Remove instantiations.
* include/bits/locale_facets.h: Move helper functions in to class
num_put.
(num_put::_M_insert_float): Same, for __output_integer.
(num_put::_M_insert_int): Same, for __output_float.
(num_put::_M_insert): New.
(__num_base): Add.
(__num_base::_S_format_float): Move
__build_float_format into class __num_base.
(__num_base::_S_format_int): Move __build_int_format into class
__num_base.
* include/bits/locale_facets.tcc (__group_digits): Change to
(__add_grouping): This.
* src/locale-inst.cc: And here. Tweak instantiations.
* src/misc-inst.cc: Remove instantiations.
* include/bits/ostream.tcc (__pad_char): Rename, adjust inserters
for new calling conventions, move to...
* include/bits/locale_facets.tcc (__pad_output): Here. Adjust
signature to make it useful for both ostream and num_put.
(__pad_numeric): Remove.
* src/misc-inst.cc: Remove instantiations.
* src/locale-inst.cc: Same.
* include/bits/locale_facets.h (_Numeric_get): Remove.
(_Numeric_put): Remove.
(num_get::get(short)): Remove.
(num_get::get(int)): Remove.
(num_get::do_get(short)): Remove.
(num_get::do_get(int)): Remove.
* include/bits/istream.tcc (istream::operator>>(short)): Fix as
per DR 118.
(istream::operator>>(int)): Same.
* include/bits/locale_facets.h (_Format_cache): Remove.
* include/bits/locale_facets.tcc: Same.
* src/locale.cc: Same.
* src/locale-inst.cc: Same.
* include/bits/ostream.tcc: Same.
* src/ios.cc (ios_base::imbue): Remove here as well.
* testsuite/22_locale/num_get.cc: New file.
* testsuite/22_locale/num_get_members_char.cc: New file.
* testsuite/22_locale/num_get_members_wchar_t.cc: New.
* testsuite/22_locale/numpunct_members_wchar_t.cc: New file.
* testsuite/22_locale/num_put.cc: New file.
* testsuite/22_locale/num_put_members_char.cc: New file.
* testsuite/22_locale/num_put_members_wchar_t.cc: New file.
* testsuite/27_io/ostream_inserter_arith.cc: Fix.
* testsuite/27_io/istream_extractor_arith.cc: Fix.
2001-11-27 Phil Edwards <pme@gcc.gnu.org> 2001-11-27 Phil Edwards <pme@gcc.gnu.org>
* docs/html/explanations.html: New section, empty for now. * docs/html/explanations.html: New section, empty for now.
......
...@@ -134,8 +134,18 @@ namespace std ...@@ -134,8 +134,18 @@ namespace std
try try
{ {
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
long __l;
if (_M_check_facet(_M_fnumget)) if (_M_check_facet(_M_fnumget))
_M_fnumget->get(*this, 0, *this, __err, __n); _M_fnumget->get(*this, 0, *this, __err, __l);
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// 118. basic_istream uses nonexistent num_get member functions.
if (!(__err & ios_base::failbit)
&& (numeric_limits<short>::min() <= __l
&& __l <= numeric_limits<short>::max()))
__n = __l;
else
__err |= ios_base::failbit;
#endif
this->setstate(__err); this->setstate(__err);
} }
catch(exception& __fail) catch(exception& __fail)
...@@ -188,8 +198,18 @@ namespace std ...@@ -188,8 +198,18 @@ namespace std
try try
{ {
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
long __l;
if (_M_check_facet(_M_fnumget)) if (_M_check_facet(_M_fnumget))
_M_fnumget->get(*this, 0, *this, __err, __n); _M_fnumget->get(*this, 0, *this, __err, __l);
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// 118. basic_istream uses nonexistent num_get member functions.
if (!(__err & ios_base::failbit)
&& (numeric_limits<int>::min() <= __l
&& __l <= numeric_limits<int>::max()))
__n = __l;
else
__err |= ios_base::failbit;
#endif
this->setstate(__err); this->setstate(__err);
} }
catch(exception& __fail) catch(exception& __fail)
...@@ -1252,4 +1272,3 @@ namespace std ...@@ -1252,4 +1272,3 @@ namespace std
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
// End: // End:
...@@ -465,93 +465,6 @@ namespace std ...@@ -465,93 +465,6 @@ namespace std
} }
// 27.6.2.5.4 Character inserters // 27.6.2.5.4 Character inserters
// Construct correctly padded string, as per 22.2.2.2.2
// Similar in theory to __pad_numeric, from num_put, but it doesn't
// use _S_fill: perhaps it should.
// Assumes
// __newlen > __oldlen
// __news is allocated for __newlen size
template<typename _CharT, typename _Traits>
void
__pad_char(basic_ios<_CharT, _Traits>& __ios,
_CharT* __news, const _CharT* __olds,
const streamsize __newlen, const streamsize __oldlen)
{
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
int_type __plen = static_cast<size_t>(__newlen - __oldlen);
char_type* __pads = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __plen));
traits_type::assign(__pads, __plen, __ios.fill());
char_type* __beg;
char_type* __end;
size_t __mod = 0;
size_t __beglen; //either __plen or __oldlen
ios_base::fmtflags __adjust = __ios.flags() & ios_base::adjustfield;
if (__adjust == ios_base::left)
{
// Padding last.
__beg = const_cast<char_type*>(__olds);
__beglen = __oldlen;
__end = __pads;
}
else if (__adjust == ios_base::internal)
{
// Pad after the sign, if there is one.
// Pad after 0[xX], if there is one.
// Who came up with these rules, anyway? Jeeze.
typedef _Format_cache<_CharT> __cache_type;
__cache_type const* __fmt = __cache_type::_S_get(__ios);
const char_type* __minus = traits_type::find(__olds, __oldlen,
__fmt->_S_minus);
const char_type* __plus = traits_type::find(__olds, __oldlen,
__fmt->_S_plus);
bool __testsign = __minus || __plus;
bool __testhex = __olds[0] == '0'
&& (__olds[1] == 'x' || __olds[1] == 'X');
if (__testhex)
{
__news[0] = __olds[0];
__news[1] = __olds[1];
__mod += 2;
__beg = const_cast<char_type*>(__olds + __mod);
__beglen = __oldlen - __mod;
__end = __pads;
}
else if (__testsign)
{
__mod += __plen;
const char_type* __sign = __minus ? __minus + 1: __plus + 1;
__beg = const_cast<char_type*>(__olds);
__beglen = __sign - __olds;
__end = const_cast<char_type*>(__sign + __plen);
traits_type::copy(__news + __beglen, __pads, __plen);
}
else
{
// Padding first.
__beg = __pads;
__beglen = __plen;
__end = const_cast<char_type*>(__olds);
}
}
else
{
// Padding first.
__beg = __pads;
__beglen = __plen;
__end = const_cast<char_type*>(__olds);
}
traits_type::copy(__news, __beg, __beglen);
traits_type::copy(__news + __beglen, __end, __newlen - __beglen - __mod);
}
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
...@@ -568,7 +481,7 @@ namespace std ...@@ -568,7 +481,7 @@ namespace std
streamsize __len = 1; streamsize __len = 1;
if (__w > __len) if (__w > __len)
{ {
__pad_char(__out, __pads, &__c, __w, __len); __pad(__out, __out.fill(), __pads, &__c, __w, __len);
__len = __w; __len = __w;
} }
__out.write(__pads, __len); __out.write(__pads, __len);
...@@ -603,7 +516,7 @@ namespace std ...@@ -603,7 +516,7 @@ namespace std
streamsize __len = 1; streamsize __len = 1;
if (__w > __len) if (__w > __len)
{ {
__pad_char(__out, __pads, &__c, __w, __len); __pad(__out, __out.fill(), __pads, &__c, __w, __len);
__len = __w; __len = __w;
} }
__out.write(__pads, __len); __out.write(__pads, __len);
...@@ -636,7 +549,7 @@ namespace std ...@@ -636,7 +549,7 @@ namespace std
streamsize __len = static_cast<streamsize>(_Traits::length(__s)); streamsize __len = static_cast<streamsize>(_Traits::length(__s));
if (__w > __len) if (__w > __len)
{ {
__pad_char(__out, __pads, __s, __w, __len); __pad(__out, __out.fill(), __pads, __s, __w, __len);
__s = __pads; __s = __pads;
__len = __w; __len = __w;
} }
...@@ -682,7 +595,7 @@ namespace std ...@@ -682,7 +595,7 @@ namespace std
if (__w > __len) if (__w > __len)
{ {
__pad_char(__out, __pads, __ws, __w, __len); __pad(__out, __out.fill(), __pads, __ws, __w, __len);
__str = __pads; __str = __pads;
__len = __w; __len = __w;
} }
...@@ -717,7 +630,7 @@ namespace std ...@@ -717,7 +630,7 @@ namespace std
streamsize __len = static_cast<streamsize>(_Traits::length(__s)); streamsize __len = static_cast<streamsize>(_Traits::length(__s));
if (__w > __len) if (__w > __len)
{ {
__pad_char(__out, __pads, __s, __w, __len); __pad(__out, __out.fill(), __pads, __s, __w, __len);
__s = __pads; __s = __pads;
__len = __w; __len = __w;
} }
...@@ -755,7 +668,7 @@ namespace std ...@@ -755,7 +668,7 @@ namespace std
#endif #endif
if (__w > __len) if (__w > __len)
{ {
__pad_char(__out, __pads, __s, __w, __len); __pad(__out, __out.fill(), __pads, __s, __w, __len);
__s = __pads; __s = __pads;
__len = __w; __len = __w;
} }
......
...@@ -159,21 +159,21 @@ namespace std ...@@ -159,21 +159,21 @@ namespace std
inline __istream_type& inline __istream_type&
get(char_type* __s, streamsize __n) get(char_type* __s, streamsize __n)
{ return get(__s, __n, this->widen('\n')); } { return this->get(__s, __n, this->widen('\n')); }
__istream_type& __istream_type&
get(__streambuf_type& __sb, char_type __delim); get(__streambuf_type& __sb, char_type __delim);
inline __istream_type& inline __istream_type&
get(__streambuf_type& __sb) get(__streambuf_type& __sb)
{ return get(__sb, this->widen('\n')); } { return this->get(__sb, this->widen('\n')); }
__istream_type& __istream_type&
getline(char_type* __s, streamsize __n, char_type __delim); getline(char_type* __s, streamsize __n, char_type __delim);
inline __istream_type& inline __istream_type&
getline(char_type* __s, streamsize __n) getline(char_type* __s, streamsize __n)
{ return getline(__s, __n, this->widen('\n')); } { return this->getline(__s, __n, this->widen('\n')); }
__istream_type& __istream_type&
ignore(streamsize __n = 1, int_type __delim = traits_type::eof()); ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
...@@ -297,4 +297,3 @@ namespace std ...@@ -297,4 +297,3 @@ namespace std
#endif #endif
#endif /* _CPP_ISTREAM */ #endif /* _CPP_ISTREAM */
...@@ -171,8 +171,7 @@ namespace std ...@@ -171,8 +171,7 @@ namespace std
{ {
int_type __eof = traits_type::eof(); int_type __eof = traits_type::eof();
bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof; bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof;
bool __beof = !__b._M_sbuf bool __beof = !__b._M_sbuf || __b._M_sbuf->sgetc() == __eof;
|| __b._M_sbuf->sgetc() == __eof;
return (__thiseof && __beof || (!__thiseof && !__beof)); return (__thiseof && __beof || (!__thiseof && !__beof));
} }
...@@ -184,8 +183,7 @@ namespace std ...@@ -184,8 +183,7 @@ namespace std
{ {
int_type __eof = traits_type::eof(); int_type __eof = traits_type::eof();
bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof; bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof;
bool __beof = !__b._M_sbuf bool __beof = !__b._M_sbuf || __b._M_sbuf->sgetc() == __eof;
|| __b._M_sbuf->sgetc() == __eof;
return (__thiseof && __beof || (!__thiseof && !__beof)); return (__thiseof && __beof || (!__thiseof && !__beof));
} }
#endif #endif
......
...@@ -284,12 +284,6 @@ namespace std ...@@ -284,12 +284,6 @@ namespace std
{ {
locale __old = _M_ios_locale; locale __old = _M_ios_locale;
_M_ios_locale = __loc; _M_ios_locale = __loc;
// Make sure there's a callback for the format caches so they will be
// marked dirty.
_Format_cache<char>::_S_get(*this);
#ifdef _GLIBCPP_USE_WCHAR_T
_Format_cache<wchar_t>::_S_get(*this);
#endif
_M_call_callbacks(imbue_event); _M_call_callbacks(imbue_event);
return __old; return __old;
} }
......
...@@ -56,7 +56,6 @@ namespace std ...@@ -56,7 +56,6 @@ namespace std
template class moneypunct_byname<char, true>; template class moneypunct_byname<char, true>;
template class money_get<char, ibuf_iterator>; template class money_get<char, ibuf_iterator>;
template class money_put<char, obuf_iterator>; template class money_put<char, obuf_iterator>;
template class _Format_cache<char>;
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
template class moneypunct<wchar_t, false>; template class moneypunct<wchar_t, false>;
...@@ -65,19 +64,91 @@ namespace std ...@@ -65,19 +64,91 @@ namespace std
template class moneypunct_byname<wchar_t, true>; template class moneypunct_byname<wchar_t, true>;
template class money_get<wchar_t, wibuf_iterator>; template class money_get<wchar_t, wibuf_iterator>;
template class money_put<wchar_t, wobuf_iterator>; template class money_put<wchar_t, wobuf_iterator>;
template class _Format_cache<wchar_t>;
#endif #endif
// numpunct, numpunct_byname, num_get, and num_put // numpunct, numpunct_byname, num_get, and num_put
template class numpunct<char>; template class numpunct<char>;
template class numpunct_byname<char>; template class numpunct_byname<char>;
template class num_get<char, ibuf_iterator>; template class num_get<char, ibuf_iterator>;
template class num_put<char, obuf_iterator>; template class num_put<char, obuf_iterator>;
template
obuf_iterator
num_put<char, obuf_iterator>::
_M_convert_int(obuf_iterator, ios_base&, char, char, char, long) const;
template
obuf_iterator
num_put<char, obuf_iterator>::
_M_convert_int(obuf_iterator, ios_base&, char, char, char,
unsigned long) const;
#ifdef _GLIBCPP_USE_LONG_LONG
template
obuf_iterator
num_put<char, obuf_iterator>::
_M_convert_int(obuf_iterator, ios_base&, char, char, char,
long long) const;
template
obuf_iterator
num_put<char, obuf_iterator>::
_M_convert_int(obuf_iterator, ios_base&, char, char, char,
unsigned long long) const;
#endif
template
obuf_iterator
num_put<char, obuf_iterator>::
_M_convert_float(obuf_iterator, ios_base&, char, char, double) const;
template
obuf_iterator
num_put<char, obuf_iterator>::
_M_convert_float(obuf_iterator, ios_base&, char, char,
long double) const;
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
template class numpunct<wchar_t>; template class numpunct<wchar_t>;
template class numpunct_byname<wchar_t>; template class numpunct_byname<wchar_t>;
template class num_get<wchar_t, wibuf_iterator>; template class num_get<wchar_t, wibuf_iterator>;
template class num_put<wchar_t, wobuf_iterator>; template class num_put<wchar_t, wobuf_iterator>;
template
wobuf_iterator
num_put<wchar_t, wobuf_iterator>::
_M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char, long) const;
template
wobuf_iterator
num_put<wchar_t, wobuf_iterator>::
_M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char,
unsigned long) const;
#ifdef _GLIBCPP_USE_LONG_LONG
template
wobuf_iterator
num_put<wchar_t, wobuf_iterator>::
_M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char,
long long) const;
template
wobuf_iterator
num_put<wchar_t, wobuf_iterator>::
_M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char,
unsigned long long) const;
#endif
template
wobuf_iterator
num_put<wchar_t, wobuf_iterator>::
_M_convert_float(wobuf_iterator, ios_base&, wchar_t, char,
double) const;
template
wobuf_iterator
num_put<wchar_t, wobuf_iterator>::
_M_convert_float(wobuf_iterator, ios_base&, wchar_t, char,
long double) const;
#endif #endif
// time_get and time_put // time_get and time_put
...@@ -246,8 +317,8 @@ namespace std ...@@ -246,8 +317,8 @@ namespace std
typedef ostreambuf_iterator<char, char_traits<char> > ostreambuf_iter; typedef ostreambuf_iterator<char, char_traits<char> > ostreambuf_iter;
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
typedef istreambuf_iterator<wchar_t,char_traits<wchar_t> > wistreambuf_iter; typedef istreambuf_iterator<wchar_t, char_traits<wchar_t> > wistreambuf_iter;
typedef ostreambuf_iterator<wchar_t,char_traits<wchar_t> > wostreambuf_iter; typedef ostreambuf_iterator<wchar_t, char_traits<wchar_t> > wostreambuf_iter;
#endif #endif
template template
...@@ -255,36 +326,23 @@ namespace std ...@@ -255,36 +326,23 @@ namespace std
locale::operator()(const string&, const string&) const; locale::operator()(const string&, const string&) const;
template template
ostreambuf_iter
__pad<char, ostreambuf_iter, output_iterator_tag>
(ostreambuf_iter, char, int, output_iterator_tag);
template
ostreambuf_iter
__pad_numeric<char, ostreambuf_iter>
(ostreambuf_iter, ios_base::fmtflags, char, int, char const*, char const*,
char const*);
template
char* char*
__group_digits<char>(char*, char, char const*, char const*, __add_grouping<char>(char*, char, char const*, char const*,
char const*, char const*); char const*, char const*);
template template
bool bool
__verify_grouping<char>(const basic_string<char>&, basic_string<char>&); __verify_grouping<char>(const basic_string<char>&, basic_string<char>&);
template template
ostreambuf_iter void
__output_integer<char, ostreambuf_iter, unsigned long> __pad<char>(ios_base&, char, char*, const char *, streamsize,
(ostreambuf_iter, ios_base &, char, bool, unsigned long); streamsize);
#ifdef _GLIBCPP_USE_LONG_LONG
template template
ostreambuf_iter void
__output_integer<char, ostreambuf_iter, unsigned long long> __pad<char, char_traits<char> >(ios_base&, char, char*,
(ostreambuf_iter, ios_base &, char, bool, unsigned long long); const char *, streamsize, streamsize);
#endif
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
template template
...@@ -294,36 +352,24 @@ namespace std ...@@ -294,36 +352,24 @@ namespace std
typedef ostreambuf_iterator<wchar_t> wostreambuf_iter; typedef ostreambuf_iterator<wchar_t> wostreambuf_iter;
template template
wostreambuf_iter
__pad<wchar_t, wostreambuf_iter, output_iterator_tag>
(wostreambuf_iter, wchar_t, int, output_iterator_tag);
template
wostreambuf_iter
__pad_numeric<wchar_t, wostreambuf_iter>
(wostreambuf_iter, ios_base::fmtflags, wchar_t __fill, int, wchar_t const*,
wchar_t const*, wchar_t const*);
template
wchar_t* wchar_t*
__group_digits<wchar_t>(wchar_t*, wchar_t, char const*, char const*, __add_grouping<wchar_t>(wchar_t*, wchar_t, char const*, char const*,
wchar_t const*, wchar_t const*); wchar_t const*, wchar_t const*);
template template
bool bool
__verify_grouping<wchar_t>(const basic_string<wchar_t>&, __verify_grouping<wchar_t>(const basic_string<wchar_t>&,
basic_string<wchar_t>&); basic_string<wchar_t>&);
template template
wostreambuf_iter void
__output_integer<wchar_t, wostreambuf_iter, unsigned long> __pad<wchar_t>(ios_base&, wchar_t, wchar_t*, const wchar_t*,
(wostreambuf_iter, ios_base &, wchar_t, bool, unsigned long); streamsize, streamsize);
#ifdef _GLIBCPP_USE_LONG_LONG
template template
wostreambuf_iter void
__output_integer<wchar_t, wostreambuf_iter, unsigned long long> __pad<wchar_t, char_traits<wchar_t> >(ios_base&, wchar_t, wchar_t*,
(wostreambuf_iter, ios_base &, wchar_t, bool, unsigned long long); const wchar_t*,
#endif streamsize, streamsize);
#endif // _GLIBCPP_USE_WCHAR_T #endif // _GLIBCPP_USE_WCHAR_T
template template
...@@ -342,4 +388,3 @@ namespace std ...@@ -342,4 +388,3 @@ namespace std
__normal_iterator<locale::facet**, vector<locale::facet*> >, __normal_iterator<locale::facet**, vector<locale::facet*> >,
locale::facet* const&); locale::facet* const&);
} // namespace std } // namespace std
...@@ -242,39 +242,6 @@ namespace std ...@@ -242,39 +242,6 @@ namespace std
string*, __false_type); string*, __false_type);
template template
void
__pad_char(basic_ios<char>&, char*, const char*,
const streamsize, const streamsize);
#ifdef _GLIBCPP_USE_WCHAR_T
template
void
__pad_char(basic_ios<wchar_t>&, wchar_t*, const wchar_t*,
const streamsize, const streamsize);
#endif
template
ostreambuf_iterator<char>
__pad_numeric(ostreambuf_iterator<char>, _Ios_Fmtflags, char, int,
const char*, const char*, const char*);
#ifdef _GLIBCPP_USE_WCHAR_T
template
ostreambuf_iterator<wchar_t>
__pad_numeric(ostreambuf_iterator<wchar_t>, _Ios_Fmtflags, wchar_t, int,
const wchar_t*, const wchar_t*, const wchar_t*);
#endif
template
ostreambuf_iterator<char>
__output_float(ostreambuf_iterator<char>, ios_base&, char,
const char*, size_t);
#ifdef _GLIBCPP_USE_WCHAR_T
template
ostreambuf_iterator<wchar_t>
__output_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
const char*, size_t);
#endif
template
streamsize streamsize
__copy_streambufs(basic_ios<char>&, basic_streambuf<char>*, __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*,
basic_streambuf<char>*); basic_streambuf<char>*);
......
// 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// 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.
// 22.2.2.1 Template class num_get
#include <locale>
void test01()
{
// Check for required base class.
typedef std::num_get<char> test_type;
typedef std::locale::facet base_type;
const test_type& obj = std::use_facet<test_type>(std::locale());
const base_type* base = &obj;
// Check for required typedefs
typedef test_type::char_type char_type;
typedef test_type::iter_type iter_type;
}
// Should be able to instantiate this for other types besides char, wchar_t
class gnu_num_get: public std::num_get<unsigned char>
{ };
void test02()
{
gnu_num_get facet01;
}
int main()
{
test01();
test02();
return 0;
}
// 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// 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.
// 22.2.2.1.1 num_get members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// XXX This test is not working for non-glibc locale models.
// { dg-do run { xfail *-*-* } }
void test01()
{
using namespace std;
typedef istreambuf_iterator<char> iterator_type;
bool test = true;
// basic construction
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the numpunct facets
const numpunct<char>& numpunct_c = use_facet<numpunct<char> >(loc_c);
const numpunct<char>& numpunct_de = use_facet<numpunct<char> >(loc_de);
const numpunct<char>& numpunct_hk = use_facet<numpunct<char> >(loc_hk);
// sanity check the data is correct.
const string empty;
char c;
bool b1 = true;
bool b0 = false;
long l1 = 2147483647;
long l2 = -2147483647;
long l;
unsigned long ul1 = 1294967294;
unsigned long ul2 = 0;
unsigned long ul;
double d1 = 1.02345e+308;
double d2 = 3.15e-308;
double d;
long double ld1 = 6.630025e+4;
long double ld2 = 0.0;
long double ld;
void* v;
const void* cv = &ul2;
// cache the num_get facet
istringstream iss;
iss.imbue(loc_de);
const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
const ios_base::iostate goodbit = ios_base::goodbit;
const ios_base::iostate eofbit = ios_base::eofbit;
ios_base::iostate err = ios_base::goodbit;
// bool, simple
iss.str("1");
iterator_type os_it00 = iss.rdbuf();
iterator_type os_it01 = ng.get(os_it00, 0, iss, err, b1);
VERIFY( b1 == true );
VERIFY( err & ios_base::eofbit );
iss.str("0");
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, b0);
VERIFY( b0 == false );
VERIFY( err & eofbit );
// bool, more twisted examples
iss.imbue(loc_c);
iss.str("true ");
iss.clear();
iss.setf(ios_base::boolalpha);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, b0);
VERIFY( b0 == true );
VERIFY( err == goodbit );
iss.str("false ");
iss.clear();
iss.setf(ios_base::boolalpha);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, b1);
VERIFY( b1 == false );
VERIFY( err == goodbit );
// long, in a locale that expects grouping
iss.imbue(loc_hk);
iss.str("2,147,483,647 ");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, l);
VERIFY( l == l1 );
VERIFY( err == goodbit );
iss.str("-2,147,483,647++++++");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, l);
VERIFY( l == l2 );
VERIFY( err == goodbit );
// unsigned long, in a locale that does not group
iss.imbue(loc_c);
iss.str("1294967294");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, ul);
VERIFY( ul == ul1);
VERIFY( err == eofbit );
iss.str("0+++++++++++++++++++");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, ul);
VERIFY( ul == ul2);
VERIFY( err == goodbit );
// ... and one that does
iss.imbue(loc_de);
iss.str("1.294.967.294+++++++");
iss.clear();
iss.width(20);
iss.setf(ios_base::left, ios_base::adjustfield);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, ul);
VERIFY( ul == ul1 );
VERIFY( err == goodbit );
// double
iss.imbue(loc_c);
iss.str("1.02345e+308++++++++");
iss.clear();
iss.width(20);
iss.setf(ios_base::left, ios_base::adjustfield);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, d);
VERIFY( d == d1 );
VERIFY( err == goodbit );
iss.str("+3.15e-308");
iss.clear();
iss.width(20);
iss.setf(ios_base::right, ios_base::adjustfield);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, d);
VERIFY( d == d2 );
VERIFY( err == eofbit );
iss.imbue(loc_de);
iss.str("+1,02345e+308");
iss.clear();
iss.width(20);
iss.setf(ios_base::right, ios_base::adjustfield);
iss.setf(ios_base::scientific, ios_base::floatfield);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, d);
VERIFY( d == d1 );
VERIFY( err == eofbit );
iss.str("3,15E-308 ");
iss.clear();
iss.width(20);
iss.precision(10);
iss.setf(ios_base::right, ios_base::adjustfield);
iss.setf(ios_base::scientific, ios_base::floatfield);
iss.setf(ios_base::uppercase);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, d);
VERIFY( d == d2 );
VERIFY( err == goodbit );
// long double
iss.str("6,630025e+4");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, ld);
VERIFY( ld == ld1 );
VERIFY( err == eofbit );
iss.str("0 ");
iss.clear();
iss.precision(0);
iss.setf(ios_base::fixed, ios_base::floatfield);
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, ld);
VERIFY( ld == 0 );
VERIFY( err == goodbit );
// const void
iss.str("0xbffff74c.");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, v);
VERIFY( &v != &cv );
VERIFY( err == goodbit );
#ifdef _GLIBCPP_USE_LONG_LONG
long long ll1 = 9223372036854775807;
long long ll2 = -9223372036854775807;
long long ll;
iss.str("9.223.372.036.854.775.807");
iss.clear();
err = goodbit;
ng.get(iss.rdbuf(), 0, iss, err, ll);
VERIFY( ll == ll1 );
VERIFY( err == eofbit );
#endif
}
int main()
{
test01();
return 0;
}
// Kathleen Hannah, humanitarian, woman, art-thief
// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// 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.
// 22.2.2.2 Template class num_put
#include <locale>
void test01()
{
// Check for required base class.
typedef std::num_put<char> test_type;
typedef std::locale::facet base_type;
const test_type& obj = std::use_facet<test_type>(std::locale());
const base_type* base = &obj;
// Check for required typedefs
typedef test_type::char_type char_type;
typedef test_type::iter_type iter_type;
}
// Should be able to instantiate this for other types besides char, wchar_t
class gnu_num_put: public std::num_put<unsigned char>
{ };
void test02()
{
gnu_num_put facet01;
}
int main()
{
test01();
test02();
return 0;
}
// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// 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.
// 22.2.2.2.1 num_put members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// XXX This test is not working for non-glibc locale models.
// { dg-do run { xfail *-*-* } }
void test01()
{
using namespace std;
typedef ostreambuf_iterator<char> iterator_type;
bool test = true;
// basic construction
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the numpunct facets
const numpunct<char>& numpunct_c = use_facet<numpunct<char> >(loc_c);
const numpunct<char>& numpunct_de = use_facet<numpunct<char> >(loc_de);
const numpunct<char>& numpunct_hk = use_facet<numpunct<char> >(loc_hk);
// sanity check the data is correct.
const string empty;
string result1;
string result2;
char c;
bool b1 = true;
bool b0 = false;
long l1 = 2147483647;
long l2 = -2147483647;
unsigned long ul1 = 1294967294;
unsigned long ul2 = 0;
double d1 = 1.7976931348623157e+308;
double d2 = 2.2250738585072014e-308;
long double ld1 = 1.7976931348623157e+308;
long double ld2 = 2.2250738585072014e-308;
const void* cv = &ld1;
// cache the num_put facet
ostringstream oss;
oss.imbue(loc_de);
const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
// bool, simple
iterator_type os_it00 = oss.rdbuf();
iterator_type os_it01 = np.put(os_it00, oss, '+', b1);
result1 = oss.str();
VERIFY( result1 == "1" );
// VERIFY( os_it00 != os_it01 );
oss.str(empty);
np.put(oss.rdbuf(), oss, '+', b0);
result2 = oss.str();
VERIFY( result2 == "0" );
// bool, more twisted examples
oss.imbue(loc_c);
oss.str(empty);
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', b0);
result1 = oss.str();
VERIFY( result1 == "+++++++++++++++++++0" );
oss.str(empty);
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
oss.setf(ios_base::boolalpha);
np.put(oss.rdbuf(), oss, '+', b1);
result2 = oss.str();
VERIFY( result2 == "true++++++++++++++++" );
// long, in a locale that expects grouping
oss.imbue(loc_hk);
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, '+', l1);
result1 = oss.str();
VERIFY( result1 == "2,147,483,647" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', l2);
result1 = oss.str();
VERIFY( result1 == "-2,147,483,647++++++" );
// unsigned long, in a locale that does not group
oss.imbue(loc_c);
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, '+', ul1);
result1 = oss.str();
VERIFY( result1 == "1294967294" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', ul2);
result1 = oss.str();
VERIFY( result1 == "0+++++++++++++++++++" );
// ... and one that does
oss.imbue(loc_de);
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', ul1);
result1 = oss.str();
VERIFY( result1 == "1.294.967.294+++++++" );
// double
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', d1);
result1 = oss.str();
VERIFY( result1 == "1,79769e+308++++++++" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', d2);
result1 = oss.str();
VERIFY( result1 == "++++++++2,22507e-308" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield);
np.put(oss.rdbuf(), oss, '+', d2);
result2 = oss.str();
VERIFY( result2 == "+++++++2,225074e-308" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.precision(10);
oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield);
oss.setf(ios_base::uppercase);
np.put(oss.rdbuf(), oss, '+', d2);
result1 = oss.str();
VERIFY( result1 == "+++2,2250738585E-308" );
// long double
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, '+', ld1);
result1 = oss.str();
VERIFY( result1 == "1,7976931349E+308" );
oss.str(empty);
oss.clear();
oss.precision(0);
oss.setf(ios_base::fixed, ios_base::floatfield);
np.put(oss.rdbuf(), oss, '+', ld2);
result1 = oss.str();
VERIFY( result1 == "0" );
// const void
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, '+', cv);
result1 = oss.str();
// No grouping characters.
VERIFY( !char_traits<char>::find(result1.c_str(),
numpunct_de.decimal_point(),
result1.size()) );
// Should contain an 'x'.
VERIFY( !char_traits<char>::find(result1.c_str(), 'x', result1.size()) );
#ifdef _GLIBCPP_USE_LONG_LONG
long long ll1 = 9223372036854775807;
long long ll2 = -9223372036854775807;
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, '+', ll1);
result1 = oss.str();
VERIFY( result1 == "9.223.372.036.854.775.807" );
#endif
}
int main()
{
test01();
return 0;
}
// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// 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.
// 22.2.2.2.1 num_put members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// XXX This test is not working for non-glibc locale models.
// { dg-do run { xfail *-*-* } }
#ifdef _GLIBCPP_USE_WCHAR_T
void test01()
{
using namespace std;
typedef ostreambuf_iterator<wchar_t> iterator_type;
bool test = true;
// basic construction
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the numpunct facets
const numpunct<wchar_t>& numpunct_c = use_facet<numpunct<wchar_t> >(loc_c);
const numpunct<wchar_t>& numpunct_de = use_facet<numpunct<wchar_t> >(loc_de);
const numpunct<wchar_t>& numpunct_hk = use_facet<numpunct<wchar_t> >(loc_hk);
// sanity check the data is correct.
const wstring empty;
wstring result1;
wstring result2;
wchar_t c;
bool b1 = true;
bool b0 = false;
long l1 = 2147483647;
long l2 = -2147483647;
unsigned long ul1 = 1294967294;
unsigned long ul2 = 0;
double d1 = 1.7976931348623157e+308;
double d2 = 2.2250738585072014e-308;
long double ld1 = 1.7976931348623157e+308;
long double ld2 = 2.2250738585072014e-308;
const void* cv = &ld1;
// cache the num_put facet
wostringstream oss;
oss.imbue(loc_de);
const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
// bool, simple
iterator_type os_it00 = oss.rdbuf();
iterator_type os_it01 = np.put(os_it00, oss, '+', b1);
result1 = oss.str();
VERIFY( result1 == L"1" );
// VERIFY( os_it00 != os_it01 );
oss.str(empty);
np.put(oss.rdbuf(), oss, L'+', b0);
result2 = oss.str();
VERIFY( result2 == L"0" );
// bool, more twisted examples
oss.imbue(loc_c);
oss.str(empty);
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, L'+', b0);
result1 = oss.str();
VERIFY( result1 == L"+++++++++++++++++++0" );
oss.str(empty);
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
oss.setf(ios_base::boolalpha);
np.put(oss.rdbuf(), oss, L'+', b1);
result2 = oss.str();
VERIFY( result2 == L"true++++++++++++++++" );
// long, in a locale that expects grouping
oss.imbue(loc_hk);
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, L'+', l1);
result1 = oss.str();
VERIFY( result1 == L"2,147,483,647" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, L'+', l2);
result1 = oss.str();
VERIFY( result1 == L"-2,147,483,647++++++" );
// unsigned long, in a locale that does not group
oss.imbue(loc_c);
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, L'+', ul1);
result1 = oss.str();
VERIFY( result1 == L"1294967294" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, L'+', ul2);
result1 = oss.str();
VERIFY( result1 == L"0+++++++++++++++++++" );
// ... and one that does
oss.imbue(loc_de);
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, L'+', ul1);
result1 = oss.str();
VERIFY( result1 == L"1.294.967.294+++++++" );
// double
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, L'+', d1);
result1 = oss.str();
VERIFY( result1 == L"1,79769e+308++++++++" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, L'+', d2);
result1 = oss.str();
VERIFY( result1 == L"++++++++2,22507e-308" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield);
np.put(oss.rdbuf(), oss, L'+', d2);
result2 = oss.str();
VERIFY( result2 == L"+++++++2,225074e-308" );
oss.str(empty);
oss.clear();
oss.width(20);
oss.precision(10);
oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield);
oss.setf(ios_base::uppercase);
np.put(oss.rdbuf(), oss, L'+', d2);
result1 = oss.str();
VERIFY( result1 == L"+++2,2250738585E-308" );
// long double
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, L'+', ld1);
result1 = oss.str();
VERIFY( result1 == L"1,7976931349E+308" );
oss.str(empty);
oss.clear();
oss.precision(0);
oss.setf(ios_base::fixed, ios_base::floatfield);
np.put(oss.rdbuf(), oss, L'+', ld2);
result1 = oss.str();
VERIFY( result1 == L"0" );
// const void
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, L'+', cv);
result1 = oss.str();
// No grouping characters.
VERIFY( !char_traits<wchar_t>::find(result1.c_str(),
numpunct_de.decimal_point(),
result1.size()) );
// Should contain an 'x'.
VERIFY( !char_traits<wchar_t>::find(result1.c_str(), L'x', result1.size()) );
#ifdef _GLIBCPP_USE_LONG_LONG
long long ll1 = 9223372036854775807;
long long ll2 = -9223372036854775807;
oss.str(empty);
oss.clear();
np.put(oss.rdbuf(), oss, '+', ll1);
result1 = oss.str();
VERIFY( result1 == L"9.223.372.036.854.775.807" );
#endif
}
#endif
int main()
{
#ifdef _GLIBCPP_USE_WCHAR_T
test01();
#endif
return 0;
}
// Diana D. Brooks, former chief executive of Sotheby's
// art-thief extraordinaire
...@@ -75,19 +75,12 @@ void test01() ...@@ -75,19 +75,12 @@ void test01()
VERIFY( dp2 != dp3 ); VERIFY( dp2 != dp3 );
VERIFY( th2 != th3 ); VERIFY( th2 != th3 );
#if 0
// XXX isn't actually supported right now.
VERIFY( t2 != t3 );
VERIFY( f2 != f3 );
#endif
VERIFY( dp2 != dp4 ); VERIFY( dp2 != dp4 );
VERIFY( th2 != th4 ); VERIFY( th2 != th4 );
#if 0 // XXX This isn't actually supported right now.
// XXX isn't actually supported right now. // VERIFY( t2 != t3 );
VERIFY( t2 != t3 ); // VERIFY( f2 != f3 );
VERIFY( f2 != f3 );
#endif
} }
int main() int main()
......
// 2001-11-20 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// 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.
// 22.2.3.1.1 nunpunct members
#include <locale>
#include <testsuite_hooks.h>
// XXX This test is not working for non-glibc locale models.
// { dg-do run { xfail *-*-* } }
void test01()
{
using namespace std;
bool test = true;
// basic construction
locale loc_c = locale::classic();
locale loc_us("en_US");
locale loc_fr("fr_FR");
locale loc_de("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_us != loc_fr );
VERIFY( loc_us != loc_de );
VERIFY( loc_de != loc_fr );
// cache the numpunct facets
const numpunct<wchar_t>& nump_c = use_facet<numpunct<wchar_t> >(loc_c);
const numpunct<wchar_t>& nump_us = use_facet<numpunct<wchar_t> >(loc_us);
const numpunct<wchar_t>& nump_fr = use_facet<numpunct<wchar_t> >(loc_fr);
const numpunct<wchar_t>& nump_de = use_facet<numpunct<wchar_t> >(loc_de);
// sanity check the data is correct.
wchar_t dp1 = nump_c.decimal_point();
wchar_t th1 = nump_c.thousands_sep();
string g1 = nump_c.grouping();
wstring t1 = nump_c.truename();
wstring f1 = nump_c.falsename();
wchar_t dp2 = nump_us.decimal_point();
wchar_t th2 = nump_us.thousands_sep();
string g2 = nump_us.grouping();
wstring t2 = nump_us.truename();
wstring f2 = nump_us.falsename();
wchar_t dp3 = nump_fr.decimal_point();
wchar_t th3 = nump_fr.thousands_sep();
string g3 = nump_fr.grouping();
wstring t3 = nump_fr.truename();
wstring f3 = nump_fr.falsename();
wchar_t dp4 = nump_de.decimal_point();
wchar_t th4 = nump_de.thousands_sep();
string g4 = nump_de.grouping();
wstring t4 = nump_de.truename();
wstring f4 = nump_de.falsename();
VERIFY( dp2 != dp3 );
VERIFY( th2 != th3 );
VERIFY( dp2 != dp4 );
VERIFY( th2 != th4 );
}
int main()
{
test01();
return 0;
}
...@@ -387,7 +387,7 @@ bool test09() ...@@ -387,7 +387,7 @@ bool test09()
} }
bool test10() { bool test10() {
std::string str_01("0 00 000 +0 + 0 - 0"); std::string str_01("0 00 000 +0 +0 -0");
std::stringbuf isbuf_01(str_01); std::stringbuf isbuf_01(str_01);
std::istream is_01(&isbuf_01); std::istream is_01(&isbuf_01);
...@@ -447,7 +447,7 @@ bool test10() { ...@@ -447,7 +447,7 @@ bool test10() {
VERIFY( n == 33 ); VERIFY( n == 33 );
VERIFY( is_03.rdstate() == std::ios_base::eofbit ); VERIFY( is_03.rdstate() == std::ios_base::eofbit );
std::string str_04("3. 4.5E+ 2a5E-3 .6E1"); std::string str_04("3. 4.5E+2a5E-3 .6E1");
std::stringbuf isbuf_04(str_04); std::stringbuf isbuf_04(str_04);
std::istream is_04(&isbuf_04); std::istream is_04(&isbuf_04);
......
...@@ -63,13 +63,13 @@ static bool F=false; ...@@ -63,13 +63,13 @@ static bool F=false;
static _TestCase testcases[] = static _TestCase testcases[] =
{ {
#if _GLIBCPP_USE_WCHAR_T #if _GLIBCPP_USE_WCHAR_T
// standard output (no formatting applied) // standard output (no formatting applied) 1-4
{ 1.2, 6,0,'.',' ', F,F,F,F,F,F,F,F, "1.2",L"1.2" }, { 1.2, 6,0,'.',' ', F,F,F,F,F,F,F,F, "1.2",L"1.2" },
{ 54, 6,0,'.',' ', F,F,F,F,F,F,F,F, "54",L"54" }, { 54, 6,0,'.',' ', F,F,F,F,F,F,F,F, "54",L"54" },
{ -.012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-0.012",L"-0.012" }, { -.012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-0.012",L"-0.012" },
{ -.00000012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-1.2e-07",L"-1.2e-07" }, { -.00000012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-1.2e-07",L"-1.2e-07" },
// fixed formatting // fixed formatting 5-11
{ 10.2345, 0,0,'.',' ', T,F,F,F,F,F,F,F, "10",L"10" }, { 10.2345, 0,0,'.',' ', T,F,F,F,F,F,F,F, "10",L"10" },
{ 10.2345, 0,0,'.',' ', T,F,F,T,F,F,F,F, "10.",L"10." }, { 10.2345, 0,0,'.',' ', T,F,F,T,F,F,F,F, "10.",L"10." },
{ 10.2345, 1,0,'.',' ', T,F,F,F,F,F,F,F, "10.2",L"10.2" }, { 10.2345, 1,0,'.',' ', T,F,F,F,F,F,F,F, "10.2",L"10.2" },
...@@ -78,7 +78,7 @@ static _TestCase testcases[] = ...@@ -78,7 +78,7 @@ static _TestCase testcases[] =
{ -10.2345, 6,0,'.',' ', T,F,F,F,F,F,F,F, "-10.234500",L"-10.234500" }, { -10.2345, 6,0,'.',' ', T,F,F,F,F,F,F,F, "-10.234500",L"-10.234500" },
{ -10.2345, 6,0,',',' ', T,F,F,F,F,F,F,F, "-10,234500",L"-10,234500" }, { -10.2345, 6,0,',',' ', T,F,F,F,F,F,F,F, "-10,234500",L"-10,234500" },
// fixed formatting with width // fixed formatting with width 12-22
{ 10.2345, 4,5,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, { 10.2345, 4,5,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" },
{ 10.2345, 4,6,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, { 10.2345, 4,6,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" },
{ 10.2345, 4,7,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, { 10.2345, 4,7,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" },
...@@ -91,7 +91,7 @@ static _TestCase testcases[] = ...@@ -91,7 +91,7 @@ static _TestCase testcases[] =
{ -10.2345, 4,10,'.','A', T,F,F,F,F,T,F,F, "-AA10.2345",L"-AA10.2345" }, { -10.2345, 4,10,'.','A', T,F,F,F,F,T,F,F, "-AA10.2345",L"-AA10.2345" },
{ 10.2345, 4,10,'.','#', T,F,T,F,F,T,F,F, "+##10.2345",L"+##10.2345" }, { 10.2345, 4,10,'.','#', T,F,T,F,F,T,F,F, "+##10.2345",L"+##10.2345" },
// scientific formatting // scientific formatting 23-29
{ 1.23e+12, 1,0,'.',' ', F,T,F,F,F,F,F,F, "1.2e+12",L"1.2e+12" }, { 1.23e+12, 1,0,'.',' ', F,T,F,F,F,F,F,F, "1.2e+12",L"1.2e+12" },
{ 1.23e+12, 1,0,'.',' ', F,T,F,F,T,F,F,F, "1.2E+12",L"1.2E+12" }, { 1.23e+12, 1,0,'.',' ', F,T,F,F,T,F,F,F, "1.2E+12",L"1.2E+12" },
{ 1.23e+12, 2,0,'.',' ', F,T,F,F,F,F,F,F, "1.23e+12",L"1.23e+12" }, { 1.23e+12, 2,0,'.',' ', F,T,F,F,F,F,F,F, "1.23e+12",L"1.23e+12" },
...@@ -207,7 +207,7 @@ test01() ...@@ -207,7 +207,7 @@ test01()
apply_formatting(tc, os); apply_formatting(tc, os);
os << tc.val; os << tc.val;
#ifdef TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "result: " << os.str() << endl; cout << j << "result 1: " << os.str() << endl;
#endif #endif
VERIFY( os && os.str() == tc.result ); VERIFY( os && os.str() == tc.result );
} }
...@@ -220,7 +220,7 @@ test01() ...@@ -220,7 +220,7 @@ test01()
apply_formatting(tc, os); apply_formatting(tc, os);
os << (long double)tc.val; os << (long double)tc.val;
#ifdef TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "result: " << os.str() << endl; cout << j << "result 2: " << os.str() << endl;
#endif #endif
VERIFY( os && os.str() == tc.result ); VERIFY( os && os.str() == tc.result );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment