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 _GLIBCXX_BEGIN_NAMESPACE(std)
37 // Construct and return valid pattern consisting of some combination of:
38 // space none symbol sign value
40 money_base::_S_construct_pattern(char __precedes, char __space,
45 // This insanely complicated routine attempts to construct a valid
46 // pattern for use with monyepunct. A couple of invariants:
48 // if (__precedes) symbol -> value
49 // else value -> symbol
54 // none == never first
55 // space never first or last
57 // Any elegant implementations of this are welcome.
62 // 1 The sign precedes the value and symbol.
63 __ret.field[0] = sign;
66 // Pattern starts with sign.
69 __ret.field[1] = symbol;
70 __ret.field[3] = value;
74 __ret.field[1] = value;
75 __ret.field[3] = symbol;
77 __ret.field[2] = space;
81 // Pattern starts with sign and ends with none.
84 __ret.field[1] = symbol;
85 __ret.field[2] = value;
89 __ret.field[1] = value;
90 __ret.field[2] = symbol;
92 __ret.field[3] = none;
96 // 2 The sign follows the value and symbol.
99 // Pattern either ends with sign.
102 __ret.field[0] = symbol;
103 __ret.field[2] = value;
107 __ret.field[0] = value;
108 __ret.field[2] = symbol;
110 __ret.field[1] = space;
111 __ret.field[3] = sign;
115 // Pattern ends with sign then none.
118 __ret.field[0] = symbol;
119 __ret.field[1] = value;
123 __ret.field[0] = value;
124 __ret.field[1] = symbol;
126 __ret.field[2] = sign;
127 __ret.field[3] = none;
131 // 3 The sign immediately precedes the symbol.
134 __ret.field[0] = sign;
135 __ret.field[1] = symbol;
138 __ret.field[2] = space;
139 __ret.field[3] = value;
143 __ret.field[2] = value;
144 __ret.field[3] = none;
149 __ret.field[0] = value;
152 __ret.field[1] = space;
153 __ret.field[2] = sign;
154 __ret.field[3] = symbol;
158 __ret.field[1] = sign;
159 __ret.field[2] = symbol;
160 __ret.field[3] = none;
165 // 4 The sign immediately follows the symbol.
168 __ret.field[0] = symbol;
169 __ret.field[1] = sign;
172 __ret.field[2] = space;
173 __ret.field[3] = value;
177 __ret.field[2] = value;
178 __ret.field[3] = none;
183 __ret.field[0] = value;
186 __ret.field[1] = space;
187 __ret.field[2] = symbol;
188 __ret.field[3] = sign;
192 __ret.field[1] = symbol;
193 __ret.field[2] = sign;
194 __ret.field[3] = none;
206 moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
210 _M_data = new __moneypunct_cache<char, true>;
215 _M_data->_M_decimal_point = '.';
216 _M_data->_M_thousands_sep = ',';
217 _M_data->_M_grouping = "";
218 _M_data->_M_grouping_size = 0;
219 _M_data->_M_use_grouping = false;
220 _M_data->_M_curr_symbol = "";
221 _M_data->_M_curr_symbol_size = 0;
222 _M_data->_M_positive_sign = "";
223 _M_data->_M_positive_sign_size = 0;
224 _M_data->_M_negative_sign = "";
225 _M_data->_M_negative_sign_size = 0;
226 _M_data->_M_frac_digits = 0;
227 _M_data->_M_pos_format = money_base::_S_default_pattern;
228 _M_data->_M_neg_format = money_base::_S_default_pattern;
230 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
231 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
236 _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
238 _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
241 // Check for NULL, which implies no fractional digits.
242 if (_M_data->_M_decimal_point == '\0')
244 // Like in "C" locale.
245 _M_data->_M_frac_digits = 0;
246 _M_data->_M_decimal_point = '.';
249 _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
252 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
253 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
254 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
256 const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
261 const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
266 // Check for NULL, which implies no grouping.
267 if (_M_data->_M_thousands_sep == '\0')
269 // Like in "C" locale.
270 _M_data->_M_grouping = "";
271 _M_data->_M_grouping_size = 0;
272 _M_data->_M_use_grouping = false;
273 _M_data->_M_thousands_sep = ',';
277 __len = strlen(__cgroup);
280 __group = new char[__len + 1];
281 memcpy(__group, __cgroup, __len + 1);
282 _M_data->_M_grouping = __group;
286 _M_data->_M_grouping = "";
287 _M_data->_M_use_grouping = false;
289 _M_data->_M_grouping_size = __len;
292 __len = strlen(__cpossign);
295 __ps = new char[__len + 1];
296 memcpy(__ps, __cpossign, __len + 1);
297 _M_data->_M_positive_sign = __ps;
300 _M_data->_M_positive_sign = "";
301 _M_data->_M_positive_sign_size = __len;
305 _M_data->_M_negative_sign = "()";
306 _M_data->_M_negative_sign_size = 2;
310 __len = strlen(__cnegsign);
313 __ns = new char[__len + 1];
314 memcpy(__ns, __cnegsign, __len + 1);
315 _M_data->_M_negative_sign = __ns;
318 _M_data->_M_negative_sign = "";
319 _M_data->_M_negative_sign_size = __len;
322 __len = strlen(__ccurr);
325 char* __curr = new char[__len + 1];
326 memcpy(__curr, __ccurr, __len + 1);
327 _M_data->_M_curr_symbol = __curr;
330 _M_data->_M_curr_symbol = "";
331 _M_data->_M_curr_symbol_size = __len;
342 char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
343 char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
344 char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
345 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
347 char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
348 char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
349 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
356 moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
360 _M_data = new __moneypunct_cache<char, false>;
365 _M_data->_M_decimal_point = '.';
366 _M_data->_M_thousands_sep = ',';
367 _M_data->_M_grouping = "";
368 _M_data->_M_grouping_size = 0;
369 _M_data->_M_use_grouping = false;
370 _M_data->_M_curr_symbol = "";
371 _M_data->_M_curr_symbol_size = 0;
372 _M_data->_M_positive_sign = "";
373 _M_data->_M_positive_sign_size = 0;
374 _M_data->_M_negative_sign = "";
375 _M_data->_M_negative_sign_size = 0;
376 _M_data->_M_frac_digits = 0;
377 _M_data->_M_pos_format = money_base::_S_default_pattern;
378 _M_data->_M_neg_format = money_base::_S_default_pattern;
380 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
381 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
386 _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
388 _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
391 // Check for NULL, which implies no fractional digits.
392 if (_M_data->_M_decimal_point == '\0')
394 // Like in "C" locale.
395 _M_data->_M_frac_digits = 0;
396 _M_data->_M_decimal_point = '.';
399 _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
402 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
403 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
404 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
406 const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
411 const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
416 // Check for NULL, which implies no grouping.
417 if (_M_data->_M_thousands_sep == '\0')
419 // Like in "C" locale.
420 _M_data->_M_grouping = "";
421 _M_data->_M_grouping_size = 0;
422 _M_data->_M_use_grouping = false;
423 _M_data->_M_thousands_sep = ',';
427 __len = strlen(__cgroup);
430 __group = new char[__len + 1];
431 memcpy(__group, __cgroup, __len + 1);
432 _M_data->_M_grouping = __group;
436 _M_data->_M_grouping = "";
437 _M_data->_M_use_grouping = false;
439 _M_data->_M_grouping_size = __len;
442 __len = strlen(__cpossign);
445 __ps = new char[__len + 1];
446 memcpy(__ps, __cpossign, __len + 1);
447 _M_data->_M_positive_sign = __ps;
450 _M_data->_M_positive_sign = "";
451 _M_data->_M_positive_sign_size = __len;
455 _M_data->_M_negative_sign = "()";
456 _M_data->_M_negative_sign_size = 2;
460 __len = strlen(__cnegsign);
463 __ns = new char[__len + 1];
464 memcpy(__ns, __cnegsign, __len + 1);
465 _M_data->_M_negative_sign = __ns;
468 _M_data->_M_negative_sign = "";
469 _M_data->_M_negative_sign_size = __len;
472 __len = strlen(__ccurr);
475 char* __curr = new char[__len + 1];
476 memcpy(__curr, __ccurr, __len + 1);
477 _M_data->_M_curr_symbol = __curr;
480 _M_data->_M_curr_symbol = "";
481 _M_data->_M_curr_symbol_size = __len;
492 char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
493 char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
494 char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
495 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
497 char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
498 char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
499 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
505 moneypunct<char, true>::~moneypunct()
507 if (_M_data->_M_grouping_size)
508 delete [] _M_data->_M_grouping;
509 if (_M_data->_M_positive_sign_size)
510 delete [] _M_data->_M_positive_sign;
511 if (_M_data->_M_negative_sign_size
512 && strcmp(_M_data->_M_negative_sign, "()") != 0)
513 delete [] _M_data->_M_negative_sign;
514 if (_M_data->_M_curr_symbol_size)
515 delete [] _M_data->_M_curr_symbol;
520 moneypunct<char, false>::~moneypunct()
522 if (_M_data->_M_grouping_size)
523 delete [] _M_data->_M_grouping;
524 if (_M_data->_M_positive_sign_size)
525 delete [] _M_data->_M_positive_sign;
526 if (_M_data->_M_negative_sign_size
527 && strcmp(_M_data->_M_negative_sign, "()") != 0)
528 delete [] _M_data->_M_negative_sign;
529 if (_M_data->_M_curr_symbol_size)
530 delete [] _M_data->_M_curr_symbol;
534 #ifdef _GLIBCXX_USE_WCHAR_T
537 moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
538 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
545 _M_data = new __moneypunct_cache<wchar_t, true>;
550 _M_data->_M_decimal_point = L'.';
551 _M_data->_M_thousands_sep = L',';
552 _M_data->_M_grouping = "";
553 _M_data->_M_grouping_size = 0;
554 _M_data->_M_use_grouping = false;
555 _M_data->_M_curr_symbol = L"";
556 _M_data->_M_curr_symbol_size = 0;
557 _M_data->_M_positive_sign = L"";
558 _M_data->_M_positive_sign_size = 0;
559 _M_data->_M_negative_sign = L"";
560 _M_data->_M_negative_sign_size = 0;
561 _M_data->_M_frac_digits = 0;
562 _M_data->_M_pos_format = money_base::_S_default_pattern;
563 _M_data->_M_neg_format = money_base::_S_default_pattern;
565 // Use ctype::widen code without the facet...
566 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
567 _M_data->_M_atoms[__i] =
568 static_cast<wchar_t>(money_base::_S_atoms[__i]);
573 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
574 __c_locale __old = __uselocale(__cloc);
576 // Switch to named locale so that mbsrtowcs will work.
577 char* __old = setlocale(LC_ALL, NULL);
578 const size_t __llen = strlen(__old) + 1;
579 char* __sav = new char[__llen];
580 memcpy(__sav, __old, __llen);
581 setlocale(LC_ALL, __name);
584 union { char *__s; wchar_t __w; } __u;
585 __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
586 _M_data->_M_decimal_point = __u.__w;
588 __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
589 _M_data->_M_thousands_sep = __u.__w;
591 // Check for NULL, which implies no fractional digits.
592 if (_M_data->_M_decimal_point == L'\0')
594 // Like in "C" locale.
595 _M_data->_M_frac_digits = 0;
596 _M_data->_M_decimal_point = L'.';
599 _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
602 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
603 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
604 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
605 const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
608 wchar_t* __wcs_ps = 0;
609 wchar_t* __wcs_ns = 0;
610 const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
615 // Check for NULL, which implies no grouping.
616 if (_M_data->_M_thousands_sep == L'\0')
618 // Like in "C" locale.
619 _M_data->_M_grouping = "";
620 _M_data->_M_grouping_size = 0;
621 _M_data->_M_use_grouping = false;
622 _M_data->_M_thousands_sep = L',';
626 __len = strlen(__cgroup);
629 __group = new char[__len + 1];
630 memcpy(__group, __cgroup, __len + 1);
631 _M_data->_M_grouping = __group;
635 _M_data->_M_grouping = "";
636 _M_data->_M_use_grouping = false;
638 _M_data->_M_grouping_size = __len;
642 __len = strlen(__cpossign);
645 memset(&__state, 0, sizeof(mbstate_t));
646 __wcs_ps = new wchar_t[__len + 1];
647 mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state);
648 _M_data->_M_positive_sign = __wcs_ps;
651 _M_data->_M_positive_sign = L"";
652 _M_data->_M_positive_sign_size =
653 wcslen(_M_data->_M_positive_sign);
655 __len = strlen(__cnegsign);
657 _M_data->_M_negative_sign = L"()";
660 memset(&__state, 0, sizeof(mbstate_t));
661 __wcs_ns = new wchar_t[__len + 1];
662 mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state);
663 _M_data->_M_negative_sign = __wcs_ns;
666 _M_data->_M_negative_sign = L"";
667 _M_data->_M_negative_sign_size =
668 wcslen(_M_data->_M_negative_sign);
671 __len = strlen(__ccurr);
674 memset(&__state, 0, sizeof(mbstate_t));
675 wchar_t* __wcs = new wchar_t[__len + 1];
676 mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state);
677 _M_data->_M_curr_symbol = __wcs;
680 _M_data->_M_curr_symbol = L"";
681 _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
690 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
693 setlocale(LC_ALL, __sav);
696 __throw_exception_again;
699 char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
700 char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
701 char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
702 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
704 char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
705 char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
706 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
709 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
712 setlocale(LC_ALL, __sav);
720 moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
721 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
728 _M_data = new __moneypunct_cache<wchar_t, false>;
733 _M_data->_M_decimal_point = L'.';
734 _M_data->_M_thousands_sep = L',';
735 _M_data->_M_grouping = "";
736 _M_data->_M_grouping_size = 0;
737 _M_data->_M_use_grouping = false;
738 _M_data->_M_curr_symbol = L"";
739 _M_data->_M_curr_symbol_size = 0;
740 _M_data->_M_positive_sign = L"";
741 _M_data->_M_positive_sign_size = 0;
742 _M_data->_M_negative_sign = L"";
743 _M_data->_M_negative_sign_size = 0;
744 _M_data->_M_frac_digits = 0;
745 _M_data->_M_pos_format = money_base::_S_default_pattern;
746 _M_data->_M_neg_format = money_base::_S_default_pattern;
748 // Use ctype::widen code without the facet...
749 for (size_t __i = 0; __i < money_base::_S_end; ++__i)
750 _M_data->_M_atoms[__i] =
751 static_cast<wchar_t>(money_base::_S_atoms[__i]);
756 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
757 __c_locale __old = __uselocale(__cloc);
759 // Switch to named locale so that mbsrtowcs will work.
760 char* __old = setlocale(LC_ALL, NULL);
761 const size_t __llen = strlen(__old) + 1;
762 char* __sav = new char[__llen];
763 memcpy(__sav, __old, __llen);
764 setlocale(LC_ALL, __name);
767 union { char *__s; wchar_t __w; } __u;
768 __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
769 _M_data->_M_decimal_point = __u.__w;
771 __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
772 _M_data->_M_thousands_sep = __u.__w;
774 // Check for NULL, which implies no fractional digits.
775 if (_M_data->_M_decimal_point == L'\0')
777 // Like in "C" locale.
778 _M_data->_M_frac_digits = 0;
779 _M_data->_M_decimal_point = L'.';
782 _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
785 const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
786 const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
787 const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
788 const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
791 wchar_t* __wcs_ps = 0;
792 wchar_t* __wcs_ns = 0;
793 const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
798 // Check for NULL, which implies no grouping.
799 if (_M_data->_M_thousands_sep == L'\0')
801 // Like in "C" locale.
802 _M_data->_M_grouping = "";
803 _M_data->_M_grouping_size = 0;
804 _M_data->_M_use_grouping = false;
805 _M_data->_M_thousands_sep = L',';
809 __len = strlen(__cgroup);
812 __group = new char[__len + 1];
813 memcpy(__group, __cgroup, __len + 1);
814 _M_data->_M_grouping = __group;
818 _M_data->_M_grouping = "";
819 _M_data->_M_use_grouping = false;
821 _M_data->_M_grouping_size = __len;
825 __len = strlen(__cpossign);
828 memset(&__state, 0, sizeof(mbstate_t));
829 __wcs_ps = new wchar_t[__len + 1];
830 mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state);
831 _M_data->_M_positive_sign = __wcs_ps;
834 _M_data->_M_positive_sign = L"";
835 _M_data->_M_positive_sign_size =
836 wcslen(_M_data->_M_positive_sign);
838 __len = strlen(__cnegsign);
840 _M_data->_M_negative_sign = L"()";
843 memset(&__state, 0, sizeof(mbstate_t));
844 __wcs_ns = new wchar_t[__len + 1];
845 mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state);
846 _M_data->_M_negative_sign = __wcs_ns;
849 _M_data->_M_negative_sign = L"";
850 _M_data->_M_negative_sign_size =
851 wcslen(_M_data->_M_negative_sign);
854 __len = strlen(__ccurr);
857 memset(&__state, 0, sizeof(mbstate_t));
858 wchar_t* __wcs = new wchar_t[__len + 1];
859 mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state);
860 _M_data->_M_curr_symbol = __wcs;
863 _M_data->_M_curr_symbol = L"";
864 _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
873 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
876 setlocale(LC_ALL, __sav);
879 __throw_exception_again;
882 char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
883 char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
884 char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
885 _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
887 char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
888 char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
889 _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
892 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
895 setlocale(LC_ALL, __sav);
902 moneypunct<wchar_t, true>::~moneypunct()
904 if (_M_data->_M_grouping_size)
905 delete [] _M_data->_M_grouping;
906 if (_M_data->_M_positive_sign_size)
907 delete [] _M_data->_M_positive_sign;
908 if (_M_data->_M_negative_sign_size
909 && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
910 delete [] _M_data->_M_negative_sign;
911 if (_M_data->_M_curr_symbol_size)
912 delete [] _M_data->_M_curr_symbol;
917 moneypunct<wchar_t, false>::~moneypunct()
919 if (_M_data->_M_grouping_size)
920 delete [] _M_data->_M_grouping;
921 if (_M_data->_M_positive_sign_size)
922 delete [] _M_data->_M_positive_sign;
923 if (_M_data->_M_negative_sign_size
924 && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
925 delete [] _M_data->_M_negative_sign;
926 if (_M_data->_M_curr_symbol_size)
927 delete [] _M_data->_M_curr_symbol;
932 _GLIBCXX_END_NAMESPACE