52#if defined (_RWSTD_MSVC) && defined (_WIN64)
54# pragma warning (disable: 4244)
62__rw_copy (
void *dst,
const void *src,
size_t n)
68__rw_widen (
void *dst,
const void *src,
size_t n)
76__rw_get_numpunct (
const __rw_facet *pfacet,
int flags)
78 const int member =
flags & ~(__rw_mon | __rw_wide | __rw_intl);
79 const bool winx = !!(
flags & __rw_wide);
80 const void *pdata = pfacet->_C_data ();
84 const __rw_punct_t*
const pun =
87 const __rw_num_t *
num;
91 case __rw_dp:
return pun->decimal_point (winx);
92 case __rw_ts:
return pun->thousands_sep (winx);
93 case __rw_gr:
return pun->grouping ();
98 return num->truename (winx);
103 return num->falsename (winx);
110 else if (0 == __rw_access::_C_get_name (*pfacet)) {
112 static const void*
const cdata[] = {
113 ".",
L".",
",",
L",",
"",
L"",
"true",
L"true",
"false",
L"false"
118 case __rw_dp:
return cdata [0 + winx];
119 case __rw_ts:
return cdata [2 + winx];
120 case __rw_gr:
return cdata [4 + winx];
121 case __rw_tn:
return cdata [6 + winx];
122 case __rw_fn:
return cdata [8 + winx];
130 const char*
const locname = __rw_access::_C_get_name (*pfacet) ?
131 __rw_access::_C_get_name (*pfacet) :
"C";
134 const __rw_setlocale clocale (locname, _RWSTD_LC_ALL);
136 if (pfacet->_C_data ()) {
141 return __rw_get_numpunct (pfacet,
flags);
145 const lconv*
const pconv = localeconv ();
151 const char*
const grp = pconv->grouping ? pconv->grouping :
"";
152 const char*
const dp = pconv->decimal_point ? pconv->decimal_point :
"";
153 const char*
const ts = pconv->thousands_sep ? pconv->thousands_sep :
"";
156 const size_t grsz = strlen (grp) + 1;
159 size_t dpsz = strlen (dp) + 1;
160 size_t tssz = strlen (ts) + 1;
161 size_t tnsz =
sizeof "true";
162 size_t fnsz =
sizeof "false";
174 sizeof (__rw_punct_t)
175 +
sizeof (__rw_num_t)
177 + grsz + dpsz + tssz + tnsz + fnsz;
180 __rw_punct_t*
const pun =
184 pun->decimal_point_off [winx] = 0;
185 pun->thousands_sep_off [winx] = pun->decimal_point_off [winx] + int (dpsz);
188 void (*
widen)(
void*,
const void*, size_t) =
189 winx ? __rw_widen : __rw_copy;
194 widen (
s + pun->decimal_point_off [winx], dp, dpsz);
195 widen (
s + pun->thousands_sep_off [winx], ts, tssz);
198 pun->punct_ext_off = pun->thousands_sep_off [winx] + int (tssz);
201 const size_t misalign = pun->punct_ext_off %
sizeof (size_t);
203 pun->punct_ext_off += int (
sizeof (
size_t) - misalign);
212 memset (
num, ~0,
sizeof *
num);
214 num->truename_off [winx] = 0;
215 num->falsename_off [winx] =
num->truename_off [winx] + int (tnsz);
217 widen (
s +
num->truename_off [winx],
"true", tnsz);
218 widen (
s +
num->falsename_off [winx],
"false", fnsz);
223 pun->punct_ext_off +
sizeof *
num +
num->falsename_off [winx] + fnsz);
225 memcpy (
s +
num->falsename_off [winx] + fnsz, grp, grsz);
235 return __rw_get_numpunct (pfacet,
flags);
242__rw_get_moneypunct (
const __rw_facet *pfacet,
int flags)
244 const int member =
flags & ~(__rw_mon | __rw_wide | __rw_intl);
245 const bool winx = !!(
flags & __rw_wide);
246 const bool intl = !!(
flags & __rw_intl);
247 const void *pdata = pfacet->_C_data ();
251 const __rw_punct_t*
const pun =
254 const __rw_mon_t *mon;
257 case __rw_dp:
return pun->decimal_point (winx);
258 case __rw_ts:
return pun->thousands_sep (winx);
259 case __rw_gr:
return pun->grouping ();
267 typedef unsigned char UChar;
271 case __rw_cs:
return mon->curr_symbol (intl, winx);
272 case __rw_ps:
return mon->positive_sign (winx);
273 case __rw_ns:
return mon->negative_sign (winx);
275 case __rw_pf:
return mon->pos_format [intl];
276 case __rw_nf:
return mon->neg_format [intl];
280 UChar (mon->frac_digits [intl]));
287 else if (0 == __rw_access::_C_get_name (*pfacet)) {
289 static const void*
const cdata[] = {
290 ".",
L".",
",",
L",",
"",
L"",
"",
L"",
"",
L"",
291 "",
L"",
"",
L"",
"\2\3\0\4",
"\2\3\0\4",
296 case __rw_dp:
return cdata [0 + winx];
297 case __rw_ts:
return cdata [2 + winx];
298 case __rw_gr:
return cdata [4 + winx];
299 case __rw_cs:
return cdata [6 + winx + 2 * intl];
300 case __rw_ps:
return cdata [10 + winx];
301 case __rw_ns:
return cdata [12 + winx];
302 case __rw_pf:
return cdata [14];
303 case __rw_nf:
return cdata [15];
306 case __rw_fd:
return 0;
314 const char*
const locname = __rw_access::_C_get_name (*pfacet) ?
315 __rw_access::_C_get_name (*pfacet) :
"C";
318 const __rw_setlocale clocale (locname, _RWSTD_LC_ALL);
320 if (pfacet->_C_data ()) {
325 return __rw_get_moneypunct (pfacet,
flags);
329 const lconv*
const pconv = localeconv ();
338 const size_t grsz = strlen (pconv->mon_grouping) + 1;
341 size_t dpsz = strlen (pconv->mon_decimal_point) + 1;
342 size_t tssz = strlen (pconv->mon_thousands_sep) + 1;
343 size_t pssz = strlen (pconv->positive_sign) + 1;
344 size_t nssz = strlen (pconv->negative_sign) + 1;
346 const char*
const cs = intl ? pconv->int_curr_symbol
347 : pconv->currency_symbol;
349 size_t cssz = strlen (cs) + 1;
362 sizeof (__rw_punct_t)
363 +
sizeof (__rw_mon_t)
365 + grsz + dpsz + tssz + pssz + nssz + cssz;
368 __rw_punct_t*
const pun =
372 pun->decimal_point_off [winx] = 0;
373 pun->thousands_sep_off [winx] = pun->decimal_point_off [winx] + int (dpsz);
376 void (*
widen)(
void*,
const void*, size_t) =
377 winx ? __rw_widen : __rw_copy;
382 widen (
s + pun->decimal_point_off [winx], pconv->mon_decimal_point, dpsz);
383 widen (
s + pun->thousands_sep_off [winx], pconv->mon_thousands_sep, tssz);
386 pun->punct_ext_off = pun->thousands_sep_off [winx] + int (tssz);
389 const size_t misalign = pun->punct_ext_off %
sizeof (size_t);
391 pun->punct_ext_off += int (
sizeof (
size_t) - misalign);
400 memset (mon, ~0,
sizeof *mon);
402 mon->positive_sign_off [winx] = 0;
403 mon->negative_sign_off [winx] = mon->positive_sign_off [winx] + int (pssz);
405 widen (
s + mon->positive_sign_off [winx], pconv->positive_sign, pssz);
406 widen (
s + mon->negative_sign_off [winx], pconv->negative_sign, nssz);
408 mon->curr_symbol_off [intl][winx] =
409 mon->negative_sign_off [winx] + int (nssz);
411 widen (
s + mon->curr_symbol_off [intl][winx], cs, cssz);
415 pun->punct_ext_off +
sizeof *mon
416 + mon->curr_symbol_off [intl][winx] + cssz);
419 memcpy (
s + mon->curr_symbol_off [intl][winx] + cssz,
420 pconv->mon_grouping, grsz);
422 mon->frac_digits [0] = pconv->frac_digits;
423 mon->frac_digits [1] = pconv->int_frac_digits;
426 mon->p_cs_precedes [0] = pconv->p_cs_precedes;
427 mon->n_cs_precedes [0] = pconv->n_cs_precedes;
428 mon->p_sep_by_space [0] = pconv->p_sep_by_space;
429 mon->n_sep_by_space [0] = pconv->n_sep_by_space;
430 mon->p_sign_posn [0] = pconv->p_sign_posn;
431 mon->n_sign_posn [0] = pconv->n_sign_posn;
433#ifndef _RWSTD_NO_LCONV_INT_FMAT
436 mon->p_cs_precedes [1] = pconv->int_p_cs_precedes;
437 mon->n_cs_precedes [1] = pconv->int_n_cs_precedes;
438 mon->p_sep_by_space [1] = pconv->int_p_sep_by_space;
439 mon->n_sep_by_space [1] = pconv->int_n_sep_by_space;
440 mon->p_sign_posn [1] = pconv->int_p_sign_posn;
441 mon->n_sign_posn [1] = pconv->int_n_sign_posn;
446 mon->p_cs_precedes [1] = mon->p_cs_precedes [0];
447 mon->n_cs_precedes [1] = mon->n_cs_precedes [0];
448 mon->p_sep_by_space [1] = mon->p_sep_by_space [0];
449 mon->n_sep_by_space [1] = mon->n_sep_by_space [0];
450 mon->p_sign_posn [1] = mon->p_sign_posn [0];
451 mon->n_sign_posn [1] = mon->n_sign_posn [0];
457 none = _STD::money_base::none,
458 space = _STD::money_base::space,
459 symbol = _STD::money_base::symbol,
460 sign = _STD::money_base::sign,
461 value = _STD::money_base::value
464 static const _STD::money_base::pattern pat[] = {
500 { { sign,
value, symbol, none } },
501 { { sign,
value, symbol, none } },
502 { {
value, symbol, sign, none } },
503 { {
value, sign, symbol, none } },
504 { {
value, symbol, sign, none } },
506 { { sign,
value, space, symbol } },
507 { { sign,
value, space, symbol } },
508 { {
value, space, symbol, sign } },
509 { {
value, space, sign, symbol } },
510 { {
value, space, symbol, sign } },
512 { { sign, space,
value, symbol } },
513 { { sign, space,
value, symbol } },
514 { {
value, symbol, space, sign } },
515 { {
value, sign, space, symbol } },
516 { {
value, symbol, space, sign } },
518 { { sign, symbol,
value, none } },
519 { { sign, symbol,
value, none } },
520 { { symbol,
value, sign, none } },
521 { { sign, symbol,
value, none } },
522 { { symbol, sign,
value, none } },
524 { { sign, symbol, space,
value } },
525 { { sign, symbol, space,
value } },
526 { { symbol, space,
value, sign } },
527 { { sign, symbol, space,
value } },
528 { { symbol, sign, space,
value } },
530 { { sign, space, symbol,
value } },
531 { { sign, space, symbol,
value } },
532 { { symbol,
value, space, sign } },
533 { { sign, space, symbol,
value } },
534 { { symbol, space, sign,
value } }
537 size_t inx = size_t (mon->p_cs_precedes [intl]) * (3U * 5U)
538 +
size_t (mon->p_sep_by_space [intl]) * 5U
539 + size_t (mon->p_sign_posn [intl]);
541 if (
inx <
sizeof pat /
sizeof *pat)
542 memcpy (mon->pos_format [intl], pat +
inx,
sizeof *pat);
544 memset (mon->pos_format [intl], none,
sizeof *pat);
546 inx = size_t (mon->n_cs_precedes [intl]) * (3U * 5U)
547 +
size_t (mon->n_sep_by_space [intl]) * 5U
548 + size_t (mon->n_sign_posn [intl]);
550 if (
inx <
sizeof pat /
sizeof *pat)
551 memcpy (mon->neg_format [intl], pat +
inx,
sizeof *pat);
553 memset (mon->neg_format [intl], none,
sizeof *pat);
563 return __rw_get_moneypunct (pfacet,
flags);
571__rw_get_punct(
const __rw_facet *pfacet,
int flags,
char)
573 typedef const char *CPChar;
575 if (
flags & __rw_mon)
576 return CPChar (__rw_get_moneypunct (pfacet,
flags & ~__rw_mon));
578 return CPChar (__rw_get_numpunct (pfacet,
flags));
582#ifndef _RWSTD_NO_WCHAR_T
586__rw_get_punct(
const __rw_facet *pfacet,
int flags,
wchar_t)
590 typedef const wchar_t *CPWChar;
592 if (
flags & __rw_mon)
593 return CPWChar (__rw_get_moneypunct (pfacet,
flags & ~__rw_mon));
595 return CPWChar (__rw_get_numpunct (pfacet,
flags));
602__rw_get_stdio_fmat (
char buf [32],
int type,
unsigned fmtflags,
615 if (type & __rw_facet::_C_floating) {
625 pbuf += sprintf (pbuf,
".%ld",
long (prec));
633 Short = __rw_facet::_C_ushort & __rw_facet::_C_typemask,
634 Long = __rw_facet::_C_ulong & __rw_facet::_C_typemask,
635 LLong = __rw_facet::_C_ullong & __rw_facet::_C_typemask,
636 Double = __rw_facet::_C_double & __rw_facet::_C_typemask,
637 LDouble = __rw_facet::_C_ldouble & __rw_facet::_C_typemask
640 const int basetype = type & __rw_facet::_C_typemask;
644 case Short: *pbuf++ =
'h';
break;
650 case LDouble: *pbuf++ =
'L';
break;
654#ifdef _RWSTD_LLONG_PRINTF_PREFIX
656 memcpy (pbuf, _RWSTD_LLONG_PRINTF_PREFIX,
657 sizeof _RWSTD_LLONG_PRINTF_PREFIX - 1);
658 pbuf +=
sizeof _RWSTD_LLONG_PRINTF_PREFIX - 1;
669 if (type & __rw_facet::_C_floating) {
684 else if (type == __rw_facet::_C_pvoid)
const char * widen(char *dst, const char *src)
#define _RWSTD_IOS_BOOLALPHA
#define _RWSTD_IOS_BASEFIELD
#define _RWSTD_IOS_FLOATFIELD
#define _RWSTD_IOS_UPPERCASE
#define _RWSTD_REINTERPRET_CAST(T, x)
#define _RWSTD_STATIC_CAST(T, x)
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_STREAMSIZE
#define _RWSTD_IOS_SHOWBASE
#define _RWSTD_ASSERT(ignore)
#define _RWSTD_IOS_SCIENTIFIC
#define _RWSTD_CONST_CAST(T, x)
#define _RWSTD_IOS_SHOWPOS
#define _RWSTD_IOS_SHOWPOINT
#define _RWSTD_ERROR_LOCALE_BAD_NAME