#pragma GCC system_header
-#include <limits> // For numeric_limits
-#include <typeinfo> // For bad_cast.
+#include <limits> // For numeric_limits
+#include <typeinfo> // For bad_cast.
#include <bits/streambuf_iterator.h>
namespace std
ios_base::iostate& __err, string& __xtrc) const
{
typedef char_traits<_CharT> __traits_type;
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef typename numpunct<_CharT>::__cache_type __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
++__beg;
}
}
-
+
// Next, look for leading zeros.
while (__beg != __end)
{
const char_type __c = *__beg;
if (__traits_type::eq(__c, __lc->_M_decimal_point)
- || (__lc->_M_use_grouping
+ || (__lc->_M_use_grouping
&& __traits_type::eq(__c, __lc->_M_thousands_sep)))
break;
else if (__traits_type::eq(__c, __lit[_S_izero]))
++__sep_pos;
++__beg;
}
- else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
- || __traits_type::eq(__c, __lit[_S_iE]))
+ else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
+ || __traits_type::eq(__c, __lit[_S_iE]))
&& __found_mantissa && !__found_sci)
{
// Scientific notation.
const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]);
if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus]))
{
- __xtrc += __plus ? _S_atoms_in[_S_iplus]
+ __xtrc += __plus ? _S_atoms_in[_S_iplus]
: _S_atoms_in[_S_iminus];
++__beg;
}
}
template<typename _CharT, typename _InIter>
- template<typename _ValueT>
+ template<typename _ValueT>
_InIter
num_get<_CharT, _InIter>::
_M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, _ValueT& __v) const
{
typedef char_traits<_CharT> __traits_type;
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef typename numpunct<_CharT>::__cache_type __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
// First check for sign.
bool __negative = false;
if (__beg != __end)
- {
+ {
const char_type __c = *__beg;
if (numeric_limits<_ValueT>::is_signed)
__negative = __traits_type::eq(__c, __lit[_S_iminus]);
__err |= ios_base::failbit;
break;
}
- }
+ }
else if (__traits_type::eq(__c, __lc->_M_decimal_point))
break;
else if (__p = __traits_type::find(__lit_zero, __len, __c))
{
// Add the ending grouping.
__found_grouping += static_cast<char>(__sep_pos);
-
+
if (!std::__verify_grouping(__lc->_M_grouping, __lc->_M_grouping_size,
__found_grouping))
__err |= ios_base::failbit;
break;
if (!__testf && !__testt)
- break;
+ break;
}
if (__testf && __n == __lc->_M_falsename_size)
__v = 0;
num_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, unsigned short& __v) const
- { return _M_extract_int(__beg, __end, __io, __err, __v); }
+ { return _M_extract_int(__beg, __end, __io, __err, __v); }
template<typename _CharT, typename _InIter>
_InIter
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, ios_base& __io,
+ do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, float& __v) const
{
string __xtrc;
if (!(__err & ios_base::failbit))
__v = reinterpret_cast<void*>(__ul);
- else
+ else
__err |= ios_base::failbit;
return __beg;
}
template<typename _CharT, typename _OutIter>
void
num_put<_CharT, _OutIter>::
- _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
+ _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
_CharT* __new, const _CharT* __cs, int& __len) const
{
// [22.2.2.2.2] Stage 3.
// If necessary, pad.
- __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
+ __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
__w, __len, true);
__len = static_cast<int>(__w);
}
{
unsigned long __ul = static_cast<unsigned long>(__v);
bool __neg = false;
- if (__v < 0)
+ if (__v < 0)
{
__ul = -__ul;
__neg = true;
}
- return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
+ return __int_to_char(__bufend, __ul, __lit, __flags, __neg);
}
template<typename _CharT>
inline int
__int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit,
ios_base::fmtflags __flags)
- {
+ {
unsigned long long __ull = static_cast<unsigned long long>(__v);
bool __neg = false;
- if (__v < 0)
+ if (__v < 0)
{
__ull = -__ull;
__neg = true;
}
- return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
+ return __int_to_char(__bufend, __ull, __lit, __flags, __neg);
}
template<typename _CharT>
ios_base::fmtflags __flags)
{ return __int_to_char(__bufend, __v, __lit, __flags, false); }
#endif
-
+
template<typename _CharT, typename _ValueT>
int
__int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit,
__basefield != ios_base::hex, true))
{
// Decimal.
- do
+ do
{
*__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
__v /= 10;
- }
+ }
while (__v != 0);
if (__neg)
*__buf-- = __lit[__num_base::_S_ominus];
else if (__basefield == ios_base::oct)
{
// Octal.
- do
+ do
{
*__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
__v >>= 3;
- }
+ }
while (__v != 0);
if (__showbase)
*__buf-- = __lit[__num_base::_S_odigits];
{
// Hex.
const bool __uppercase = __flags & ios_base::uppercase;
- const int __case_offset = __uppercase ? __num_base::_S_oudigits
+ const int __case_offset = __uppercase ? __num_base::_S_oudigits
: __num_base::_S_odigits;
- do
+ do
{
*__buf-- = __lit[(__v & 0xf) + __case_offset];
__v >>= 4;
- }
+ }
while (__v != 0);
if (__showbase)
{
// However, remember that the latter do not occur if the number
// printed is '0' (__len == 1).
streamsize __off = 0;
- const ios_base::fmtflags __basefield = __io.flags()
+ const ios_base::fmtflags __basefield = __io.flags()
& ios_base::basefield;
if ((__io.flags() & ios_base::showbase) && __len > 1)
if (__basefield == ios_base::oct)
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
- _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
+ _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
typedef typename numpunct<_CharT>::__cache_type __cache_type;
const __cache_type* __lc = __uc(__loc);
const _CharT* __lit = __lc->_M_atoms_out;
- // Long enough to hold hex, dec, and octal representations.
+ // Long enough to hold hex, dec, and octal representations.
const int __ilen = 4 * sizeof(_ValueT);
- _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __ilen));
// [22.2.2.2.2] Stage 1, numeric conversion to character.
int __len;
__len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags());
__cs += __ilen - __len;
-
- // Add grouping, if necessary.
+
+ // Add grouping, if necessary.
if (__lc->_M_use_grouping)
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
- _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
_M_group_int(__lc->_M_grouping, __lc->_M_grouping_size,
__lc->_M_thousands_sep, __io, __cs2, __cs, __len);
__cs = __cs2;
}
-
+
// Pad.
const streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
- _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
_M_pad(__fill, __w, __io, __cs3, __cs, __len);
__cs = __cs3;
// [22.2.2.2.2] Stage 4.
// Write resulting, fully-formatted string to output iterator.
return std::__write(__s, __cs, __len);
- }
+ }
template<typename _CharT, typename _OutIter>
void
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 282. What types does numpunct grouping refer to?
- // Add grouping, if necessary.
+ // Add grouping, if necessary.
_CharT* __p2;
const int __declen = __p ? __p - __cs : __len;
__p2 = std::__add_grouping(__new, __sep, __grouping, __grouping_size,
__cs, __cs + __declen);
-
+
// Tack on decimal part.
int __newlen = __p2 - __new;
if (__p)
{
char_traits<_CharT>::copy(__p2, __p, __len - __declen);
__newlen += __len - __declen;
- }
+ }
__len = __newlen;
}
// If the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size)
{
- __cs_size = __len + 1;
+ __cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
__len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v,
_S_get_c_locale(), __prec);
// fractional part + 3 chars for sign, decimal point, '\0'. On
// the other hand, for non-fixed outputs __max_digits*3 chars
// are largely sufficient.
- const int __cs_size = __fixed ? __max_exp + __max_digits + 4
+ const int __cs_size = __fixed ? __max_exp + __max_digits + 4
: __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
_S_format_float(__io, __fbuf, __mod);
- __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
+ __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
_S_get_c_locale(), __prec);
#endif
// numpunct.decimal_point() values for '.' and adding grouping.
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len));
__ctype.widen(__cs, __cs + __len, __ws);
-
+
// Replace decimal point.
const _CharT __cdec = __ctype.widen('.');
const _CharT __dec = __lc->_M_decimal_point;
if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
__ws[__p - __ws] = __dec;
- // Add grouping, if necessary.
+ // Add grouping, if necessary.
if (__lc->_M_use_grouping)
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
_M_group_float(__lc->_M_grouping, __lc->_M_grouping_size,
__lc->_M_thousands_sep, __p, __ws2, __ws, __len);
__ws = __ws3;
}
__io.width(0);
-
+
// [22.2.2.2.2] Stage 4.
// Write resulting, fully-formatted string to output iterator.
return std::__write(__s, __ws, __len);
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
- const _CharT* __name = __v ? __lc->_M_truename
+ const _CharT* __name = __v ? __lc->_M_truename
: __lc->_M_falsename;
int __len = __v ? __lc->_M_truename_size
: __lc->_M_falsename_size;
const streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
- _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
_M_pad(__fill, __w, __io, __cs, __name, __len);
__name = __cs;
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
- do_put(iter_type __s, ios_base& __io, char_type __fill,
+ do_put(iter_type __s, ios_base& __io, char_type __fill,
long double __v) const
{ return _M_insert_float(__s, __io, __fill, 'L', __v); }
const ios_base::fmtflags __fmt = ~(ios_base::showpos | ios_base::basefield
| ios_base::uppercase | ios_base::internal);
__io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
-
- __s = _M_insert_int(__s, __io, __fill,
+
+ __s = _M_insert_int(__s, __io, __fill,
reinterpret_cast<unsigned long>(__v));
__io.flags(__flags);
return __s;
template<typename _CharT, typename _InIter>
_InIter
money_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
+ do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, long double& __units) const
- {
+ {
string_type __str;
- __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
+ __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
const int __cs_size = __str.size() + 1;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
const locale __loc = __io.getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const _CharT* __wcs = __str.c_str();
- __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
+ __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
std::__convert_to_v(__cs, __units, __err, _S_get_c_locale());
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
money_get<_CharT, _InIter>::
- do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
+ do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __units) const
- {
+ {
// These contortions are quite unfortunate.
- typedef moneypunct<_CharT, true> __money_true;
- typedef moneypunct<_CharT, false> __money_false;
- typedef money_base::part part;
- typedef typename string_type::size_type size_type;
+ typedef moneypunct<_CharT, true> __money_true;
+ typedef moneypunct<_CharT, false> __money_false;
+ typedef money_base::part part;
+ typedef typename string_type::size_type size_type;
const locale __loc = __io.getloc();
- const __money_true& __mpt = use_facet<__money_true>(__loc);
- const __money_false& __mpf = use_facet<__money_false>(__loc);
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const __money_true& __mpt = use_facet<__money_true>(__loc);
+ const __money_false& __mpf = use_facet<__money_false>(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- const money_base::pattern __p = __intl ? __mpt.neg_format()
+ const money_base::pattern __p = __intl ? __mpt.neg_format()
: __mpf.neg_format();
- const string_type __pos_sign = __intl ? __mpt.positive_sign()
+ const string_type __pos_sign = __intl ? __mpt.positive_sign()
: __mpf.positive_sign();
- const string_type __neg_sign = __intl ? __mpt.negative_sign()
+ const string_type __neg_sign = __intl ? __mpt.negative_sign()
: __mpf.negative_sign();
- const char_type __d = __intl ? __mpt.decimal_point()
- : __mpf.decimal_point();
- const char_type __sep = __intl ? __mpt.thousands_sep()
- : __mpf.thousands_sep();
+ const char_type __d = __intl ? __mpt.decimal_point()
+ : __mpf.decimal_point();
+ const char_type __sep = __intl ? __mpt.thousands_sep()
+ : __mpf.thousands_sep();
const string __grouping = __intl ? __mpt.grouping() : __mpf.grouping();
// Set to deduced positive or negative sign, depending.
string_type __sign;
// String of grouping info from thousands_sep plucked from __units.
- string __grouping_tmp;
+ string __grouping_tmp;
// Marker for thousands_sep position.
int __sep_pos = 0;
// If input iterator is in a valid state.
bool __testvalid = true;
// Flag marking when a decimal point is found.
- bool __testdecfound = false;
+ bool __testdecfound = false;
// The tentative returned string is stored here.
string_type __tmp_units;
switch (__which)
{
case money_base::symbol:
- if (__io.flags() & ios_base::showbase
+ if (__io.flags() & ios_base::showbase
|| __i < 2 || __sign.size() > 1
|| ((static_cast<part>(__p.field[3]) != money_base::none)
- && __i == 2))
+ && __i == 2))
{
// According to 22.2.6.1.2.2, symbol is required
// if (__io.flags() & ios_base::showbase),
__testvalid = false;
}
break;
- case money_base::sign:
+ case money_base::sign:
// Sign might not exist, or be more than one character long.
if (__pos_sign.size() && *__beg == __pos_sign[0])
{
case money_base::none:
// Only if not at the end of the pattern.
if (__i != 3)
- for (; __beg != __end
+ for (; __beg != __end
&& __ctype.is(ctype_base::space, *__beg); ++__beg);
break;
}
}
-
+
// Need to get the rest of the sign characters, if they exist.
if (__sign.size() > 1)
{
for (; __beg != __end && __i < __len; ++__i)
for (; __beg != __end
&& *__beg != __sign[__i]; ++__beg);
-
+
if (__i != __len)
__testvalid = false;
}
__tmp_units.erase(0, __only_zeros ? __tmp_units.size() - 1
: __first);
}
-
+
// 22.2.6.1.2, p4
if (__sign.size() && __sign == __neg_sign
&& __tmp_units[0] != __zero)
__grouping_tmp))
__testvalid = false;
}
-
+
// Iff not enough digits were supplied after the decimal-point.
if (__testdecfound)
{
- const int __frac = __intl ? __mpt.frac_digits()
+ const int __frac = __intl ? __mpt.frac_digits()
: __mpf.frac_digits();
if (__frac > 0 && __sep_pos != __frac)
__testvalid = false;
else
__testvalid = false;
- // Iff no more characters are available.
+ // Iff no more characters are available.
if (__beg == __end)
__err |= ios_base::eofbit;
// Use the "swap trick" to copy __tmp_units into __units.
__tmp_units.swap(__units);
- return __beg;
+ return __beg;
}
template<typename _CharT, typename _OutIter>
money_put<_CharT, _OutIter>::
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
long double __units) const
- {
+ {
const locale __loc = __io.getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
#ifdef _GLIBCXX_USE_C99
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 328. Bad sprintf format modifier in money_put<>::do_put()
- int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
+ int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
_S_get_c_locale());
// If the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size)
{
__cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
- __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
+ __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units,
_S_get_c_locale());
}
#else
- // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
+ // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units,
+ int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units,
_S_get_c_locale());
#endif
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __cs_size));
__ctype.widen(__cs, __cs + __len, __ws);
const string_type __digits(__ws, __len);
- return this->do_put(__s, __intl, __io, __fill, __digits);
+ return this->do_put(__s, __intl, __io, __fill, __digits);
}
template<typename _CharT, typename _OutIter>
money_put<_CharT, _OutIter>::
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
const string_type& __digits) const
- {
- typedef typename string_type::size_type size_type;
- typedef money_base::part part;
+ {
+ typedef typename string_type::size_type size_type;
+ typedef money_base::part part;
const locale __loc = __io.getloc();
const size_type __width = static_cast<size_type>(__io.width());
// These contortions are quite unfortunate.
typedef moneypunct<_CharT, true> __money_true;
typedef moneypunct<_CharT, false> __money_false;
- const __money_true& __mpt = use_facet<__money_true>(__loc);
- const __money_false& __mpf = use_facet<__money_false>(__loc);
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const __money_true& __mpt = use_facet<__money_true>(__loc);
+ const __money_false& __mpf = use_facet<__money_false>(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
// Determine if negative or positive formats are to be used, and
// discard leading negative_sign if it is present.
__sign = __intl ? __mpt.negative_sign() : __mpf.negative_sign();
++__beg;
}
-
+
// Look for valid numbers in the current ctype facet within input digits.
__end = __ctype.scan_not(ctype_base::digit, __beg, __end);
if (__beg != __end)
// final_value = grouped units + (decimal point) + (digits)
string_type __res;
string_type __value;
- const string_type __symbol = __intl ? __mpt.curr_symbol()
- : __mpf.curr_symbol();
+ const string_type __symbol = __intl ? __mpt.curr_symbol()
+ : __mpf.curr_symbol();
// Deal with decimal point, decimal digits.
- const int __frac = __intl ? __mpt.frac_digits()
- : __mpf.frac_digits();
+ const int __frac = __intl ? __mpt.frac_digits()
+ : __mpf.frac_digits();
if (__frac > 0)
{
- const char_type __d = __intl ? __mpt.decimal_point()
+ const char_type __d = __intl ? __mpt.decimal_point()
: __mpf.decimal_point();
if (__end - __beg >= __frac)
{
// grouping rules.
if (__beg != __end)
{
- const string __grouping = __intl ? __mpt.grouping()
+ const string __grouping = __intl ? __mpt.grouping()
: __mpf.grouping();
if (__grouping.size())
{
- const char_type __sep = __intl ? __mpt.thousands_sep()
- : __mpf.thousands_sep();
+ const char_type __sep = __intl ? __mpt.thousands_sep()
+ : __mpf.thousands_sep();
const char* __gbeg = __grouping.data();
const size_t __glen = __grouping.size();
const int __n = (__end - __beg) * 2;
_CharT* __ws2 =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
- _CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg,
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
+ _CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg,
__glen, __beg, __end);
__value.insert(0, __ws2, __ws_end - __ws2);
}
if (__io.flags() & ios_base::showbase)
__res += __symbol;
break;
- case money_base::sign:
+ case money_base::sign:
// Sign might not exist, or be more than one
// charater long. In that case, add in the rest
// below.
__s = std::__write(__s, __res.data(), __len);
}
__io.width(0);
- return __s;
+ return __s;
}
void
time_get<_CharT, _InIter>::
_M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
- ios_base::iostate& __err, tm* __tm,
+ ios_base::iostate& __err, tm* __tm,
const _CharT* __format) const
- {
+ {
const locale __loc = __io.getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const size_t __len = char_traits<_CharT>::length(__format);
for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
{
// Verify valid formatting code, attempt to extract.
char __c = __ctype.narrow(__format[++__i], 0);
- int __mem = 0;
+ int __mem = 0;
if (__c == 'E' || __c == 'O')
__c = __ctype.narrow(__format[++__i], 0);
switch (__c)
// Abbreviated weekday name [tm_wday]
const char_type* __days1[7];
__tp._M_days_abbreviated(__days1);
- _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
+ _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
__ctype, __err);
break;
case 'A':
// Weekday name [tm_wday].
const char_type* __days2[7];
__tp._M_days(__days2);
- _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
+ _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
__ctype, __err);
break;
case 'h':
// Abbreviated month name [tm_mon]
const char_type* __months1[12];
__tp._M_months_abbreviated(__months1);
- _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
+ _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
__ctype, __err);
break;
case 'B':
// Month name [tm_mon].
const char_type* __months2[12];
__tp._M_months(__months2);
- _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
+ _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
__ctype, __err);
break;
case 'c':
// Default time and date representation.
const char_type* __dt[2];
__tp._M_date_time_formats(__dt);
- _M_extract_via_format(__beg, __end, __io, __err, __tm,
+ _M_extract_via_format(__beg, __end, __io, __err, __tm,
__dt[0]);
break;
case 'd':
// Day [01, 31]. [tm_mday]
- _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+ _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
__ctype, __err);
break;
case 'e':
__ctype, __err);
else
_M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, 2,
- __ctype, __err);
- break;
+ __ctype, __err);
+ break;
case 'D':
// Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
__cs = "%m/%d/%y";
__ctype.widen(__cs, __cs + 9, __wcs);
- _M_extract_via_format(__beg, __end, __io, __err, __tm,
+ _M_extract_via_format(__beg, __end, __io, __err, __tm,
__wcs);
break;
case 'H':
break;
case 'I':
// Hour [01, 12]. [tm_hour]
- _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+ _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
__ctype, __err);
break;
case 'm':
// Month [01, 12]. [tm_mon]
- _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
+ _M_extract_num(__beg, __end, __mem, 1, 12, 2, __ctype,
__err);
if (!__err)
__tm->tm_mon = __mem - 1;
// Equivalent to (%H:%M).
__cs = "%H:%M";
__ctype.widen(__cs, __cs + 6, __wcs);
- _M_extract_via_format(__beg, __end, __io, __err, __tm,
+ _M_extract_via_format(__beg, __end, __io, __err, __tm,
__wcs);
break;
case 'S':
// Equivalent to (%H:%M:%S).
__cs = "%H:%M:%S";
__ctype.widen(__cs, __cs + 9, __wcs);
- _M_extract_via_format(__beg, __end, __io, __err, __tm,
+ _M_extract_via_format(__beg, __end, __io, __err, __tm,
__wcs);
break;
case 'x':
// Locale's date.
const char_type* __dates[2];
__tp._M_date_formats(__dates);
- _M_extract_via_format(__beg, __end, __io, __err, __tm,
+ _M_extract_via_format(__beg, __end, __io, __err, __tm,
__dates[0]);
break;
case 'X':
// Locale's time.
const char_type* __times[2];
__tp._M_time_formats(__times);
- _M_extract_via_format(__beg, __end, __io, __err, __tm,
+ _M_extract_via_format(__beg, __end, __io, __err, __tm,
__times[0]);
break;
case 'y':
case 'C': // C99
// Two digit year. [tm_year]
- _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
+ _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
__ctype, __err);
break;
case 'Y':
// Year [1900). [tm_year]
- _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
+ _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
__ctype, __err);
if (!__err)
__tm->tm_year = __mem - 1900;
if (__ctype.is(ctype_base::upper, *__beg))
{
int __tmp;
- _M_extract_name(__beg, __end, __tmp,
- __timepunct_cache<_CharT>::_S_timezones,
+ _M_extract_name(__beg, __end, __tmp,
+ __timepunct_cache<_CharT>::_S_timezones,
14, __ctype, __err);
-
+
// GMT requires special effort.
if (__beg != __end && !__err && __tmp == 0
- && (*__beg == __ctype.widen('-')
+ && (*__beg == __ctype.widen('-')
|| *__beg == __ctype.widen('+')))
{
_M_extract_num(__beg, __end, __tmp, 0, 23, 2,
__ctype, __err);
_M_extract_num(__beg, __end, __tmp, 0, 59, 2,
__ctype, __err);
- }
+ }
}
else
__err |= ios_base::failbit;
void
time_get<_CharT, _InIter>::
_M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
- int __min, int __max, size_t __len,
- const ctype<_CharT>& __ctype,
+ int __min, int __max, size_t __len,
+ const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const
{
// As-is works for __len = 1, 2, 4, the values actually used.
void
time_get<_CharT, _InIter>::
_M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
- const _CharT** __names, size_t __indexlen,
- const ctype<_CharT>& __ctype,
+ const _CharT** __names, size_t __indexlen,
+ const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const
{
- typedef char_traits<_CharT> __traits_type;
- int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
+ typedef char_traits<_CharT> __traits_type;
+ int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
* __indexlen));
size_t __nmatches = 0;
size_t __pos = 0;
bool __testvalid = true;
const char_type* __name;
- // Look for initial matches.
+ // Look for initial matches.
// NB: Some of the locale data is in the form of all lowercase
// names, and some is in the form of initially-capitalized
// names. Look for both.
{
const char_type __c = *__beg;
for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
- if (__c == __names[__i1][0]
+ if (__c == __names[__i1][0]
|| __c == __ctype.toupper(__names[__i1][0]))
__matches[__nmatches++] = __i1;
}
-
+
while (__nmatches > 1)
{
// Find smallest matching string.
size_t __minlen = 10;
for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
- __minlen = std::min(__minlen,
+ __minlen = std::min(__minlen,
__traits_type::length(__names[__matches[__i2]]));
++__beg;
if (__pos < __minlen && __beg != __end)
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
- do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
+ do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
- typedef char_traits<_CharT> __traits_type;
+ typedef char_traits<_CharT> __traits_type;
const locale __loc = __io.getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const char_type* __days[7];
__tp._M_days_abbreviated(__days);
int __tmpwday;
// exact same order, first to last, such that the resulting
// __days array with the same index points to a day, and that
// day's abbreviated form.
- // NB: Also assumes that an abbreviated name is a subset of the name.
+ // NB: Also assumes that an abbreviated name is a subset of the name.
if (!__err)
{
size_t __pos = __traits_type::length(__days[__tmpwday]);
{
// Extract the rest of it.
const size_t __len = __traits_type::length(__name);
- while (__pos < __len && __beg != __end
+ while (__pos < __len && __beg != __end
&& __name[__pos] == *__beg)
++__beg, ++__pos;
if (__len != __pos)
do_get_monthname(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
{
- typedef char_traits<_CharT> __traits_type;
+ typedef char_traits<_CharT> __traits_type;
const locale __loc = __io.getloc();
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const char_type* __months[12];
__tp._M_months_abbreviated(__months);
int __tmpmon;
// exact same order, first to last, such that the resulting
// __months array with the same index points to a month, and that
// month's abbreviated form.
- // NB: Also assumes that an abbreviated name is a subset of the name.
+ // NB: Also assumes that an abbreviated name is a subset of the name.
if (!__err)
{
size_t __pos = __traits_type::length(__months[__tmpmon]);
{
// Extract the rest of it.
const size_t __len = __traits_type::length(__name);
- while (__pos < __len && __beg != __end
+ while (__pos < __len && __beg != __end
&& __name[__pos] == *__beg)
++__beg, ++__pos;
if (__len != __pos)
if (!__err)
__tm->tm_mon = __tmpmon;
}
-
+
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
template<typename _CharT, typename _InIter>
_InIter
time_get<_CharT, _InIter>::
- do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
+ do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
const locale __loc = __io.getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
size_t __i = 0;
int __value = 0;
break;
}
if (__i == 2 || __i == 4)
- __tm->tm_year = __i == 2 ? __value : __value - 1900;
+ __tm->tm_year = __i == 2 ? __value : __value - 1900;
else
__err |= ios_base::failbit;
if (__beg == __end)
template<typename _CharT, typename _OutIter>
_OutIter
time_put<_CharT, _OutIter>::
- put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
+ put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
const _CharT* __beg, const _CharT* __end) const
{
const locale __loc = __io.getloc();
template<typename _CharT, typename _OutIter>
_OutIter
time_put<_CharT, _OutIter>::
- do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
+ do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
char __format, char __mod) const
- {
+ {
const locale __loc = __io.getloc();
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
// format character: if __mod is not the default argument, assume
// it's a valid modifier.
char_type __fmt[4];
- __fmt[0] = __ctype.widen('%');
+ __fmt[0] = __ctype.widen('%');
if (!__mod)
{
__fmt[1] = __format;
template<typename _CharT>
int
collate<_CharT>::
- do_compare(const _CharT* __lo1, const _CharT* __hi1,
+ do_compare(const _CharT* __lo1, const _CharT* __hi1,
const _CharT* __lo2, const _CharT* __hi2) const
- {
+ {
// strcoll assumes zero-terminated strings so we make a copy
// and then put a zero at the end.
const string_type __one(__lo1, __hi1);
if (__res >= __len)
{
__len = __res + 1;
- __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len));
__res = _M_transform(__c, __p, __res + 1);
}
long
collate<_CharT>::
do_hash(const _CharT* __lo, const _CharT* __hi) const
- {
+ {
unsigned long __val = 0;
for (; __lo < __hi; ++__lo)
- __val = *__lo + ((__val << 7) |
+ __val = *__lo + ((__val << 7) |
(__val >> (numeric_limits<unsigned long>::digits - 7)));
return static_cast<long>(__val);
}
// Construct correctly padded string, as per 22.2.2.2.2
- // Assumes
+ // Assumes
// __newlen > __oldlen
// __news is allocated for __newlen size
// Used by both num_put and ostream inserters: if __num,
// NB: Of the two parameters, _CharT can be deduced from the
// function arguments. The other (_Traits) has to be explicitly specified.
template<typename _CharT, typename _Traits>
- void
- __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
- _CharT* __news, const _CharT* __olds,
- const streamsize __newlen,
+ void
+ __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
+ _CharT* __news, const _CharT* __olds,
+ const streamsize __newlen,
const streamsize __oldlen, const bool __num)
{
const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
// Pad after 0[xX], if there is one.
// Who came up with these rules, anyway? Jeeze.
const locale& __loc = __io._M_getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const _CharT __minus = __ctype.widen('-');
const _CharT __plus = __ctype.widen('+');
const bool __testsign = _Traits::eq(__olds[0], __minus)
|| _Traits::eq(__olds[0], __plus);
- const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
- && (_Traits::eq(__ctype.widen('x'), __olds[1])
+ const bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0])
+ && (_Traits::eq(__ctype.widen('x'), __olds[1])
|| _Traits::eq(__ctype.widen('X'), __olds[1]));
if (__testhex)
{
- __news[0] = __olds[0];
+ __news[0] = __olds[0];
__news[1] = __olds[1];
__mod = 2;
__news += 2;
bool
__verify_grouping(const char* __grouping, size_t __grouping_size,
const string& __grouping_tmp)
- {
+ {
const size_t __n = __grouping_tmp.size() - 1;
const size_t __min = std::min(__n, __grouping_size - 1);
size_t __i = __n;
}
// Inhibit implicit instantiations for required instantiations,
- // which are defined via explicit instantiations elsewhere.
+ // which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
#if _GLIBCXX_EXTERN_TEMPLATE
extern template class moneypunct<char, false>;
extern template class numpunct<char>;
extern template class numpunct_byname<char>;
extern template class num_get<char>;
- extern template class num_put<char>;
+ extern template class num_put<char>;
extern template class __timepunct<char>;
extern template class time_put<char>;
extern template class time_put_byname<char>;
extern template class collate_byname<char>;
extern template
- const codecvt<char, char, mbstate_t>&
+ const codecvt<char, char, mbstate_t>&
use_facet<codecvt<char, char, mbstate_t> >(const locale&);
extern template
- const collate<char>&
+ const collate<char>&
use_facet<collate<char> >(const locale&);
extern template
- const numpunct<char>&
+ const numpunct<char>&
use_facet<numpunct<char> >(const locale&);
- extern template
- const num_put<char>&
+ extern template
+ const num_put<char>&
use_facet<num_put<char> >(const locale&);
- extern template
- const num_get<char>&
+ extern template
+ const num_get<char>&
use_facet<num_get<char> >(const locale&);
extern template
- const moneypunct<char, true>&
+ const moneypunct<char, true>&
use_facet<moneypunct<char, true> >(const locale&);
extern template
- const moneypunct<char, false>&
+ const moneypunct<char, false>&
use_facet<moneypunct<char, false> >(const locale&);
- extern template
- const money_put<char>&
+ extern template
+ const money_put<char>&
use_facet<money_put<char> >(const locale&);
- extern template
- const money_get<char>&
+ extern template
+ const money_get<char>&
use_facet<money_get<char> >(const locale&);
extern template
- const __timepunct<char>&
+ const __timepunct<char>&
use_facet<__timepunct<char> >(const locale&);
- extern template
- const time_put<char>&
+ extern template
+ const time_put<char>&
use_facet<time_put<char> >(const locale&);
- extern template
- const time_get<char>&
+ extern template
+ const time_get<char>&
use_facet<time_get<char> >(const locale&);
- extern template
- const messages<char>&
+ extern template
+ const messages<char>&
use_facet<messages<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<ctype<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<codecvt<char, char, mbstate_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<collate<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<numpunct<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<num_put<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<num_get<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<moneypunct<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<money_put<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<money_get<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<__timepunct<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<time_put<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<time_get<char> >(const locale&);
- extern template
+ extern template
bool
has_facet<messages<char> >(const locale&);
extern template class collate_byname<wchar_t>;
extern template
- const codecvt<wchar_t, char, mbstate_t>&
+ const codecvt<wchar_t, char, mbstate_t>&
use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
extern template
- const collate<wchar_t>&
+ const collate<wchar_t>&
use_facet<collate<wchar_t> >(const locale&);
extern template
- const numpunct<wchar_t>&
+ const numpunct<wchar_t>&
use_facet<numpunct<wchar_t> >(const locale&);
- extern template
- const num_put<wchar_t>&
+ extern template
+ const num_put<wchar_t>&
use_facet<num_put<wchar_t> >(const locale&);
- extern template
- const num_get<wchar_t>&
+ extern template
+ const num_get<wchar_t>&
use_facet<num_get<wchar_t> >(const locale&);
extern template
- const moneypunct<wchar_t, true>&
+ const moneypunct<wchar_t, true>&
use_facet<moneypunct<wchar_t, true> >(const locale&);
extern template
- const moneypunct<wchar_t, false>&
+ const moneypunct<wchar_t, false>&
use_facet<moneypunct<wchar_t, false> >(const locale&);
-
- extern template
- const money_put<wchar_t>&
+
+ extern template
+ const money_put<wchar_t>&
use_facet<money_put<wchar_t> >(const locale&);
- extern template
- const money_get<wchar_t>&
+ extern template
+ const money_get<wchar_t>&
use_facet<money_get<wchar_t> >(const locale&);
extern template
- const __timepunct<wchar_t>&
+ const __timepunct<wchar_t>&
use_facet<__timepunct<wchar_t> >(const locale&);
- extern template
- const time_put<wchar_t>&
+ extern template
+ const time_put<wchar_t>&
use_facet<time_put<wchar_t> >(const locale&);
- extern template
- const time_get<wchar_t>&
+ extern template
+ const time_get<wchar_t>&
use_facet<time_get<wchar_t> >(const locale&);
- extern template
- const messages<wchar_t>&
+ extern template
+ const messages<wchar_t>&
use_facet<messages<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<ctype<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<collate<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<numpunct<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<num_put<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<num_get<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<moneypunct<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<money_put<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<money_get<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<__timepunct<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<time_put<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<time_get<wchar_t> >(const locale&);
- extern template
+ extern template
bool
has_facet<messages<wchar_t> >(const locale&);
#endif