epoc32/include/tools/stlport/stl/_monetary.c
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_monetary.c	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,604 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +#ifndef _STLP_MONETARY_C
    1.22 +#define _STLP_MONETARY_C
    1.23 +
    1.24 +# ifndef _STLP_INTERNAL_MONETARY_H
    1.25 +#  include <stl/_monetary.h>
    1.26 +# endif
    1.27 +
    1.28 +#ifndef _STLP_INTERNAL_IOS_H
    1.29 +# include <stl/_ios.h>
    1.30 +#endif
    1.31 +
    1.32 +#ifndef _STLP_INTERNAL_NUM_PUT_H
    1.33 +# include <stl/_num_put.h>
    1.34 +#endif
    1.35 +
    1.36 +#ifndef _STLP_INTERNAL_NUM_GET_H
    1.37 +# include <stl/_num_get.h>
    1.38 +#endif
    1.39 +
    1.40 +_STLP_BEGIN_NAMESPACE
    1.41 +
    1.42 +#if (_STLP_STATIC_TEMPLATE_DATA > 0)
    1.43 +
    1.44 +#  if !defined (__BORLANDC__)
    1.45 +template <class _CharT, class _InputIterator>
    1.46 +locale::id money_get<_CharT, _InputIterator>::id;
    1.47 +
    1.48 +template <class _CharT, class _OutputIterator>
    1.49 +locale::id money_put<_CharT, _OutputIterator>::id;
    1.50 +#  endif
    1.51 +
    1.52 +#  if (defined (__CYGWIN__) || defined (__MINGW32__)) && \
    1.53 +       defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)
    1.54 +/*
    1.55 + * Under cygwin, when STLport is used as a shared library, the id needs
    1.56 + * to be specified as imported otherwise they will be duplicated in the
    1.57 + * calling executable.
    1.58 + */
    1.59 +template <>
    1.60 +_STLP_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
    1.61 +/*
    1.62 +template <>
    1.63 +_STLP_DECLSPEC locale::id money_get<char, const char*>::id;
    1.64 +*/
    1.65 +
    1.66 +template <>
    1.67 +_STLP_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
    1.68 +template <>
    1.69 +_STLP_DECLSPEC locale::id money_put<char, char*>::id;
    1.70 +
    1.71 +#    if !defined (_STLP_NO_WCHAR_T)
    1.72 +template <>
    1.73 +_STLP_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
    1.74 +template <>
    1.75 +_STLP_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id;
    1.76 +
    1.77 +template <>
    1.78 +_STLP_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
    1.79 +template <>
    1.80 +_STLP_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id;
    1.81 +#    endif
    1.82 +
    1.83 +#  endif
    1.84 +
    1.85 +#else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
    1.86 +
    1.87 +//typedef money_get<char, const char*> money_get_char;
    1.88 +//typedef money_put<char, char*> money_put_char;
    1.89 +typedef money_get<char, istreambuf_iterator<char, char_traits<char> > > money_get_char_2;
    1.90 +typedef money_put<char, ostreambuf_iterator<char, char_traits<char> > > money_put_char_2;
    1.91 +
    1.92 +//__DECLARE_INSTANCE(locale::id, money_get_char::id, );
    1.93 +//__DECLARE_INSTANCE(locale::id, money_put_char::id, );
    1.94 +__DECLARE_INSTANCE(locale::id, money_get_char_2::id, );
    1.95 +__DECLARE_INSTANCE(locale::id, money_put_char_2::id, );
    1.96 +
    1.97 +#  ifndef _STLP_NO_WCHAR_T
    1.98 +
    1.99 +//typedef money_get<wchar_t, const wchar_t*> money_get_wchar_t;
   1.100 +//typedef money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > money_get_wchar_t_2;
   1.101 +typedef money_put<wchar_t, wchar_t*> money_put_wchar_t;
   1.102 +typedef money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > money_put_wchar_t_2;
   1.103 +
   1.104 +//__DECLARE_INSTANCE(locale::id, money_get_wchar_t::id, );
   1.105 +//__DECLARE_INSTANCE(locale::id, money_put_wchar_t::id, );
   1.106 +__DECLARE_INSTANCE(locale::id, money_get_wchar_t_2::id, );
   1.107 +__DECLARE_INSTANCE(locale::id, money_put_wchar_t_2::id, );
   1.108 +
   1.109 +#  endif
   1.110 +#endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
   1.111 +
   1.112 +// money_get facets
   1.113 +
   1.114 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.115 +
   1.116 +// helper functions for do_get
   1.117 +template <class _InIt1, class _InIt2>
   1.118 +pair<_InIt1, bool> __get_string( _InIt1 __first, _InIt1 __last,
   1.119 +                                 _InIt2 __str_first, _InIt2 __str_last) {
   1.120 +  while ( __first != __last && __str_first != __str_last && *__first == *__str_first ) {
   1.121 +    ++__first;
   1.122 +    ++__str_first;
   1.123 +  }
   1.124 +  return make_pair(__first, __str_first == __str_last);
   1.125 +}
   1.126 +
   1.127 +template <class _InIt, class _OuIt, class _CharT>
   1.128 +bool
   1.129 +__get_monetary_value(_InIt& __first, _InIt __last, _OuIt __out_ite,
   1.130 +                     const ctype<_CharT>& _c_type,
   1.131 +                     _CharT __point, int __frac_digits, _CharT __sep,
   1.132 +                     const string& __grouping, bool &__syntax_ok) {
   1.133 +  if (__first == __last || !_c_type.is(ctype_base::digit, *__first))
   1.134 +    return false;
   1.135 +
   1.136 +  char __group_sizes[128];
   1.137 +  char* __group_sizes_end = __grouping.empty()? 0 : __group_sizes;
   1.138 +  char   __current_group_size = 0;
   1.139 +
   1.140 +  while (__first != __last) {
   1.141 +    if (_c_type.is(ctype_base::digit, *__first)) {
   1.142 +      ++__current_group_size;
   1.143 +      *__out_ite++ = *__first++;
   1.144 +    }
   1.145 +    else if (__group_sizes_end) {
   1.146 +      if (*__first == __sep) {
   1.147 +        *__group_sizes_end++ = __current_group_size;
   1.148 +        __current_group_size = 0;
   1.149 +        ++__first;
   1.150 +      }
   1.151 +      else break;
   1.152 +    }
   1.153 +    else
   1.154 +      break;
   1.155 +  }
   1.156 +
   1.157 +  if (__grouping.empty())
   1.158 +    __syntax_ok = true;
   1.159 +  else {
   1.160 +    if (__group_sizes_end != __group_sizes)
   1.161 +      *__group_sizes_end++ = __current_group_size;
   1.162 +
   1.163 +    __syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end,
   1.164 +                                   __grouping.data(), __grouping.data()+ __grouping.size());
   1.165 +
   1.166 +    if (__first == __last || *__first != __point) {
   1.167 +      for (int __digits = 0; __digits != __frac_digits; ++__digits)
   1.168 +        *__out_ite++ = _CharT('0');
   1.169 +      return true; // OK not to have decimal point
   1.170 +    }
   1.171 +  }
   1.172 +
   1.173 +  ++__first;
   1.174 +
   1.175 +  int __digits = 0;
   1.176 +
   1.177 +  while (__first != __last && _c_type.is(ctype_base::digit, *__first)) {
   1.178 +      *__out_ite++ = *__first++;
   1.179 +     ++__digits;
   1.180 +  }
   1.181 +
   1.182 +  __syntax_ok = __syntax_ok && (__digits == __frac_digits);
   1.183 +
   1.184 +  return true;
   1.185 +}
   1.186 +
   1.187 +
   1.188 +template <class _CharT, class _InputIter, class _StrType>
   1.189 +_InputIter __money_do_get(_InputIter __s, _InputIter __end, bool  __intl,
   1.190 +                     ios_base&  __str, ios_base::iostate&  __err,
   1.191 +                     _StrType& __digits, bool &__is_positive, _CharT* /*__dummy*/) {
   1.192 +  if (__s == __end) {
   1.193 +    __err |= ios_base::eofbit;
   1.194 +    return __s;
   1.195 +  }
   1.196 +
   1.197 +  typedef _CharT char_type;
   1.198 +  typedef _StrType string_type;
   1.199 +  typedef _InputIter iter_type;
   1.200 +  typedef moneypunct<char_type, false> _Punct;
   1.201 +  typedef moneypunct<char_type, true>  _Punct_intl;
   1.202 +  typedef ctype<char_type>             _Ctype;
   1.203 +
   1.204 +  locale __loc = __str.getloc();
   1.205 +  const _Punct&      __punct      = use_facet<_Punct>(__loc) ;
   1.206 +  const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
   1.207 +  const _Ctype&      __c_type     = use_facet<_Ctype>(__loc) ;
   1.208 +
   1.209 +  money_base::pattern __format = __intl ? __punct_intl.neg_format()
   1.210 +                                        : __punct.neg_format();
   1.211 +  string_type __ns = __intl ? __punct_intl.negative_sign()
   1.212 +                            : __punct.negative_sign();
   1.213 +  string_type __ps = __intl ? __punct_intl.positive_sign()
   1.214 +                            : __punct.positive_sign();
   1.215 +  int __i;
   1.216 +  bool __symbol_required = (__str.flags() & ios_base::showbase) != 0;
   1.217 +  string_type __buf;
   1.218 +  back_insert_iterator<string_type> __out_ite(__buf);
   1.219 +
   1.220 +  for (__i = 0; __i < 4; ++__i) {
   1.221 +    switch (__format.field[__i]) {
   1.222 +    case money_base::none:
   1.223 +      if (__i == 3) {
   1.224 +        if (__c_type.is(ctype_base::space, *__s)) {
   1.225 +          __err = ios_base::failbit;
   1.226 +          return __s;
   1.227 +        }
   1.228 +        break;
   1.229 +      }
   1.230 +      while (__s != __end && __c_type.is(ctype_base::space, *__s))
   1.231 +        ++__s;
   1.232 +      break;
   1.233 +    case money_base::space:
   1.234 +      if (!__c_type.is(ctype_base::space, *__s)) {
   1.235 +        __err = ios_base::failbit;
   1.236 +        return __s;
   1.237 +      }
   1.238 +      ++__s;
   1.239 +      while (__s != __end && __c_type.is(ctype_base::space, *__s))
   1.240 +        ++__s;
   1.241 +      break;
   1.242 +    case money_base::symbol: {
   1.243 +      string_type __curs = __intl ? __punct_intl.curr_symbol()
   1.244 +                                  : __punct.curr_symbol();
   1.245 +      pair<iter_type, bool>
   1.246 +      __result  = __get_string(__s, __end, __curs.begin(), __curs.end());
   1.247 +      if (!__result.second && __symbol_required)
   1.248 +        __err = ios_base::failbit;
   1.249 +      __s = __result.first;
   1.250 +      break;
   1.251 +    }
   1.252 +    case money_base::sign: {
   1.253 +      if (__s == __end) {
   1.254 +        if (__ps.empty())
   1.255 +          break;
   1.256 +        if (__ns.empty()) {
   1.257 +          __is_positive = false;
   1.258 +          break;
   1.259 +        }
   1.260 +        __err = ios_base::failbit;
   1.261 +        return __s;
   1.262 +      }
   1.263 +      else {
   1.264 +        if (__ps.empty()) {
   1.265 +          if (__ns.empty())
   1.266 +            break;
   1.267 +          if (*__s == __ns[0]) {
   1.268 +            ++__s;
   1.269 +            __is_positive = false;
   1.270 +          }
   1.271 +          break;
   1.272 +        }
   1.273 +        else {
   1.274 +          if (*__s == __ps[0]) {
   1.275 +            ++__s;
   1.276 +            break;
   1.277 +          }
   1.278 +          if (__ns.empty())
   1.279 +            break;
   1.280 +          if (*__s == __ns[0]) {
   1.281 +            ++__s;
   1.282 +            __is_positive = false;
   1.283 +            break;
   1.284 +          }
   1.285 +          __err = ios_base::failbit;
   1.286 +        }
   1.287 +      }
   1.288 +      return __s;
   1.289 +    }
   1.290 +    case money_base::value: {
   1.291 +      char_type __point = __intl ? __punct_intl.decimal_point()
   1.292 +                                 : __punct.decimal_point();
   1.293 +      int __frac_digits = __intl ? __punct_intl.frac_digits()
   1.294 +                                 : __punct.frac_digits();
   1.295 +      string __grouping = __intl ? __punct_intl.grouping()
   1.296 +                                 : __punct.grouping();
   1.297 +      bool __syntax_ok = true;
   1.298 +
   1.299 +      bool __result;
   1.300 +
   1.301 +      char_type __sep = __grouping.empty() ? char_type() :
   1.302 +      __intl ? __punct_intl.thousands_sep() : __punct.thousands_sep();
   1.303 +
   1.304 +      __result = __get_monetary_value(__s, __end, __out_ite, __c_type,
   1.305 +                                      __point, __frac_digits,
   1.306 +                                      __sep,
   1.307 +                                      __grouping, __syntax_ok);
   1.308 +
   1.309 +      if (!__syntax_ok)
   1.310 +        __err |= ios_base::failbit;
   1.311 +      if (!__result) {
   1.312 +        __err = ios_base::failbit;
   1.313 +        return __s;
   1.314 +      }
   1.315 +      break;
   1.316 +
   1.317 +    }                           // Close money_base::value case
   1.318 +    }                           // Close switch statement
   1.319 +  }                             // Close for loop
   1.320 +
   1.321 +  if (__is_positive) {
   1.322 +    if (__ps.size() > 1) {
   1.323 +      pair<_InputIter, bool>
   1.324 +        __result = __get_string(__s, __end, __ps.begin() + 1, __ps.end());
   1.325 +      __s = __result.first;
   1.326 +      if (!__result.second)
   1.327 +        __err |= ios::failbit;
   1.328 +    }
   1.329 +    if (!(__err & ios_base::failbit))
   1.330 +      __digits = __buf;
   1.331 +  }
   1.332 +  else {
   1.333 +    if (__ns.size() > 1) {
   1.334 +      pair<_InputIter, bool>
   1.335 +        __result = __get_string(__s, __end, __ns.begin() + 1, __ns.end());
   1.336 +      __s = __result.first;
   1.337 +      if (!__result.second)
   1.338 +        __err |= ios::failbit;
   1.339 +    }
   1.340 +    if (!(__err & ios::failbit)) {
   1.341 +      __digits = __c_type.widen('-');
   1.342 +      __digits += __buf;
   1.343 +    }
   1.344 +  }
   1.345 +  if (__s == __end)
   1.346 +    __err |= ios::eofbit;
   1.347 +
   1.348 +  return __s;
   1.349 +}
   1.350 +
   1.351 +_STLP_MOVE_TO_STD_NAMESPACE
   1.352 +
   1.353 +//===== methods ======
   1.354 +template <class _CharT, class _InputIter>
   1.355 +_InputIter
   1.356 +money_get<_CharT, _InputIter>::do_get(_InputIter __s, _InputIter  __end, bool  __intl,
   1.357 +                                      ios_base&  __str, ios_base::iostate& __err,
   1.358 +                                      _STLP_LONGEST_FLOAT_TYPE& __units) const {
   1.359 +  string_type __buf;
   1.360 +  bool __is_positive = true;
   1.361 +  __s = _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __buf, __is_positive, (_CharT*)0);
   1.362 +
   1.363 +  if (__err == ios_base::goodbit || __err == ios_base::eofbit) {
   1.364 +    typename string_type::iterator __b = __buf.begin(), __e = __buf.end();
   1.365 +
   1.366 +    if (!__is_positive) ++__b;
   1.367 +    // Can't use atold, since it might be wchar_t. Don't get confused by name below :
   1.368 +    // it's perfectly capable of reading long double.
   1.369 +    _STLP_PRIV __get_decimal_integer(__b, __e, __units, (_CharT*)0);
   1.370 +
   1.371 +    if (!__is_positive) {
   1.372 +      __units = -__units;
   1.373 +    }
   1.374 +  }
   1.375 +
   1.376 +  return __s;
   1.377 +}
   1.378 +
   1.379 +template <class _CharT, class _InputIter>
   1.380 +_InputIter
   1.381 +money_get<_CharT, _InputIter>::do_get(iter_type __s, iter_type  __end, bool  __intl,
   1.382 +                                      ios_base&  __str, ios_base::iostate&  __err,
   1.383 +                                      string_type& __digits) const {
   1.384 +  bool __is_positive = true;
   1.385 +  return _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __digits, __is_positive, (_CharT*)0);
   1.386 +}
   1.387 +
   1.388 +// money_put facets
   1.389 +
   1.390 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.391 +
   1.392 +template <class _CharT, class _OutputIter, class _Str_Type, class _Str>
   1.393 +_OutputIter __money_do_put(_OutputIter __s, bool  __intl, ios_base&  __str,
   1.394 +                           _CharT __fill, const _Str& __digits, bool __check_digits,
   1.395 +                           _Str_Type * /*__dummy*/) {
   1.396 +  typedef _CharT char_type;
   1.397 +  typedef _Str_Type string_type;
   1.398 +  typedef ctype<char_type>             _Ctype;
   1.399 +  typedef moneypunct<char_type, false> _Punct;
   1.400 +  typedef moneypunct<char_type, true>  _Punct_intl;
   1.401 +
   1.402 +  locale __loc = __str.getloc();
   1.403 +  const _Ctype&      __c_type     = use_facet<_Ctype>(__loc) ;
   1.404 +  const _Punct&      __punct      = use_facet<_Punct>(__loc) ;
   1.405 +  const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
   1.406 +
   1.407 +  // some special characters
   1.408 +  char_type __minus = __c_type.widen('-');
   1.409 +  char_type __plus  = __c_type.widen('+');
   1.410 +  char_type __space = __c_type.widen(' ');
   1.411 +  char_type __zero  = __c_type.widen('0');
   1.412 +  char_type __point = __intl ? __punct_intl.decimal_point()
   1.413 +                             : __punct.decimal_point();
   1.414 +
   1.415 +  char_type __sep = __intl ? __punct_intl.thousands_sep()
   1.416 +                           : __punct.thousands_sep();
   1.417 +
   1.418 +  string __grouping = __intl ? __punct_intl.grouping()
   1.419 +                             : __punct.grouping();
   1.420 +
   1.421 +  int __frac_digits      = __intl ? __punct_intl.frac_digits()
   1.422 +                                  : __punct.frac_digits();
   1.423 +
   1.424 +  string_type __curr_sym = __intl ? __punct_intl.curr_symbol()
   1.425 +                                  : __punct.curr_symbol();
   1.426 +
   1.427 +  // if there are no digits we are going to return __s.  If there
   1.428 +  // are digits, but not enough to fill the frac_digits, we are
   1.429 +  // going to add zeros.  I don't know whether this is right or
   1.430 +  // not.
   1.431 +  if (__digits.empty())
   1.432 +    return __s;
   1.433 +
   1.434 +  typename string_type::const_iterator __digits_first = __digits.begin();
   1.435 +  typename string_type::const_iterator __digits_last  = __digits.end();
   1.436 +
   1.437 +  bool __is_negative = *__digits_first == __minus;
   1.438 +  if (__is_negative)
   1.439 +    ++__digits_first;
   1.440 +
   1.441 +#if !defined (__BORLANDC__)
   1.442 +  string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign()
   1.443 +                                              : __punct_intl.positive_sign()
   1.444 +                              : __is_negative ? __punct.negative_sign()
   1.445 +                                              : __punct.positive_sign();
   1.446 +#else
   1.447 +  string_type __sign;
   1.448 +  if (__intl) {
   1.449 +    if (__is_negative)
   1.450 +      __sign = __punct_intl.negative_sign();
   1.451 +    else
   1.452 +      __sign = __punct_intl.positive_sign();
   1.453 +  }
   1.454 +  else {
   1.455 +    if (__is_negative)
   1.456 +      __sign = __punct.negative_sign();
   1.457 +    else
   1.458 +      __sign = __punct.positive_sign();
   1.459 +  }
   1.460 +#endif
   1.461 +
   1.462 +  if (__check_digits) {
   1.463 +    typename string_type::const_iterator __cp = __digits_first;
   1.464 +    while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp))
   1.465 +      ++__cp;
   1.466 +    if (__cp == __digits_first)
   1.467 +      return __s;
   1.468 +    __digits_last = __cp;
   1.469 +  }
   1.470 +
   1.471 +  // If grouping is required, we make a copy of __digits and
   1.472 +  // insert the grouping.
   1.473 +  _STLP_BASIC_IOSTRING(char_type) __new_digits;
   1.474 +  if (!__grouping.empty()) {
   1.475 +    __new_digits.assign(__digits_first, __digits_last);
   1.476 +    __insert_grouping(__new_digits,
   1.477 +                      __new_digits.size() - __frac_digits,
   1.478 +                      __grouping,
   1.479 +                      __sep, __plus, __minus, 0);
   1.480 +    __digits_first = __new_digits.begin(); // <<--
   1.481 +    __digits_last  = __new_digits.end();   // <<--
   1.482 +  }
   1.483 +
   1.484 +  // Determine the amount of padding required, if any.
   1.485 +  streamsize __width = __str.width();
   1.486 +
   1.487 +#if defined (_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1))
   1.488 +  size_t __value_length = operator -(__digits_last, __digits_first);
   1.489 +#else
   1.490 +  size_t __value_length = __digits_last - __digits_first;
   1.491 +#endif
   1.492 +
   1.493 +  size_t __length = __value_length + __sign.size();
   1.494 +
   1.495 +  if (__frac_digits != 0)
   1.496 +    ++__length;
   1.497 +
   1.498 +  bool __generate_curr = (__str.flags() & ios_base::showbase) !=0;
   1.499 +  if (__generate_curr)
   1.500 +    __length += __curr_sym.size();
   1.501 +  money_base::pattern __format = __intl ? (__is_negative ? __punct_intl.neg_format()
   1.502 +                                                         : __punct_intl.pos_format())
   1.503 +                                        : (__is_negative ? __punct.neg_format()
   1.504 +                                                         : __punct.pos_format());
   1.505 +  {
   1.506 +    //For the moment the following is commented for decoding reason.
   1.507 +    //No reason to add a space last if the money symbol do not have to be display
   1.508 +    //if (__format.field[3] == (char) money_base::symbol && !__generate_curr) {
   1.509 +    //  if (__format.field[2] == (char) money_base::space) {
   1.510 +    //    __format.field[2] = (char) money_base::none;
   1.511 +    //  }
   1.512 +    //}
   1.513 +    //space can only be second or third and only once (22.2.6.3-1):
   1.514 +    if ((__format.field[1] == (char) money_base::space) ||
   1.515 +        (__format.field[2] == (char) money_base::space))
   1.516 +      ++__length;
   1.517 +  }
   1.518 +
   1.519 +  const bool __need_fill = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __length) < __width)) ||
   1.520 +                            ((sizeof(streamsize) <= sizeof(size_t)) && (__length < __STATIC_CAST(size_t, __width))));
   1.521 +  streamsize __fill_amt = __need_fill ? __width - __length : 0;
   1.522 +
   1.523 +  ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield;
   1.524 +
   1.525 +  if (__fill_amt != 0 &&
   1.526 +      !(__fill_pos & (ios_base::left | ios_base::internal)))
   1.527 +    __s = __fill_n(__s, __fill_amt, __fill);
   1.528 +
   1.529 +  for (int __i = 0; __i < 4; ++__i) {
   1.530 +    char __ffield = __format.field[__i];
   1.531 +    switch (__ffield) {
   1.532 +      case money_base::none:
   1.533 +        if (__fill_amt != 0 && __fill_pos == ios_base::internal)
   1.534 +          __s = __fill_n(__s, __fill_amt, __fill);
   1.535 +        break;
   1.536 +      case money_base::space:
   1.537 +        *__s++ = __space;
   1.538 +        if (__fill_amt != 0 && __fill_pos == ios_base::internal)
   1.539 +          __s = __fill_n(__s, __fill_amt, __fill);
   1.540 +        break;
   1.541 +      case money_base::symbol:
   1.542 +        if (__generate_curr)
   1.543 +          __s = copy(__curr_sym.begin(), __curr_sym.end(), __s);
   1.544 +        break;
   1.545 +      case money_base::sign:
   1.546 +        if (!__sign.empty())
   1.547 +          *__s++ = __sign[0];
   1.548 +        break;
   1.549 +      case money_base::value:
   1.550 +        if (__frac_digits == 0) {
   1.551 +          __s = copy(__digits_first, __digits_last, __s);
   1.552 +        } else {
   1.553 +          if ((int)__value_length <= __frac_digits) {
   1.554 +            // if we see '9' here, we should out 0.09
   1.555 +            *__s++ = __zero;  // integer part is zero
   1.556 +            *__s++ = __point; // decimal point
   1.557 +            __s =  __fill_n(__s, __frac_digits - __value_length, __zero); // zeros
   1.558 +            __s = copy(__digits_first, __digits_last, __s); // digits
   1.559 +          } else {
   1.560 +            __s = copy(__digits_first, __digits_last - __frac_digits, __s);
   1.561 +            if (__frac_digits != 0) {
   1.562 +              *__s++ = __point;
   1.563 +              __s = copy(__digits_last - __frac_digits, __digits_last, __s);
   1.564 +            }
   1.565 +          }
   1.566 +        }
   1.567 +        break;
   1.568 +    } //Close for switch
   1.569 +  } // Close for loop
   1.570 +
   1.571 +  // Ouput rest of sign if necessary.
   1.572 +  if (__sign.size() > 1)
   1.573 +    __s = copy(__sign.begin() + 1, __sign.end(), __s);
   1.574 +  if (__fill_amt != 0 &&
   1.575 +      !(__fill_pos & (ios_base::right | ios_base::internal)))
   1.576 +    __s = __fill_n(__s, __fill_amt, __fill);
   1.577 +
   1.578 +  return __s;
   1.579 +}
   1.580 +
   1.581 +_STLP_MOVE_TO_STD_NAMESPACE
   1.582 +
   1.583 +template <class _CharT, class _OutputIter>
   1.584 +_OutputIter
   1.585 +money_put<_CharT, _OutputIter>
   1.586 + ::do_put(_OutputIter __s, bool __intl, ios_base& __str,
   1.587 +          char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const {
   1.588 +  _STLP_BASIC_IOSTRING(char_type) __digits;
   1.589 +  _STLP_PRIV __get_money_digits(__digits, __str, __units);
   1.590 +  return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, false, __STATIC_CAST(string_type*, 0));
   1.591 +}
   1.592 +
   1.593 +template <class _CharT, class _OutputIter>
   1.594 +_OutputIter
   1.595 +money_put<_CharT, _OutputIter>
   1.596 + ::do_put(_OutputIter __s, bool __intl, ios_base& __str,
   1.597 +          char_type __fill, const string_type& __digits) const {
   1.598 +  return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, true, __STATIC_CAST(string_type*, 0));
   1.599 +}
   1.600 +
   1.601 +_STLP_END_NAMESPACE
   1.602 +
   1.603 +#endif /* _STLP_MONETARY_C */
   1.604 +
   1.605 +// Local Variables:
   1.606 +// mode:C++
   1.607 +// End: