1 // std::moneypunct implementation details, GNU version -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
27 // ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
30 // Written by Benjamin Kosnik <bkoz@redhat.com>
33 #include <bits/c++locale_internal.h>
35 namespace std _GLIBCXX_VISIBILITY(default)
37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
39 // Construct and return valid pattern consisting of some combination of:
40 // space none symbol sign value
42 money_base::_S_construct_pattern(char __precedes, char __space,
47 // This insanely complicated routine attempts to construct a valid
48 // pattern for use with monyepunct. A couple of invariants:
50 // if (__precedes) symbol -> value
51 // else value -> symbol
56 // none == never first
57 // space never first or last
59 // Any elegant implementations of this are welcome.
64 // 1 The sign precedes the value and symbol.
65 __ret.field[0] = sign;
68 // Pattern starts with sign.
71 __ret.field[1] = symbol;
72 __ret.field[3] = value;
76 __ret.field[1] = value;
77 __ret.field[3] = symbol;
79 __ret.field[2] = space;
83 // Pattern starts with sign and ends with none.
86 __ret.field[1] = symbol;
87 __ret.field[2] = value;
91 __ret.field[1] = value;
92 __ret.field[2] = symbol;
94 __ret.field[3] = none;
98 // 2 The sign follows the value and symbol.
101 // Pattern either ends with sign.
104 __ret.field[0] = symbol;
105 __ret.field[2] = value;
109 __ret.field[0] = value;
110 __ret.field[2] = symbol;
112 __ret.field[1] = space;
113 __ret.field[3] = sign;
117 // Pattern ends with sign then none.
120 __ret.field[0] = symbol;
121 __ret.field[1] = value;
125 __ret.field[0] = value;
126 __ret.field[1] = symbol;
128 __ret.field[2] = sign;
129 __ret.field[3] = none;
133 // 3 The sign immediately precedes the symbol.
136 __ret.field[0] = sign;
137 __ret.field[1] = symbol;
140 __ret.field[2] = space;
141 __ret.field[3] = value;
145 __ret.field[2] = value;
146 __ret.field[3] = none;
151 __ret.field[0] = value;
154 __ret.field[1] = space;
155 __ret.field[2] = sign;
156 __ret.field[3] = symbol;
160 __ret.field[1] = sign;
161 __ret.field[2] = symbol;
162 __ret.field[3] = none;
167 // 4 The sign immediately follows the symbol.
170 __ret.field[0] = symbol;
171 __ret.field[1] = sign;
174 __ret.field[2] = space;
175 __ret.field[3] = value;
179 __ret.field[2] = value;
180 __ret.field[3] = none;
185 __ret.field[0] = value;
188 __ret.field[1] = space;
189 __ret.field[2] = symbol;
190 __ret.field[3] = sign;
194 __ret.field[1] = symbol;
195 __ret.field[2] = sign;
196 __ret.field[3] = none;
208 moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
212 _M_data = new __moneypunct_cache<char, true>;
217 _M_data->_M_decimal_point = '.';
218 _M_data->_M_thousands_sep = ',';
219 _M_data->_M_grouping = "";
220 _M_data->_M_grouping_size = 0;
221 _M_data->_M_use_grouping = false;
222 _M_data->_M_curr_symbol = "";
223 _M_data->_M_curr_symbol_size = 0;
224 _M_data->_M_positive_sign = "";
225 _M_data->_M_positive_sign_size = 0;
226 _M_data->_M_negative_sign = "";
227 _M_data->_M_negative_sign_size = 0;
228 _M_data->_M_frac_digits = 0;
229 _M_data->_M_pos_format = money_base::_S_default_pattern;
230 _M_data->_M_neg_format = money_base::_S_default_pattern;
232 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
233 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
238 _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
240 _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
243 // Check for NULL, which implies no fractional digits.
244 if (_M_data->_M_decimal_point == '\0')
246 // Like in "C" locale.
247 _M_data->_M_frac_digits = 0;
248 _M_data->_M_decimal_point = '.';
251 _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
254 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
255 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
256 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
258 const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
263 const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
268 // Check for NULL, which implies no grouping.
269 if (_M_data->_M_thousands_sep == '\0')
271 // Like in "C" locale.
272 _M_data->_M_grouping = "";
273 _M_data->_M_grouping_size = 0;
274 _M_data->_M_use_grouping = false;
275 _M_data->_M_thousands_sep = ',';
279 __len = strlen(__cgroup);
282 __group = new char[__len + 1];
283 memcpy(__group, __cgroup, __len + 1);
284 _M_data->_M_grouping = __group;
288 _M_data->_M_grouping = "";
289 _M_data->_M_use_grouping = false;
291 _M_data->_M_grouping_size = __len;
294 __len = strlen(__cpossign);
297 __ps = new char[__len + 1];
298 memcpy(__ps, __cpossign, __len + 1);
299 _M_data->_M_positive_sign = __ps;
302 _M_data->_M_positive_sign = "";
303 _M_data->_M_positive_sign_size = __len;
307 _M_data->_M_negative_sign = "()";
308 _M_data->_M_negative_sign_size = 2;
312 __len = strlen(__cnegsign);
315 __ns = new char[__len + 1];
316 memcpy(__ns, __cnegsign, __len + 1);
317 _M_data->_M_negative_sign = __ns;
320 _M_data->_M_negative_sign = "";
321 _M_data->_M_negative_sign_size = __len;
324 __len = strlen(__ccurr);
327 char* __curr = new char[__len + 1];
328 memcpy(__curr, __ccurr, __len + 1);
329 _M_data->_M_curr_symbol = __curr;
332 _M_data->_M_curr_symbol = "";
333 _M_data->_M_curr_symbol_size = __len;
344 char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
345 char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
346 char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
347 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
349 char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
350 char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
351 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
358 moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
362 _M_data = new __moneypunct_cache<char, false>;
367 _M_data->_M_decimal_point = '.';
368 _M_data->_M_thousands_sep = ',';
369 _M_data->_M_grouping = "";
370 _M_data->_M_grouping_size = 0;
371 _M_data->_M_use_grouping = false;
372 _M_data->_M_curr_symbol = "";
373 _M_data->_M_curr_symbol_size = 0;
374 _M_data->_M_positive_sign = "";
375 _M_data->_M_positive_sign_size = 0;
376 _M_data->_M_negative_sign = "";
377 _M_data->_M_negative_sign_size = 0;
378 _M_data->_M_frac_digits = 0;
379 _M_data->_M_pos_format = money_base::_S_default_pattern;
380 _M_data->_M_neg_format = money_base::_S_default_pattern;
382 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
383 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
388 _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
390 _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
393 // Check for NULL, which implies no fractional digits.
394 if (_M_data->_M_decimal_point == '\0')
396 // Like in "C" locale.
397 _M_data->_M_frac_digits = 0;
398 _M_data->_M_decimal_point = '.';
401 _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
404 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
405 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
406 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
408 const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
413 const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
418 // Check for NULL, which implies no grouping.
419 if (_M_data->_M_thousands_sep == '\0')
421 // Like in "C" locale.
422 _M_data->_M_grouping = "";
423 _M_data->_M_grouping_size = 0;
424 _M_data->_M_use_grouping = false;
425 _M_data->_M_thousands_sep = ',';
429 __len = strlen(__cgroup);
432 __group = new char[__len + 1];
433 memcpy(__group, __cgroup, __len + 1);
434 _M_data->_M_grouping = __group;
438 _M_data->_M_grouping = "";
439 _M_data->_M_use_grouping = false;
441 _M_data->_M_grouping_size = __len;
444 __len = strlen(__cpossign);
447 __ps = new char[__len + 1];
448 memcpy(__ps, __cpossign, __len + 1);
449 _M_data->_M_positive_sign = __ps;
452 _M_data->_M_positive_sign = "";
453 _M_data->_M_positive_sign_size = __len;
457 _M_data->_M_negative_sign = "()";
458 _M_data->_M_negative_sign_size = 2;
462 __len = strlen(__cnegsign);
465 __ns = new char[__len + 1];
466 memcpy(__ns, __cnegsign, __len + 1);
467 _M_data->_M_negative_sign = __ns;
470 _M_data->_M_negative_sign = "";
471 _M_data->_M_negative_sign_size = __len;
474 __len = strlen(__ccurr);
477 char* __curr = new char[__len + 1];
478 memcpy(__curr, __ccurr, __len + 1);
479 _M_data->_M_curr_symbol = __curr;
482 _M_data->_M_curr_symbol = "";
483 _M_data->_M_curr_symbol_size = __len;
494 char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
495 char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
496 char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
497 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
499 char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
500 char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
501 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
507 moneypunct<char, true>::~moneypunct()
509 if (_M_data->_M_grouping_size)
510 delete [] _M_data->_M_grouping;
511 if (_M_data->_M_positive_sign_size)
512 delete [] _M_data->_M_positive_sign;
513 if (_M_data->_M_negative_sign_size
514 && strcmp(_M_data->_M_negative_sign, "()") != 0)
515 delete [] _M_data->_M_negative_sign;
516 if (_M_data->_M_curr_symbol_size)
517 delete [] _M_data->_M_curr_symbol;
522 moneypunct<char, false>::~moneypunct()
524 if (_M_data->_M_grouping_size)
525 delete [] _M_data->_M_grouping;
526 if (_M_data->_M_positive_sign_size)
527 delete [] _M_data->_M_positive_sign;
528 if (_M_data->_M_negative_sign_size
529 && strcmp(_M_data->_M_negative_sign, "()") != 0)
530 delete [] _M_data->_M_negative_sign;
531 if (_M_data->_M_curr_symbol_size)
532 delete [] _M_data->_M_curr_symbol;
536 #ifdef _GLIBCXX_USE_WCHAR_T
539 moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
540 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
547 _M_data = new __moneypunct_cache<wchar_t, true>;
552 _M_data->_M_decimal_point = L'.';
553 _M_data->_M_thousands_sep = L',';
554 _M_data->_M_grouping = "";
555 _M_data->_M_grouping_size = 0;
556 _M_data->_M_use_grouping = false;
557 _M_data->_M_curr_symbol = L"";
558 _M_data->_M_curr_symbol_size = 0;
559 _M_data->_M_positive_sign = L"";
560 _M_data->_M_positive_sign_size = 0;
561 _M_data->_M_negative_sign = L"";
562 _M_data->_M_negative_sign_size = 0;
563 _M_data->_M_frac_digits = 0;
564 _M_data->_M_pos_format = money_base::_S_default_pattern;
565 _M_data->_M_neg_format = money_base::_S_default_pattern;
567 // Use ctype::widen code without the facet...
568 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
569 _M_data->_M_atoms[__i] =
570 static_cast<wchar_t>(money_base::_S_atoms[__i]);
575 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
576 __c_locale __old = __uselocale(__cloc);
578 // Switch to named locale so that mbsrtowcs will work.
579 char* __old = setlocale(LC_ALL, 0);
580 const size_t __llen = strlen(__old) + 1;
581 char* __sav = new char[__llen];
582 memcpy(__sav, __old, __llen);
583 setlocale(LC_ALL, __name);
586 union { char *__s; wchar_t __w; } __u;
587 __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
588 _M_data->_M_decimal_point = __u.__w;
590 __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
591 _M_data->_M_thousands_sep = __u.__w;
593 // Check for NULL, which implies no fractional digits.
594 if (_M_data->_M_decimal_point == L'\0')
596 // Like in "C" locale.
597 _M_data->_M_frac_digits = 0;
598 _M_data->_M_decimal_point = L'.';
601 _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
604 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
605 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
606 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
607 const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
610 wchar_t* __wcs_ps = 0;
611 wchar_t* __wcs_ns = 0;
612 const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
617 // Check for NULL, which implies no grouping.
618 if (_M_data->_M_thousands_sep == L'\0')
620 // Like in "C" locale.
621 _M_data->_M_grouping = "";
622 _M_data->_M_grouping_size = 0;
623 _M_data->_M_use_grouping = false;
624 _M_data->_M_thousands_sep = L',';
628 __len = strlen(__cgroup);
631 __group = new char[__len + 1];
632 memcpy(__group, __cgroup, __len + 1);
633 _M_data->_M_grouping = __group;
637 _M_data->_M_grouping = "";
638 _M_data->_M_use_grouping = false;
640 _M_data->_M_grouping_size = __len;
644 __len = strlen(__cpossign);
647 memset(&__state, 0, sizeof(mbstate_t));
648 __wcs_ps = new wchar_t[__len + 1];
649 mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state);
650 _M_data->_M_positive_sign = __wcs_ps;
653 _M_data->_M_positive_sign = L"";
654 _M_data->_M_positive_sign_size =
655 wcslen(_M_data->_M_positive_sign);
657 __len = strlen(__cnegsign);
659 _M_data->_M_negative_sign = L"()";
662 memset(&__state, 0, sizeof(mbstate_t));
663 __wcs_ns = new wchar_t[__len + 1];
664 mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state);
665 _M_data->_M_negative_sign = __wcs_ns;
668 _M_data->_M_negative_sign = L"";
669 _M_data->_M_negative_sign_size =
670 wcslen(_M_data->_M_negative_sign);
673 __len = strlen(__ccurr);
676 memset(&__state, 0, sizeof(mbstate_t));
677 wchar_t* __wcs = new wchar_t[__len + 1];
678 mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state);
679 _M_data->_M_curr_symbol = __wcs;
682 _M_data->_M_curr_symbol = L"";
683 _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
692 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
695 setlocale(LC_ALL, __sav);
698 __throw_exception_again;
701 char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
702 char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
703 char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
704 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
706 char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
707 char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
708 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
711 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
714 setlocale(LC_ALL, __sav);
722 moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
723 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
730 _M_data = new __moneypunct_cache<wchar_t, false>;
735 _M_data->_M_decimal_point = L'.';
736 _M_data->_M_thousands_sep = L',';
737 _M_data->_M_grouping = "";
738 _M_data->_M_grouping_size = 0;
739 _M_data->_M_use_grouping = false;
740 _M_data->_M_curr_symbol = L"";
741 _M_data->_M_curr_symbol_size = 0;
742 _M_data->_M_positive_sign = L"";
743 _M_data->_M_positive_sign_size = 0;
744 _M_data->_M_negative_sign = L"";
745 _M_data->_M_negative_sign_size = 0;
746 _M_data->_M_frac_digits = 0;
747 _M_data->_M_pos_format = money_base::_S_default_pattern;
748 _M_data->_M_neg_format = money_base::_S_default_pattern;
750 // Use ctype::widen code without the facet...
751 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
752 _M_data->_M_atoms[__i] =
753 static_cast<wchar_t>(money_base::_S_atoms[__i]);
758 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
759 __c_locale __old = __uselocale(__cloc);
761 // Switch to named locale so that mbsrtowcs will work.
762 char* __old = setlocale(LC_ALL, 0);
763 const size_t __llen = strlen(__old) + 1;
764 char* __sav = new char[__llen];
765 memcpy(__sav, __old, __llen);
766 setlocale(LC_ALL, __name);
769 union { char *__s; wchar_t __w; } __u;
770 __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
771 _M_data->_M_decimal_point = __u.__w;
773 __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
774 _M_data->_M_thousands_sep = __u.__w;
776 // Check for NULL, which implies no fractional digits.
777 if (_M_data->_M_decimal_point == L'\0')
779 // Like in "C" locale.
780 _M_data->_M_frac_digits = 0;
781 _M_data->_M_decimal_point = L'.';
784 _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
787 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
788 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
789 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
790 const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
793 wchar_t* __wcs_ps = 0;
794 wchar_t* __wcs_ns = 0;
795 const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
800 // Check for NULL, which implies no grouping.
801 if (_M_data->_M_thousands_sep == L'\0')
803 // Like in "C" locale.
804 _M_data->_M_grouping = "";
805 _M_data->_M_grouping_size = 0;
806 _M_data->_M_use_grouping = false;
807 _M_data->_M_thousands_sep = L',';
811 __len = strlen(__cgroup);
814 __group = new char[__len + 1];
815 memcpy(__group, __cgroup, __len + 1);
816 _M_data->_M_grouping = __group;
820 _M_data->_M_grouping = "";
821 _M_data->_M_use_grouping = false;
823 _M_data->_M_grouping_size = __len;
827 __len = strlen(__cpossign);
830 memset(&__state, 0, sizeof(mbstate_t));
831 __wcs_ps = new wchar_t[__len + 1];
832 mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state);
833 _M_data->_M_positive_sign = __wcs_ps;
836 _M_data->_M_positive_sign = L"";
837 _M_data->_M_positive_sign_size =
838 wcslen(_M_data->_M_positive_sign);
840 __len = strlen(__cnegsign);
842 _M_data->_M_negative_sign = L"()";
845 memset(&__state, 0, sizeof(mbstate_t));
846 __wcs_ns = new wchar_t[__len + 1];
847 mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state);
848 _M_data->_M_negative_sign = __wcs_ns;
851 _M_data->_M_negative_sign = L"";
852 _M_data->_M_negative_sign_size =
853 wcslen(_M_data->_M_negative_sign);
856 __len = strlen(__ccurr);
859 memset(&__state, 0, sizeof(mbstate_t));
860 wchar_t* __wcs = new wchar_t[__len + 1];
861 mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state);
862 _M_data->_M_curr_symbol = __wcs;
865 _M_data->_M_curr_symbol = L"";
866 _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
875 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
878 setlocale(LC_ALL, __sav);
881 __throw_exception_again;
884 char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
885 char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
886 char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
887 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
889 char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
890 char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
891 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
894 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
897 setlocale(LC_ALL, __sav);
904 moneypunct<wchar_t, true>::~moneypunct()
906 if (_M_data->_M_grouping_size)
907 delete [] _M_data->_M_grouping;
908 if (_M_data->_M_positive_sign_size)
909 delete [] _M_data->_M_positive_sign;
910 if (_M_data->_M_negative_sign_size
911 && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
912 delete [] _M_data->_M_negative_sign;
913 if (_M_data->_M_curr_symbol_size)
914 delete [] _M_data->_M_curr_symbol;
919 moneypunct<wchar_t, false>::~moneypunct()
921 if (_M_data->_M_grouping_size)
922 delete [] _M_data->_M_grouping;
923 if (_M_data->_M_positive_sign_size)
924 delete [] _M_data->_M_positive_sign;
925 if (_M_data->_M_negative_sign_size
926 && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
927 delete [] _M_data->_M_negative_sign;
928 if (_M_data->_M_curr_symbol_size)
929 delete [] _M_data->_M_curr_symbol;
934 _GLIBCXX_END_NAMESPACE_VERSION