1 // std::moneypunct implementation details, GNU version -*- C++ -*-
3 // Copyright (C) 2001-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
26 // ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
29 // Written by Benjamin Kosnik <bkoz@redhat.com>
32 #include <bits/c++locale_internal.h>
34 namespace std _GLIBCXX_VISIBILITY(default)
36 _GLIBCXX_BEGIN_NAMESPACE_VERSION
38 // Construct and return valid pattern consisting of some combination of:
39 // space none symbol sign value
41 money_base::_S_construct_pattern(char __precedes, char __space,
46 // This insanely complicated routine attempts to construct a valid
47 // pattern for use with monyepunct. A couple of invariants:
49 // if (__precedes) symbol -> value
50 // else value -> symbol
55 // none == never first
56 // space never first or last
58 // Any elegant implementations of this are welcome.
63 // 1 The sign precedes the value and symbol.
64 __ret.field[0] = sign;
67 // Pattern starts with sign.
70 __ret.field[1] = symbol;
71 __ret.field[3] = value;
75 __ret.field[1] = value;
76 __ret.field[3] = symbol;
78 __ret.field[2] = space;
82 // Pattern starts with sign and ends with none.
85 __ret.field[1] = symbol;
86 __ret.field[2] = value;
90 __ret.field[1] = value;
91 __ret.field[2] = symbol;
93 __ret.field[3] = none;
97 // 2 The sign follows the value and symbol.
100 // Pattern either ends with sign.
103 __ret.field[0] = symbol;
104 __ret.field[2] = value;
108 __ret.field[0] = value;
109 __ret.field[2] = symbol;
111 __ret.field[1] = space;
112 __ret.field[3] = sign;
116 // Pattern ends with sign then none.
119 __ret.field[0] = symbol;
120 __ret.field[1] = value;
124 __ret.field[0] = value;
125 __ret.field[1] = symbol;
127 __ret.field[2] = sign;
128 __ret.field[3] = none;
132 // 3 The sign immediately precedes the symbol.
135 __ret.field[0] = sign;
136 __ret.field[1] = symbol;
139 __ret.field[2] = space;
140 __ret.field[3] = value;
144 __ret.field[2] = value;
145 __ret.field[3] = none;
150 __ret.field[0] = value;
153 __ret.field[1] = space;
154 __ret.field[2] = sign;
155 __ret.field[3] = symbol;
159 __ret.field[1] = sign;
160 __ret.field[2] = symbol;
161 __ret.field[3] = none;
166 // 4 The sign immediately follows the symbol.
169 __ret.field[0] = symbol;
170 __ret.field[1] = sign;
173 __ret.field[2] = space;
174 __ret.field[3] = value;
178 __ret.field[2] = value;
179 __ret.field[3] = none;
184 __ret.field[0] = value;
187 __ret.field[1] = space;
188 __ret.field[2] = symbol;
189 __ret.field[3] = sign;
193 __ret.field[1] = symbol;
194 __ret.field[2] = sign;
195 __ret.field[3] = none;
207 moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
211 _M_data = new __moneypunct_cache<char, true>;
216 _M_data->_M_decimal_point = '.';
217 _M_data->_M_thousands_sep = ',';
218 _M_data->_M_grouping = "";
219 _M_data->_M_grouping_size = 0;
220 _M_data->_M_use_grouping = false;
221 _M_data->_M_curr_symbol = "";
222 _M_data->_M_curr_symbol_size = 0;
223 _M_data->_M_positive_sign = "";
224 _M_data->_M_positive_sign_size = 0;
225 _M_data->_M_negative_sign = "";
226 _M_data->_M_negative_sign_size = 0;
227 _M_data->_M_frac_digits = 0;
228 _M_data->_M_pos_format = money_base::_S_default_pattern;
229 _M_data->_M_neg_format = money_base::_S_default_pattern;
231 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
232 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
237 _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
239 _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
242 // Check for NULL, which implies no fractional digits.
243 if (_M_data->_M_decimal_point == '\0')
245 // Like in "C" locale.
246 _M_data->_M_frac_digits = 0;
247 _M_data->_M_decimal_point = '.';
250 _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
253 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
254 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
255 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
257 const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
262 const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
267 // Check for NULL, which implies no grouping.
268 if (_M_data->_M_thousands_sep == '\0')
270 // Like in "C" locale.
271 _M_data->_M_grouping = "";
272 _M_data->_M_grouping_size = 0;
273 _M_data->_M_use_grouping = false;
274 _M_data->_M_thousands_sep = ',';
278 __len = strlen(__cgroup);
281 __group = new char[__len + 1];
282 memcpy(__group, __cgroup, __len + 1);
283 _M_data->_M_grouping = __group;
287 _M_data->_M_grouping = "";
288 _M_data->_M_use_grouping = false;
290 _M_data->_M_grouping_size = __len;
293 __len = strlen(__cpossign);
296 __ps = new char[__len + 1];
297 memcpy(__ps, __cpossign, __len + 1);
298 _M_data->_M_positive_sign = __ps;
301 _M_data->_M_positive_sign = "";
302 _M_data->_M_positive_sign_size = __len;
306 _M_data->_M_negative_sign = "()";
307 _M_data->_M_negative_sign_size = 2;
311 __len = strlen(__cnegsign);
314 __ns = new char[__len + 1];
315 memcpy(__ns, __cnegsign, __len + 1);
316 _M_data->_M_negative_sign = __ns;
319 _M_data->_M_negative_sign = "";
320 _M_data->_M_negative_sign_size = __len;
323 __len = strlen(__ccurr);
326 char* __curr = new char[__len + 1];
327 memcpy(__curr, __ccurr, __len + 1);
328 _M_data->_M_curr_symbol = __curr;
331 _M_data->_M_curr_symbol = "";
332 _M_data->_M_curr_symbol_size = __len;
341 __throw_exception_again;
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;
492 __throw_exception_again;
495 char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
496 char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
497 char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
498 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
500 char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
501 char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
502 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
508 moneypunct<char, true>::~moneypunct()
510 if (_M_data->_M_grouping_size)
511 delete [] _M_data->_M_grouping;
512 if (_M_data->_M_positive_sign_size)
513 delete [] _M_data->_M_positive_sign;
514 if (_M_data->_M_negative_sign_size
515 && strcmp(_M_data->_M_negative_sign, "()") != 0)
516 delete [] _M_data->_M_negative_sign;
517 if (_M_data->_M_curr_symbol_size)
518 delete [] _M_data->_M_curr_symbol;
523 moneypunct<char, false>::~moneypunct()
525 if (_M_data->_M_grouping_size)
526 delete [] _M_data->_M_grouping;
527 if (_M_data->_M_positive_sign_size)
528 delete [] _M_data->_M_positive_sign;
529 if (_M_data->_M_negative_sign_size
530 && strcmp(_M_data->_M_negative_sign, "()") != 0)
531 delete [] _M_data->_M_negative_sign;
532 if (_M_data->_M_curr_symbol_size)
533 delete [] _M_data->_M_curr_symbol;
537 #ifdef _GLIBCXX_USE_WCHAR_T
540 moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
541 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
548 _M_data = new __moneypunct_cache<wchar_t, true>;
553 _M_data->_M_decimal_point = L'.';
554 _M_data->_M_thousands_sep = L',';
555 _M_data->_M_grouping = "";
556 _M_data->_M_grouping_size = 0;
557 _M_data->_M_use_grouping = false;
558 _M_data->_M_curr_symbol = L"";
559 _M_data->_M_curr_symbol_size = 0;
560 _M_data->_M_positive_sign = L"";
561 _M_data->_M_positive_sign_size = 0;
562 _M_data->_M_negative_sign = L"";
563 _M_data->_M_negative_sign_size = 0;
564 _M_data->_M_frac_digits = 0;
565 _M_data->_M_pos_format = money_base::_S_default_pattern;
566 _M_data->_M_neg_format = money_base::_S_default_pattern;
568 // Use ctype::widen code without the facet...
569 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
570 _M_data->_M_atoms[__i] =
571 static_cast<wchar_t>(money_base::_S_atoms[__i]);
576 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
577 __c_locale __old = __uselocale(__cloc);
579 // Switch to named locale so that mbsrtowcs will work.
580 char* __old = setlocale(LC_ALL, 0);
581 const size_t __llen = strlen(__old) + 1;
582 char* __sav = new char[__llen];
583 memcpy(__sav, __old, __llen);
584 setlocale(LC_ALL, __name);
587 union { char *__s; wchar_t __w; } __u;
588 __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
589 _M_data->_M_decimal_point = __u.__w;
591 __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
592 _M_data->_M_thousands_sep = __u.__w;
594 // Check for NULL, which implies no fractional digits.
595 if (_M_data->_M_decimal_point == L'\0')
597 // Like in "C" locale.
598 _M_data->_M_frac_digits = 0;
599 _M_data->_M_decimal_point = L'.';
602 _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
605 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
606 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
607 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
608 const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
611 wchar_t* __wcs_ps = 0;
612 wchar_t* __wcs_ns = 0;
613 const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
618 // Check for NULL, which implies no grouping.
619 if (_M_data->_M_thousands_sep == L'\0')
621 // Like in "C" locale.
622 _M_data->_M_grouping = "";
623 _M_data->_M_grouping_size = 0;
624 _M_data->_M_use_grouping = false;
625 _M_data->_M_thousands_sep = L',';
629 __len = strlen(__cgroup);
632 __group = new char[__len + 1];
633 memcpy(__group, __cgroup, __len + 1);
634 _M_data->_M_grouping = __group;
638 _M_data->_M_grouping = "";
639 _M_data->_M_use_grouping = false;
641 _M_data->_M_grouping_size = __len;
645 __len = strlen(__cpossign);
648 memset(&__state, 0, sizeof(mbstate_t));
649 __wcs_ps = new wchar_t[__len + 1];
650 mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state);
651 _M_data->_M_positive_sign = __wcs_ps;
654 _M_data->_M_positive_sign = L"";
655 _M_data->_M_positive_sign_size =
656 wcslen(_M_data->_M_positive_sign);
658 __len = strlen(__cnegsign);
660 _M_data->_M_negative_sign = L"()";
663 memset(&__state, 0, sizeof(mbstate_t));
664 __wcs_ns = new wchar_t[__len + 1];
665 mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state);
666 _M_data->_M_negative_sign = __wcs_ns;
669 _M_data->_M_negative_sign = L"";
670 _M_data->_M_negative_sign_size =
671 wcslen(_M_data->_M_negative_sign);
674 __len = strlen(__ccurr);
677 memset(&__state, 0, sizeof(mbstate_t));
678 wchar_t* __wcs = new wchar_t[__len + 1];
679 mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state);
680 _M_data->_M_curr_symbol = __wcs;
683 _M_data->_M_curr_symbol = L"";
684 _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
693 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
696 setlocale(LC_ALL, __sav);
699 __throw_exception_again;
702 char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
703 char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
704 char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
705 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
707 char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
708 char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
709 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
712 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
715 setlocale(LC_ALL, __sav);
723 moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
724 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
731 _M_data = new __moneypunct_cache<wchar_t, false>;
736 _M_data->_M_decimal_point = L'.';
737 _M_data->_M_thousands_sep = L',';
738 _M_data->_M_grouping = "";
739 _M_data->_M_grouping_size = 0;
740 _M_data->_M_use_grouping = false;
741 _M_data->_M_curr_symbol = L"";
742 _M_data->_M_curr_symbol_size = 0;
743 _M_data->_M_positive_sign = L"";
744 _M_data->_M_positive_sign_size = 0;
745 _M_data->_M_negative_sign = L"";
746 _M_data->_M_negative_sign_size = 0;
747 _M_data->_M_frac_digits = 0;
748 _M_data->_M_pos_format = money_base::_S_default_pattern;
749 _M_data->_M_neg_format = money_base::_S_default_pattern;
751 // Use ctype::widen code without the facet...
752 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
753 _M_data->_M_atoms[__i] =
754 static_cast<wchar_t>(money_base::_S_atoms[__i]);
759 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
760 __c_locale __old = __uselocale(__cloc);
762 // Switch to named locale so that mbsrtowcs will work.
763 char* __old = setlocale(LC_ALL, 0);
764 const size_t __llen = strlen(__old) + 1;
765 char* __sav = new char[__llen];
766 memcpy(__sav, __old, __llen);
767 setlocale(LC_ALL, __name);
770 union { char *__s; wchar_t __w; } __u;
771 __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
772 _M_data->_M_decimal_point = __u.__w;
774 __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
775 _M_data->_M_thousands_sep = __u.__w;
777 // Check for NULL, which implies no fractional digits.
778 if (_M_data->_M_decimal_point == L'\0')
780 // Like in "C" locale.
781 _M_data->_M_frac_digits = 0;
782 _M_data->_M_decimal_point = L'.';
785 _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
788 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
789 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
790 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
791 const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
794 wchar_t* __wcs_ps = 0;
795 wchar_t* __wcs_ns = 0;
796 const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
801 // Check for NULL, which implies no grouping.
802 if (_M_data->_M_thousands_sep == L'\0')
804 // Like in "C" locale.
805 _M_data->_M_grouping = "";
806 _M_data->_M_grouping_size = 0;
807 _M_data->_M_use_grouping = false;
808 _M_data->_M_thousands_sep = L',';
812 __len = strlen(__cgroup);
815 __group = new char[__len + 1];
816 memcpy(__group, __cgroup, __len + 1);
817 _M_data->_M_grouping = __group;
821 _M_data->_M_grouping = "";
822 _M_data->_M_use_grouping = false;
824 _M_data->_M_grouping_size = __len;
828 __len = strlen(__cpossign);
831 memset(&__state, 0, sizeof(mbstate_t));
832 __wcs_ps = new wchar_t[__len + 1];
833 mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state);
834 _M_data->_M_positive_sign = __wcs_ps;
837 _M_data->_M_positive_sign = L"";
838 _M_data->_M_positive_sign_size =
839 wcslen(_M_data->_M_positive_sign);
841 __len = strlen(__cnegsign);
843 _M_data->_M_negative_sign = L"()";
846 memset(&__state, 0, sizeof(mbstate_t));
847 __wcs_ns = new wchar_t[__len + 1];
848 mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state);
849 _M_data->_M_negative_sign = __wcs_ns;
852 _M_data->_M_negative_sign = L"";
853 _M_data->_M_negative_sign_size =
854 wcslen(_M_data->_M_negative_sign);
857 __len = strlen(__ccurr);
860 memset(&__state, 0, sizeof(mbstate_t));
861 wchar_t* __wcs = new wchar_t[__len + 1];
862 mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state);
863 _M_data->_M_curr_symbol = __wcs;
866 _M_data->_M_curr_symbol = L"";
867 _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
876 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
879 setlocale(LC_ALL, __sav);
882 __throw_exception_again;
885 char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
886 char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
887 char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
888 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
890 char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
891 char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
892 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
895 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
898 setlocale(LC_ALL, __sav);
905 moneypunct<wchar_t, true>::~moneypunct()
907 if (_M_data->_M_grouping_size)
908 delete [] _M_data->_M_grouping;
909 if (_M_data->_M_positive_sign_size)
910 delete [] _M_data->_M_positive_sign;
911 if (_M_data->_M_negative_sign_size
912 && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
913 delete [] _M_data->_M_negative_sign;
914 if (_M_data->_M_curr_symbol_size)
915 delete [] _M_data->_M_curr_symbol;
920 moneypunct<wchar_t, false>::~moneypunct()
922 if (_M_data->_M_grouping_size)
923 delete [] _M_data->_M_grouping;
924 if (_M_data->_M_positive_sign_size)
925 delete [] _M_data->_M_positive_sign;
926 if (_M_data->_M_negative_sign_size
927 && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
928 delete [] _M_data->_M_negative_sign;
929 if (_M_data->_M_curr_symbol_size)
930 delete [] _M_data->_M_curr_symbol;
935 _GLIBCXX_END_NAMESPACE_VERSION