summaryrefslogtreecommitdiffstats
path: root/meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-05-22 09:42:20 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2009-05-22 09:42:20 +0100
commite6a3149428ef2d42d9a9df78a19c2e52496f3deb (patch)
tree368294cd96f741990717234a6819cc60c1b413f6 /meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch
parentf887fcd665505453412a9f2e2508404e6ec4eea8 (diff)
downloadpoky-e6a3149428ef2d42d9a9df78a19c2e52496f3deb.tar.gz
gcc: Add 4.3.3 and switch to for Moblin
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch')
-rw-r--r--meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch2790
1 files changed, 2790 insertions, 0 deletions
diff --git a/meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch b/meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch
new file mode 100644
index 0000000000..ea21388b75
--- /dev/null
+++ b/meta/packages/gcc/gcc-4.3.3/200-uclibc-locale.patch
@@ -0,0 +1,2790 @@
1--- gcc/libstdc++-v3/acinclude.m4
2+++ gcc/libstdc++-v3/acinclude.m4
3@@ -1369,7 +1369,7 @@
4 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
5 GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
6 [use MODEL for target locale package],
7- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
8+ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
9
10 # Deal with gettext issues. Default to not using it (=no) until we detect
11 # support for it later. Let the user turn it off via --e/d, but let that
12@@ -1385,6 +1385,9 @@
13 # Default to "generic".
14 if test $enable_clocale_flag = auto; then
15 case ${target_os} in
16+ *-uclibc*)
17+ enable_clocale_flag=uclibc
18+ ;;
19 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
20 AC_EGREP_CPP([_GLIBCXX_ok], [
21 #include <features.h>
22@@ -1528,6 +1531,40 @@
23 CTIME_CC=config/locale/generic/time_members.cc
24 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
25 ;;
26+ uclibc)
27+ AC_MSG_RESULT(uclibc)
28+
29+ # Declare intention to use gettext, and add support for specific
30+ # languages.
31+ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
32+ ALL_LINGUAS="de fr"
33+
34+ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
35+ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
36+ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
37+ USE_NLS=yes
38+ fi
39+ # Export the build objects.
40+ for ling in $ALL_LINGUAS; do \
41+ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
42+ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
43+ done
44+ AC_SUBST(glibcxx_MOFILES)
45+ AC_SUBST(glibcxx_POFILES)
46+
47+ CLOCALE_H=config/locale/uclibc/c_locale.h
48+ CLOCALE_CC=config/locale/uclibc/c_locale.cc
49+ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
50+ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
51+ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
52+ CMESSAGES_H=config/locale/uclibc/messages_members.h
53+ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
54+ CMONEY_CC=config/locale/uclibc/monetary_members.cc
55+ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
56+ CTIME_H=config/locale/uclibc/time_members.h
57+ CTIME_CC=config/locale/uclibc/time_members.cc
58+ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
59+ ;;
60 esac
61
62 # This is where the testsuite looks for locale catalogs, using the
63--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
64+++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
65@@ -0,0 +1,63 @@
66+// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
67+
68+// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
69+//
70+// This file is part of the GNU ISO C++ Library. This library is free
71+// software; you can redistribute it and/or modify it under the
72+// terms of the GNU General Public License as published by the
73+// Free Software Foundation; either version 2, or (at your option)
74+// any later version.
75+
76+// This library is distributed in the hope that it will be useful,
77+// but WITHOUT ANY WARRANTY; without even the implied warranty of
78+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79+// GNU General Public License for more details.
80+
81+// You should have received a copy of the GNU General Public License along
82+// with this library; see the file COPYING. If not, write to the Free
83+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
84+// USA.
85+
86+// As a special exception, you may use this file as part of a free software
87+// library without restriction. Specifically, if other files instantiate
88+// templates or use macros or inline functions from this file, or you compile
89+// this file and link it with other files to produce an executable, this
90+// file does not by itself cause the resulting executable to be covered by
91+// the GNU General Public License. This exception does not however
92+// invalidate any other reasons why the executable file might be covered by
93+// the GNU General Public License.
94+
95+// Written by Jakub Jelinek <jakub@redhat.com>
96+
97+#include <bits/c++config.h>
98+#include <clocale>
99+
100+#ifdef __UCLIBC_MJN3_ONLY__
101+#warning clean this up
102+#endif
103+
104+#ifdef __UCLIBC_HAS_XLOCALE__
105+
106+extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
107+extern "C" __typeof(strcoll_l) __strcoll_l;
108+extern "C" __typeof(strftime_l) __strftime_l;
109+extern "C" __typeof(strtod_l) __strtod_l;
110+extern "C" __typeof(strtof_l) __strtof_l;
111+extern "C" __typeof(strtold_l) __strtold_l;
112+extern "C" __typeof(strxfrm_l) __strxfrm_l;
113+extern "C" __typeof(newlocale) __newlocale;
114+extern "C" __typeof(freelocale) __freelocale;
115+extern "C" __typeof(duplocale) __duplocale;
116+extern "C" __typeof(uselocale) __uselocale;
117+
118+#ifdef _GLIBCXX_USE_WCHAR_T
119+extern "C" __typeof(iswctype_l) __iswctype_l;
120+extern "C" __typeof(towlower_l) __towlower_l;
121+extern "C" __typeof(towupper_l) __towupper_l;
122+extern "C" __typeof(wcscoll_l) __wcscoll_l;
123+extern "C" __typeof(wcsftime_l) __wcsftime_l;
124+extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
125+extern "C" __typeof(wctype_l) __wctype_l;
126+#endif
127+
128+#endif // GLIBC 2.3 and later
129--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
130+++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
131@@ -0,0 +1,160 @@
132+// Wrapper for underlying C-language localization -*- C++ -*-
133+
134+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
135+//
136+// This file is part of the GNU ISO C++ Library. This library is free
137+// software; you can redistribute it and/or modify it under the
138+// terms of the GNU General Public License as published by the
139+// Free Software Foundation; either version 2, or (at your option)
140+// any later version.
141+
142+// This library is distributed in the hope that it will be useful,
143+// but WITHOUT ANY WARRANTY; without even the implied warranty of
144+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145+// GNU General Public License for more details.
146+
147+// You should have received a copy of the GNU General Public License along
148+// with this library; see the file COPYING. If not, write to the Free
149+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
150+// USA.
151+
152+// As a special exception, you may use this file as part of a free software
153+// library without restriction. Specifically, if other files instantiate
154+// templates or use macros or inline functions from this file, or you compile
155+// this file and link it with other files to produce an executable, this
156+// file does not by itself cause the resulting executable to be covered by
157+// the GNU General Public License. This exception does not however
158+// invalidate any other reasons why the executable file might be covered by
159+// the GNU General Public License.
160+
161+//
162+// ISO C++ 14882: 22.8 Standard locale categories.
163+//
164+
165+// Written by Benjamin Kosnik <bkoz@redhat.com>
166+
167+#include <cerrno> // For errno
168+#include <locale>
169+#include <stdexcept>
170+#include <langinfo.h>
171+#include <bits/c++locale_internal.h>
172+
173+#ifndef __UCLIBC_HAS_XLOCALE__
174+#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
175+#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
176+#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
177+#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
178+#define __strtof_l(S, E, L) strtof((S), (E))
179+#define __strtod_l(S, E, L) strtod((S), (E))
180+#define __strtold_l(S, E, L) strtold((S), (E))
181+#warning should dummy __newlocale check for C|POSIX ?
182+#define __newlocale(a, b, c) NULL
183+#define __freelocale(a) ((void)0)
184+#define __duplocale(a) __c_locale()
185+#endif
186+
187+namespace std
188+{
189+ template<>
190+ void
191+ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
192+ const __c_locale& __cloc)
193+ {
194+ if (!(__err & ios_base::failbit))
195+ {
196+ char* __sanity;
197+ errno = 0;
198+ float __f = __strtof_l(__s, &__sanity, __cloc);
199+ if (__sanity != __s && errno != ERANGE)
200+ __v = __f;
201+ else
202+ __err |= ios_base::failbit;
203+ }
204+ }
205+
206+ template<>
207+ void
208+ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
209+ const __c_locale& __cloc)
210+ {
211+ if (!(__err & ios_base::failbit))
212+ {
213+ char* __sanity;
214+ errno = 0;
215+ double __d = __strtod_l(__s, &__sanity, __cloc);
216+ if (__sanity != __s && errno != ERANGE)
217+ __v = __d;
218+ else
219+ __err |= ios_base::failbit;
220+ }
221+ }
222+
223+ template<>
224+ void
225+ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
226+ const __c_locale& __cloc)
227+ {
228+ if (!(__err & ios_base::failbit))
229+ {
230+ char* __sanity;
231+ errno = 0;
232+ long double __ld = __strtold_l(__s, &__sanity, __cloc);
233+ if (__sanity != __s && errno != ERANGE)
234+ __v = __ld;
235+ else
236+ __err |= ios_base::failbit;
237+ }
238+ }
239+
240+ void
241+ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
242+ __c_locale __old)
243+ {
244+ __cloc = __newlocale(1 << LC_ALL, __s, __old);
245+#ifdef __UCLIBC_HAS_XLOCALE__
246+ if (!__cloc)
247+ {
248+ // This named locale is not supported by the underlying OS.
249+ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
250+ "name not valid"));
251+ }
252+#endif
253+ }
254+
255+ void
256+ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
257+ {
258+ if (_S_get_c_locale() != __cloc)
259+ __freelocale(__cloc);
260+ }
261+
262+ __c_locale
263+ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
264+ { return __duplocale(__cloc); }
265+} // namespace std
266+
267+namespace __gnu_cxx
268+{
269+ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
270+ {
271+ "LC_CTYPE",
272+ "LC_NUMERIC",
273+ "LC_TIME",
274+ "LC_COLLATE",
275+ "LC_MONETARY",
276+ "LC_MESSAGES",
277+#if _GLIBCXX_NUM_CATEGORIES != 0
278+ "LC_PAPER",
279+ "LC_NAME",
280+ "LC_ADDRESS",
281+ "LC_TELEPHONE",
282+ "LC_MEASUREMENT",
283+ "LC_IDENTIFICATION"
284+#endif
285+ };
286+}
287+
288+namespace std
289+{
290+ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
291+} // namespace std
292--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
293+++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
294@@ -0,0 +1,117 @@
295+// Wrapper for underlying C-language localization -*- C++ -*-
296+
297+// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
298+//
299+// This file is part of the GNU ISO C++ Library. This library is free
300+// software; you can redistribute it and/or modify it under the
301+// terms of the GNU General Public License as published by the
302+// Free Software Foundation; either version 2, or (at your option)
303+// any later version.
304+
305+// This library is distributed in the hope that it will be useful,
306+// but WITHOUT ANY WARRANTY; without even the implied warranty of
307+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
308+// GNU General Public License for more details.
309+
310+// You should have received a copy of the GNU General Public License along
311+// with this library; see the file COPYING. If not, write to the Free
312+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
313+// USA.
314+
315+// As a special exception, you may use this file as part of a free software
316+// library without restriction. Specifically, if other files instantiate
317+// templates or use macros or inline functions from this file, or you compile
318+// this file and link it with other files to produce an executable, this
319+// file does not by itself cause the resulting executable to be covered by
320+// the GNU General Public License. This exception does not however
321+// invalidate any other reasons why the executable file might be covered by
322+// the GNU General Public License.
323+
324+//
325+// ISO C++ 14882: 22.8 Standard locale categories.
326+//
327+
328+// Written by Benjamin Kosnik <bkoz@redhat.com>
329+
330+#ifndef _C_LOCALE_H
331+#define _C_LOCALE_H 1
332+
333+#pragma GCC system_header
334+
335+#include <cstring> // get std::strlen
336+#include <cstdio> // get std::snprintf or std::sprintf
337+#include <clocale>
338+#include <langinfo.h> // For codecvt
339+#ifdef __UCLIBC_MJN3_ONLY__
340+#warning fix this
341+#endif
342+#ifdef __UCLIBC_HAS_LOCALE__
343+#include <iconv.h> // For codecvt using iconv, iconv_t
344+#endif
345+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
346+#include <libintl.h> // For messages
347+#endif
348+
349+#ifdef __UCLIBC_MJN3_ONLY__
350+#warning what is _GLIBCXX_C_LOCALE_GNU for
351+#endif
352+#define _GLIBCXX_C_LOCALE_GNU 1
353+
354+#ifdef __UCLIBC_MJN3_ONLY__
355+#warning fix categories
356+#endif
357+// #define _GLIBCXX_NUM_CATEGORIES 6
358+#define _GLIBCXX_NUM_CATEGORIES 0
359+
360+#ifdef __UCLIBC_HAS_XLOCALE__
361+namespace __gnu_cxx
362+{
363+ extern "C" __typeof(uselocale) __uselocale;
364+}
365+#endif
366+
367+namespace std
368+{
369+#ifdef __UCLIBC_HAS_XLOCALE__
370+ typedef __locale_t __c_locale;
371+#else
372+ typedef int* __c_locale;
373+#endif
374+
375+ // Convert numeric value of type _Tv to string and return length of
376+ // string. If snprintf is available use it, otherwise fall back to
377+ // the unsafe sprintf which, in general, can be dangerous and should
378+ // be avoided.
379+ template<typename _Tv>
380+ int
381+ __convert_from_v(char* __out,
382+ const int __size __attribute__ ((__unused__)),
383+ const char* __fmt,
384+#ifdef __UCLIBC_HAS_XCLOCALE__
385+ _Tv __v, const __c_locale& __cloc, int __prec)
386+ {
387+ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
388+#else
389+ _Tv __v, const __c_locale&, int __prec)
390+ {
391+# ifdef __UCLIBC_HAS_LOCALE__
392+ char* __old = std::setlocale(LC_ALL, NULL);
393+ char* __sav = new char[std::strlen(__old) + 1];
394+ std::strcpy(__sav, __old);
395+ std::setlocale(LC_ALL, "C");
396+# endif
397+#endif
398+
399+ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
400+
401+#ifdef __UCLIBC_HAS_XCLOCALE__
402+ __gnu_cxx::__uselocale(__old);
403+#elif defined __UCLIBC_HAS_LOCALE__
404+ std::setlocale(LC_ALL, __sav);
405+ delete [] __sav;
406+#endif
407+ return __ret;
408+ }
409+}
410+
411+#endif
412--- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
413+++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
414@@ -0,0 +1,306 @@
415+// std::codecvt implementation details, GNU version -*- C++ -*-
416+
417+// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
418+//
419+// This file is part of the GNU ISO C++ Library. This library is free
420+// software; you can redistribute it and/or modify it under the
421+// terms of the GNU General Public License as published by the
422+// Free Software Foundation; either version 2, or (at your option)
423+// any later version.
424+
425+// This library is distributed in the hope that it will be useful,
426+// but WITHOUT ANY WARRANTY; without even the implied warranty of
427+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
428+// GNU General Public License for more details.
429+
430+// You should have received a copy of the GNU General Public License along
431+// with this library; see the file COPYING. If not, write to the Free
432+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
433+// USA.
434+
435+// As a special exception, you may use this file as part of a free software
436+// library without restriction. Specifically, if other files instantiate
437+// templates or use macros or inline functions from this file, or you compile
438+// this file and link it with other files to produce an executable, this
439+// file does not by itself cause the resulting executable to be covered by
440+// the GNU General Public License. This exception does not however
441+// invalidate any other reasons why the executable file might be covered by
442+// the GNU General Public License.
443+
444+//
445+// ISO C++ 14882: 22.2.1.5 - Template class codecvt
446+//
447+
448+// Written by Benjamin Kosnik <bkoz@redhat.com>
449+
450+#include <locale>
451+#include <bits/c++locale_internal.h>
452+
453+namespace std
454+{
455+ // Specializations.
456+#ifdef _GLIBCXX_USE_WCHAR_T
457+ codecvt_base::result
458+ codecvt<wchar_t, char, mbstate_t>::
459+ do_out(state_type& __state, const intern_type* __from,
460+ const intern_type* __from_end, const intern_type*& __from_next,
461+ extern_type* __to, extern_type* __to_end,
462+ extern_type*& __to_next) const
463+ {
464+ result __ret = ok;
465+ state_type __tmp_state(__state);
466+
467+#ifdef __UCLIBC_HAS_XLOCALE__
468+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
469+#endif
470+
471+ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
472+ // in case we fall back to wcrtomb and then continue, in a loop.
473+ // NB: wcsnrtombs is a GNU extension
474+ for (__from_next = __from, __to_next = __to;
475+ __from_next < __from_end && __to_next < __to_end
476+ && __ret == ok;)
477+ {
478+ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
479+ __from_end - __from_next);
480+ if (!__from_chunk_end)
481+ __from_chunk_end = __from_end;
482+
483+ __from = __from_next;
484+ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
485+ __from_chunk_end - __from_next,
486+ __to_end - __to_next, &__state);
487+ if (__conv == static_cast<size_t>(-1))
488+ {
489+ // In case of error, in order to stop at the exact place we
490+ // have to start again from the beginning with a series of
491+ // wcrtomb.
492+ for (; __from < __from_next; ++__from)
493+ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
494+ __state = __tmp_state;
495+ __ret = error;
496+ }
497+ else if (__from_next && __from_next < __from_chunk_end)
498+ {
499+ __to_next += __conv;
500+ __ret = partial;
501+ }
502+ else
503+ {
504+ __from_next = __from_chunk_end;
505+ __to_next += __conv;
506+ }
507+
508+ if (__from_next < __from_end && __ret == ok)
509+ {
510+ extern_type __buf[MB_LEN_MAX];
511+ __tmp_state = __state;
512+ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
513+ if (__conv > static_cast<size_t>(__to_end - __to_next))
514+ __ret = partial;
515+ else
516+ {
517+ memcpy(__to_next, __buf, __conv);
518+ __state = __tmp_state;
519+ __to_next += __conv;
520+ ++__from_next;
521+ }
522+ }
523+ }
524+
525+#ifdef __UCLIBC_HAS_XLOCALE__
526+ __uselocale(__old);
527+#endif
528+
529+ return __ret;
530+ }
531+
532+ codecvt_base::result
533+ codecvt<wchar_t, char, mbstate_t>::
534+ do_in(state_type& __state, const extern_type* __from,
535+ const extern_type* __from_end, const extern_type*& __from_next,
536+ intern_type* __to, intern_type* __to_end,
537+ intern_type*& __to_next) const
538+ {
539+ result __ret = ok;
540+ state_type __tmp_state(__state);
541+
542+#ifdef __UCLIBC_HAS_XLOCALE__
543+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
544+#endif
545+
546+ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
547+ // in case we store a L'\0' and then continue, in a loop.
548+ // NB: mbsnrtowcs is a GNU extension
549+ for (__from_next = __from, __to_next = __to;
550+ __from_next < __from_end && __to_next < __to_end
551+ && __ret == ok;)
552+ {
553+ const extern_type* __from_chunk_end;
554+ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
555+ __from_end
556+ - __from_next));
557+ if (!__from_chunk_end)
558+ __from_chunk_end = __from_end;
559+
560+ __from = __from_next;
561+ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
562+ __from_chunk_end - __from_next,
563+ __to_end - __to_next, &__state);
564+ if (__conv == static_cast<size_t>(-1))
565+ {
566+ // In case of error, in order to stop at the exact place we
567+ // have to start again from the beginning with a series of
568+ // mbrtowc.
569+ for (;; ++__to_next, __from += __conv)
570+ {
571+ __conv = mbrtowc(__to_next, __from, __from_end - __from,
572+ &__tmp_state);
573+ if (__conv == static_cast<size_t>(-1)
574+ || __conv == static_cast<size_t>(-2))
575+ break;
576+ }
577+ __from_next = __from;
578+ __state = __tmp_state;
579+ __ret = error;
580+ }
581+ else if (__from_next && __from_next < __from_chunk_end)
582+ {
583+ // It is unclear what to return in this case (see DR 382).
584+ __to_next += __conv;
585+ __ret = partial;
586+ }
587+ else
588+ {
589+ __from_next = __from_chunk_end;
590+ __to_next += __conv;
591+ }
592+
593+ if (__from_next < __from_end && __ret == ok)
594+ {
595+ if (__to_next < __to_end)
596+ {
597+ // XXX Probably wrong for stateful encodings
598+ __tmp_state = __state;
599+ ++__from_next;
600+ *__to_next++ = L'\0';
601+ }
602+ else
603+ __ret = partial;
604+ }
605+ }
606+
607+#ifdef __UCLIBC_HAS_XLOCALE__
608+ __uselocale(__old);
609+#endif
610+
611+ return __ret;
612+ }
613+
614+ int
615+ codecvt<wchar_t, char, mbstate_t>::
616+ do_encoding() const throw()
617+ {
618+ // XXX This implementation assumes that the encoding is
619+ // stateless and is either single-byte or variable-width.
620+ int __ret = 0;
621+#ifdef __UCLIBC_HAS_XLOCALE__
622+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
623+#endif
624+ if (MB_CUR_MAX == 1)
625+ __ret = 1;
626+#ifdef __UCLIBC_HAS_XLOCALE__
627+ __uselocale(__old);
628+#endif
629+ return __ret;
630+ }
631+
632+ int
633+ codecvt<wchar_t, char, mbstate_t>::
634+ do_max_length() const throw()
635+ {
636+#ifdef __UCLIBC_HAS_XLOCALE__
637+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
638+#endif
639+ // XXX Probably wrong for stateful encodings.
640+ int __ret = MB_CUR_MAX;
641+#ifdef __UCLIBC_HAS_XLOCALE__
642+ __uselocale(__old);
643+#endif
644+ return __ret;
645+ }
646+
647+ int
648+ codecvt<wchar_t, char, mbstate_t>::
649+ do_length(state_type& __state, const extern_type* __from,
650+ const extern_type* __end, size_t __max) const
651+ {
652+ int __ret = 0;
653+ state_type __tmp_state(__state);
654+
655+#ifdef __UCLIBC_HAS_XLOCALE__
656+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
657+#endif
658+
659+ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
660+ // in case we advance past it and then continue, in a loop.
661+ // NB: mbsnrtowcs is a GNU extension
662+
663+ // A dummy internal buffer is needed in order for mbsnrtocws to consider
664+ // its fourth parameter (it wouldn't with NULL as first parameter).
665+ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
666+ * __max));
667+ while (__from < __end && __max)
668+ {
669+ const extern_type* __from_chunk_end;
670+ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
671+ __end
672+ - __from));
673+ if (!__from_chunk_end)
674+ __from_chunk_end = __end;
675+
676+ const extern_type* __tmp_from = __from;
677+ size_t __conv = mbsnrtowcs(__to, &__from,
678+ __from_chunk_end - __from,
679+ __max, &__state);
680+ if (__conv == static_cast<size_t>(-1))
681+ {
682+ // In case of error, in order to stop at the exact place we
683+ // have to start again from the beginning with a series of
684+ // mbrtowc.
685+ for (__from = __tmp_from;; __from += __conv)
686+ {
687+ __conv = mbrtowc(NULL, __from, __end - __from,
688+ &__tmp_state);
689+ if (__conv == static_cast<size_t>(-1)
690+ || __conv == static_cast<size_t>(-2))
691+ break;
692+ }
693+ __state = __tmp_state;
694+ __ret += __from - __tmp_from;
695+ break;
696+ }
697+ if (!__from)
698+ __from = __from_chunk_end;
699+
700+ __ret += __from - __tmp_from;
701+ __max -= __conv;
702+
703+ if (__from < __end && __max)
704+ {
705+ // XXX Probably wrong for stateful encodings
706+ __tmp_state = __state;
707+ ++__from;
708+ ++__ret;
709+ --__max;
710+ }
711+ }
712+
713+#ifdef __UCLIBC_HAS_XLOCALE__
714+ __uselocale(__old);
715+#endif
716+
717+ return __ret;
718+ }
719+#endif
720+}
721--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
722+++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
723@@ -0,0 +1,80 @@
724+// std::collate implementation details, GNU version -*- C++ -*-
725+
726+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
727+//
728+// This file is part of the GNU ISO C++ Library. This library is free
729+// software; you can redistribute it and/or modify it under the
730+// terms of the GNU General Public License as published by the
731+// Free Software Foundation; either version 2, or (at your option)
732+// any later version.
733+
734+// This library is distributed in the hope that it will be useful,
735+// but WITHOUT ANY WARRANTY; without even the implied warranty of
736+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
737+// GNU General Public License for more details.
738+
739+// You should have received a copy of the GNU General Public License along
740+// with this library; see the file COPYING. If not, write to the Free
741+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
742+// USA.
743+
744+// As a special exception, you may use this file as part of a free software
745+// library without restriction. Specifically, if other files instantiate
746+// templates or use macros or inline functions from this file, or you compile
747+// this file and link it with other files to produce an executable, this
748+// file does not by itself cause the resulting executable to be covered by
749+// the GNU General Public License. This exception does not however
750+// invalidate any other reasons why the executable file might be covered by
751+// the GNU General Public License.
752+
753+//
754+// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
755+//
756+
757+// Written by Benjamin Kosnik <bkoz@redhat.com>
758+
759+#include <locale>
760+#include <bits/c++locale_internal.h>
761+
762+#ifndef __UCLIBC_HAS_XLOCALE__
763+#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
764+#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
765+#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
766+#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
767+#endif
768+
769+namespace std
770+{
771+ // These are basically extensions to char_traits, and perhaps should
772+ // be put there instead of here.
773+ template<>
774+ int
775+ collate<char>::_M_compare(const char* __one, const char* __two) const
776+ {
777+ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
778+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
779+ }
780+
781+ template<>
782+ size_t
783+ collate<char>::_M_transform(char* __to, const char* __from,
784+ size_t __n) const
785+ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
786+
787+#ifdef _GLIBCXX_USE_WCHAR_T
788+ template<>
789+ int
790+ collate<wchar_t>::_M_compare(const wchar_t* __one,
791+ const wchar_t* __two) const
792+ {
793+ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
794+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
795+ }
796+
797+ template<>
798+ size_t
799+ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
800+ size_t __n) const
801+ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
802+#endif
803+}
804--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
805+++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
806@@ -0,0 +1,300 @@
807+// std::ctype implementation details, GNU version -*- C++ -*-
808+
809+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
810+//
811+// This file is part of the GNU ISO C++ Library. This library is free
812+// software; you can redistribute it and/or modify it under the
813+// terms of the GNU General Public License as published by the
814+// Free Software Foundation; either version 2, or (at your option)
815+// any later version.
816+
817+// This library is distributed in the hope that it will be useful,
818+// but WITHOUT ANY WARRANTY; without even the implied warranty of
819+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
820+// GNU General Public License for more details.
821+
822+// You should have received a copy of the GNU General Public License along
823+// with this library; see the file COPYING. If not, write to the Free
824+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
825+// USA.
826+
827+// As a special exception, you may use this file as part of a free software
828+// library without restriction. Specifically, if other files instantiate
829+// templates or use macros or inline functions from this file, or you compile
830+// this file and link it with other files to produce an executable, this
831+// file does not by itself cause the resulting executable to be covered by
832+// the GNU General Public License. This exception does not however
833+// invalidate any other reasons why the executable file might be covered by
834+// the GNU General Public License.
835+
836+//
837+// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
838+//
839+
840+// Written by Benjamin Kosnik <bkoz@redhat.com>
841+
842+#define _LIBC
843+#include <locale>
844+#undef _LIBC
845+#include <bits/c++locale_internal.h>
846+
847+#ifndef __UCLIBC_HAS_XLOCALE__
848+#define __wctype_l(S, L) wctype((S))
849+#define __towupper_l(C, L) towupper((C))
850+#define __towlower_l(C, L) towlower((C))
851+#define __iswctype_l(C, M, L) iswctype((C), (M))
852+#endif
853+
854+namespace std
855+{
856+ // NB: The other ctype<char> specializations are in src/locale.cc and
857+ // various /config/os/* files.
858+ template<>
859+ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
860+ : ctype<char>(0, false, __refs)
861+ {
862+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
863+ {
864+ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
865+ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
866+#ifdef __UCLIBC_HAS_XLOCALE__
867+ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
868+ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
869+ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
870+#endif
871+ }
872+ }
873+
874+#ifdef _GLIBCXX_USE_WCHAR_T
875+ ctype<wchar_t>::__wmask_type
876+ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
877+ {
878+ __wmask_type __ret;
879+ switch (__m)
880+ {
881+ case space:
882+ __ret = __wctype_l("space", _M_c_locale_ctype);
883+ break;
884+ case print:
885+ __ret = __wctype_l("print", _M_c_locale_ctype);
886+ break;
887+ case cntrl:
888+ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
889+ break;
890+ case upper:
891+ __ret = __wctype_l("upper", _M_c_locale_ctype);
892+ break;
893+ case lower:
894+ __ret = __wctype_l("lower", _M_c_locale_ctype);
895+ break;
896+ case alpha:
897+ __ret = __wctype_l("alpha", _M_c_locale_ctype);
898+ break;
899+ case digit:
900+ __ret = __wctype_l("digit", _M_c_locale_ctype);
901+ break;
902+ case punct:
903+ __ret = __wctype_l("punct", _M_c_locale_ctype);
904+ break;
905+ case xdigit:
906+ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
907+ break;
908+ case alnum:
909+ __ret = __wctype_l("alnum", _M_c_locale_ctype);
910+ break;
911+ case graph:
912+ __ret = __wctype_l("graph", _M_c_locale_ctype);
913+ break;
914+ default:
915+ __ret = __wmask_type();
916+ }
917+ return __ret;
918+ }
919+
920+ wchar_t
921+ ctype<wchar_t>::do_toupper(wchar_t __c) const
922+ { return __towupper_l(__c, _M_c_locale_ctype); }
923+
924+ const wchar_t*
925+ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
926+ {
927+ while (__lo < __hi)
928+ {
929+ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
930+ ++__lo;
931+ }
932+ return __hi;
933+ }
934+
935+ wchar_t
936+ ctype<wchar_t>::do_tolower(wchar_t __c) const
937+ { return __towlower_l(__c, _M_c_locale_ctype); }
938+
939+ const wchar_t*
940+ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
941+ {
942+ while (__lo < __hi)
943+ {
944+ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
945+ ++__lo;
946+ }
947+ return __hi;
948+ }
949+
950+ bool
951+ ctype<wchar_t>::
952+ do_is(mask __m, wchar_t __c) const
953+ {
954+ // Highest bitmask in ctype_base == 10, but extra in "C"
955+ // library for blank.
956+ bool __ret = false;
957+ const size_t __bitmasksize = 11;
958+ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
959+ if (__m & _M_bit[__bitcur]
960+ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
961+ {
962+ __ret = true;
963+ break;
964+ }
965+ return __ret;
966+ }
967+
968+ const wchar_t*
969+ ctype<wchar_t>::
970+ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
971+ {
972+ for (; __lo < __hi; ++__vec, ++__lo)
973+ {
974+ // Highest bitmask in ctype_base == 10, but extra in "C"
975+ // library for blank.
976+ const size_t __bitmasksize = 11;
977+ mask __m = 0;
978+ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
979+ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
980+ __m |= _M_bit[__bitcur];
981+ *__vec = __m;
982+ }
983+ return __hi;
984+ }
985+
986+ const wchar_t*
987+ ctype<wchar_t>::
988+ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
989+ {
990+ while (__lo < __hi && !this->do_is(__m, *__lo))
991+ ++__lo;
992+ return __lo;
993+ }
994+
995+ const wchar_t*
996+ ctype<wchar_t>::
997+ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
998+ {
999+ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
1000+ ++__lo;
1001+ return __lo;
1002+ }
1003+
1004+ wchar_t
1005+ ctype<wchar_t>::
1006+ do_widen(char __c) const
1007+ { return _M_widen[static_cast<unsigned char>(__c)]; }
1008+
1009+ const char*
1010+ ctype<wchar_t>::
1011+ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
1012+ {
1013+ while (__lo < __hi)
1014+ {
1015+ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
1016+ ++__lo;
1017+ ++__dest;
1018+ }
1019+ return __hi;
1020+ }
1021+
1022+ char
1023+ ctype<wchar_t>::
1024+ do_narrow(wchar_t __wc, char __dfault) const
1025+ {
1026+ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
1027+ return _M_narrow[__wc];
1028+#ifdef __UCLIBC_HAS_XLOCALE__
1029+ __c_locale __old = __uselocale(_M_c_locale_ctype);
1030+#endif
1031+ const int __c = wctob(__wc);
1032+#ifdef __UCLIBC_HAS_XLOCALE__
1033+ __uselocale(__old);
1034+#endif
1035+ return (__c == EOF ? __dfault : static_cast<char>(__c));
1036+ }
1037+
1038+ const wchar_t*
1039+ ctype<wchar_t>::
1040+ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
1041+ char* __dest) const
1042+ {
1043+#ifdef __UCLIBC_HAS_XLOCALE__
1044+ __c_locale __old = __uselocale(_M_c_locale_ctype);
1045+#endif
1046+ if (_M_narrow_ok)
1047+ while (__lo < __hi)
1048+ {
1049+ if (*__lo >= 0 && *__lo < 128)
1050+ *__dest = _M_narrow[*__lo];
1051+ else
1052+ {
1053+ const int __c = wctob(*__lo);
1054+ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
1055+ }
1056+ ++__lo;
1057+ ++__dest;
1058+ }
1059+ else
1060+ while (__lo < __hi)
1061+ {
1062+ const int __c = wctob(*__lo);
1063+ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
1064+ ++__lo;
1065+ ++__dest;
1066+ }
1067+#ifdef __UCLIBC_HAS_XLOCALE__
1068+ __uselocale(__old);
1069+#endif
1070+ return __hi;
1071+ }
1072+
1073+ void
1074+ ctype<wchar_t>::_M_initialize_ctype()
1075+ {
1076+#ifdef __UCLIBC_HAS_XLOCALE__
1077+ __c_locale __old = __uselocale(_M_c_locale_ctype);
1078+#endif
1079+ wint_t __i;
1080+ for (__i = 0; __i < 128; ++__i)
1081+ {
1082+ const int __c = wctob(__i);
1083+ if (__c == EOF)
1084+ break;
1085+ else
1086+ _M_narrow[__i] = static_cast<char>(__c);
1087+ }
1088+ if (__i == 128)
1089+ _M_narrow_ok = true;
1090+ else
1091+ _M_narrow_ok = false;
1092+ for (size_t __j = 0;
1093+ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
1094+ _M_widen[__j] = btowc(__j);
1095+
1096+ for (size_t __k = 0; __k <= 11; ++__k)
1097+ {
1098+ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
1099+ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
1100+ }
1101+#ifdef __UCLIBC_HAS_XLOCALE__
1102+ __uselocale(__old);
1103+#endif
1104+ }
1105+#endif // _GLIBCXX_USE_WCHAR_T
1106+}
1107--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
1108+++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
1109@@ -0,0 +1,100 @@
1110+// std::messages implementation details, GNU version -*- C++ -*-
1111+
1112+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
1113+//
1114+// This file is part of the GNU ISO C++ Library. This library is free
1115+// software; you can redistribute it and/or modify it under the
1116+// terms of the GNU General Public License as published by the
1117+// Free Software Foundation; either version 2, or (at your option)
1118+// any later version.
1119+
1120+// This library is distributed in the hope that it will be useful,
1121+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1122+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1123+// GNU General Public License for more details.
1124+
1125+// You should have received a copy of the GNU General Public License along
1126+// with this library; see the file COPYING. If not, write to the Free
1127+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1128+// USA.
1129+
1130+// As a special exception, you may use this file as part of a free software
1131+// library without restriction. Specifically, if other files instantiate
1132+// templates or use macros or inline functions from this file, or you compile
1133+// this file and link it with other files to produce an executable, this
1134+// file does not by itself cause the resulting executable to be covered by
1135+// the GNU General Public License. This exception does not however
1136+// invalidate any other reasons why the executable file might be covered by
1137+// the GNU General Public License.
1138+
1139+//
1140+// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
1141+//
1142+
1143+// Written by Benjamin Kosnik <bkoz@redhat.com>
1144+
1145+#include <locale>
1146+#include <bits/c++locale_internal.h>
1147+
1148+#ifdef __UCLIBC_MJN3_ONLY__
1149+#warning fix gettext stuff
1150+#endif
1151+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
1152+extern "C" char *__dcgettext(const char *domainname,
1153+ const char *msgid, int category);
1154+#undef gettext
1155+#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
1156+#else
1157+#undef gettext
1158+#define gettext(msgid) (msgid)
1159+#endif
1160+
1161+namespace std
1162+{
1163+ // Specializations.
1164+ template<>
1165+ string
1166+ messages<char>::do_get(catalog, int, int, const string& __dfault) const
1167+ {
1168+#ifdef __UCLIBC_HAS_XLOCALE__
1169+ __c_locale __old = __uselocale(_M_c_locale_messages);
1170+ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
1171+ __uselocale(__old);
1172+ return string(__msg);
1173+#elif defined __UCLIBC_HAS_LOCALE__
1174+ char* __old = strdup(setlocale(LC_ALL, NULL));
1175+ setlocale(LC_ALL, _M_name_messages);
1176+ const char* __msg = gettext(__dfault.c_str());
1177+ setlocale(LC_ALL, __old);
1178+ free(__old);
1179+ return string(__msg);
1180+#else
1181+ const char* __msg = gettext(__dfault.c_str());
1182+ return string(__msg);
1183+#endif
1184+ }
1185+
1186+#ifdef _GLIBCXX_USE_WCHAR_T
1187+ template<>
1188+ wstring
1189+ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
1190+ {
1191+# ifdef __UCLIBC_HAS_XLOCALE__
1192+ __c_locale __old = __uselocale(_M_c_locale_messages);
1193+ char* __msg = gettext(_M_convert_to_char(__dfault));
1194+ __uselocale(__old);
1195+ return _M_convert_from_char(__msg);
1196+# elif defined __UCLIBC_HAS_LOCALE__
1197+ char* __old = strdup(setlocale(LC_ALL, NULL));
1198+ setlocale(LC_ALL, _M_name_messages);
1199+ char* __msg = gettext(_M_convert_to_char(__dfault));
1200+ setlocale(LC_ALL, __old);
1201+ free(__old);
1202+ return _M_convert_from_char(__msg);
1203+# else
1204+ char* __msg = gettext(_M_convert_to_char(__dfault));
1205+ return _M_convert_from_char(__msg);
1206+# endif
1207+ }
1208+#endif
1209+}
1210--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
1211+++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
1212@@ -0,0 +1,118 @@
1213+// std::messages implementation details, GNU version -*- C++ -*-
1214+
1215+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
1216+//
1217+// This file is part of the GNU ISO C++ Library. This library is free
1218+// software; you can redistribute it and/or modify it under the
1219+// terms of the GNU General Public License as published by the
1220+// Free Software Foundation; either version 2, or (at your option)
1221+// any later version.
1222+
1223+// This library is distributed in the hope that it will be useful,
1224+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1225+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1226+// GNU General Public License for more details.
1227+
1228+// You should have received a copy of the GNU General Public License along
1229+// with this library; see the file COPYING. If not, write to the Free
1230+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1231+// USA.
1232+
1233+// As a special exception, you may use this file as part of a free software
1234+// library without restriction. Specifically, if other files instantiate
1235+// templates or use macros or inline functions from this file, or you compile
1236+// this file and link it with other files to produce an executable, this
1237+// file does not by itself cause the resulting executable to be covered by
1238+// the GNU General Public License. This exception does not however
1239+// invalidate any other reasons why the executable file might be covered by
1240+// the GNU General Public License.
1241+
1242+//
1243+// ISO C++ 14882: 22.2.7.1.2 messages functions
1244+//
1245+
1246+// Written by Benjamin Kosnik <bkoz@redhat.com>
1247+
1248+#ifdef __UCLIBC_MJN3_ONLY__
1249+#warning fix prototypes for *textdomain funcs
1250+#endif
1251+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
1252+extern "C" char *__textdomain(const char *domainname);
1253+extern "C" char *__bindtextdomain(const char *domainname,
1254+ const char *dirname);
1255+#else
1256+#undef __textdomain
1257+#undef __bindtextdomain
1258+#define __textdomain(D) ((void)0)
1259+#define __bindtextdomain(D,P) ((void)0)
1260+#endif
1261+
1262+ // Non-virtual member functions.
1263+ template<typename _CharT>
1264+ messages<_CharT>::messages(size_t __refs)
1265+ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
1266+ _M_name_messages(_S_get_c_name())
1267+ { }
1268+
1269+ template<typename _CharT>
1270+ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
1271+ size_t __refs)
1272+ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
1273+ _M_name_messages(__s)
1274+ {
1275+ char* __tmp = new char[std::strlen(__s) + 1];
1276+ std::strcpy(__tmp, __s);
1277+ _M_name_messages = __tmp;
1278+ }
1279+
1280+ template<typename _CharT>
1281+ typename messages<_CharT>::catalog
1282+ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
1283+ const char* __dir) const
1284+ {
1285+ __bindtextdomain(__s.c_str(), __dir);
1286+ return this->do_open(__s, __loc);
1287+ }
1288+
1289+ // Virtual member functions.
1290+ template<typename _CharT>
1291+ messages<_CharT>::~messages()
1292+ {
1293+ if (_M_name_messages != _S_get_c_name())
1294+ delete [] _M_name_messages;
1295+ _S_destroy_c_locale(_M_c_locale_messages);
1296+ }
1297+
1298+ template<typename _CharT>
1299+ typename messages<_CharT>::catalog
1300+ messages<_CharT>::do_open(const basic_string<char>& __s,
1301+ const locale&) const
1302+ {
1303+ // No error checking is done, assume the catalog exists and can
1304+ // be used.
1305+ __textdomain(__s.c_str());
1306+ return 0;
1307+ }
1308+
1309+ template<typename _CharT>
1310+ void
1311+ messages<_CharT>::do_close(catalog) const
1312+ { }
1313+
1314+ // messages_byname
1315+ template<typename _CharT>
1316+ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
1317+ : messages<_CharT>(__refs)
1318+ {
1319+ if (this->_M_name_messages != locale::facet::_S_get_c_name())
1320+ delete [] this->_M_name_messages;
1321+ char* __tmp = new char[std::strlen(__s) + 1];
1322+ std::strcpy(__tmp, __s);
1323+ this->_M_name_messages = __tmp;
1324+
1325+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
1326+ {
1327+ this->_S_destroy_c_locale(this->_M_c_locale_messages);
1328+ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
1329+ }
1330+ }
1331--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
1332+++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
1333@@ -0,0 +1,692 @@
1334+// std::moneypunct implementation details, GNU version -*- C++ -*-
1335+
1336+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
1337+//
1338+// This file is part of the GNU ISO C++ Library. This library is free
1339+// software; you can redistribute it and/or modify it under the
1340+// terms of the GNU General Public License as published by the
1341+// Free Software Foundation; either version 2, or (at your option)
1342+// any later version.
1343+
1344+// This library is distributed in the hope that it will be useful,
1345+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1346+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1347+// GNU General Public License for more details.
1348+
1349+// You should have received a copy of the GNU General Public License along
1350+// with this library; see the file COPYING. If not, write to the Free
1351+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1352+// USA.
1353+
1354+// As a special exception, you may use this file as part of a free software
1355+// library without restriction. Specifically, if other files instantiate
1356+// templates or use macros or inline functions from this file, or you compile
1357+// this file and link it with other files to produce an executable, this
1358+// file does not by itself cause the resulting executable to be covered by
1359+// the GNU General Public License. This exception does not however
1360+// invalidate any other reasons why the executable file might be covered by
1361+// the GNU General Public License.
1362+
1363+//
1364+// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
1365+//
1366+
1367+// Written by Benjamin Kosnik <bkoz@redhat.com>
1368+
1369+#define _LIBC
1370+#include <locale>
1371+#undef _LIBC
1372+#include <bits/c++locale_internal.h>
1373+
1374+#ifdef __UCLIBC_MJN3_ONLY__
1375+#warning optimize this for uclibc
1376+#warning tailor for stub locale support
1377+#endif
1378+
1379+#ifndef __UCLIBC_HAS_XLOCALE__
1380+#define __nl_langinfo_l(N, L) nl_langinfo((N))
1381+#endif
1382+
1383+namespace std
1384+{
1385+ // Construct and return valid pattern consisting of some combination of:
1386+ // space none symbol sign value
1387+ money_base::pattern
1388+ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
1389+ {
1390+ pattern __ret;
1391+
1392+ // This insanely complicated routine attempts to construct a valid
1393+ // pattern for use with monyepunct. A couple of invariants:
1394+
1395+ // if (__precedes) symbol -> value
1396+ // else value -> symbol
1397+
1398+ // if (__space) space
1399+ // else none
1400+
1401+ // none == never first
1402+ // space never first or last
1403+
1404+ // Any elegant implementations of this are welcome.
1405+ switch (__posn)
1406+ {
1407+ case 0:
1408+ case 1:
1409+ // 1 The sign precedes the value and symbol.
1410+ __ret.field[0] = sign;
1411+ if (__space)
1412+ {
1413+ // Pattern starts with sign.
1414+ if (__precedes)
1415+ {
1416+ __ret.field[1] = symbol;
1417+ __ret.field[3] = value;
1418+ }
1419+ else
1420+ {
1421+ __ret.field[1] = value;
1422+ __ret.field[3] = symbol;
1423+ }
1424+ __ret.field[2] = space;
1425+ }
1426+ else
1427+ {
1428+ // Pattern starts with sign and ends with none.
1429+ if (__precedes)
1430+ {
1431+ __ret.field[1] = symbol;
1432+ __ret.field[2] = value;
1433+ }
1434+ else
1435+ {
1436+ __ret.field[1] = value;
1437+ __ret.field[2] = symbol;
1438+ }
1439+ __ret.field[3] = none;
1440+ }
1441+ break;
1442+ case 2:
1443+ // 2 The sign follows the value and symbol.
1444+ if (__space)
1445+ {
1446+ // Pattern either ends with sign.
1447+ if (__precedes)
1448+ {
1449+ __ret.field[0] = symbol;
1450+ __ret.field[2] = value;
1451+ }
1452+ else
1453+ {
1454+ __ret.field[0] = value;
1455+ __ret.field[2] = symbol;
1456+ }
1457+ __ret.field[1] = space;
1458+ __ret.field[3] = sign;
1459+ }
1460+ else
1461+ {
1462+ // Pattern ends with sign then none.
1463+ if (__precedes)
1464+ {
1465+ __ret.field[0] = symbol;
1466+ __ret.field[1] = value;
1467+ }
1468+ else
1469+ {
1470+ __ret.field[0] = value;
1471+ __ret.field[1] = symbol;
1472+ }
1473+ __ret.field[2] = sign;
1474+ __ret.field[3] = none;
1475+ }
1476+ break;
1477+ case 3:
1478+ // 3 The sign immediately precedes the symbol.
1479+ if (__precedes)
1480+ {
1481+ __ret.field[0] = sign;
1482+ __ret.field[1] = symbol;
1483+ if (__space)
1484+ {
1485+ __ret.field[2] = space;
1486+ __ret.field[3] = value;
1487+ }
1488+ else
1489+ {
1490+ __ret.field[2] = value;
1491+ __ret.field[3] = none;
1492+ }
1493+ }
1494+ else
1495+ {
1496+ __ret.field[0] = value;
1497+ if (__space)
1498+ {
1499+ __ret.field[1] = space;
1500+ __ret.field[2] = sign;
1501+ __ret.field[3] = symbol;
1502+ }
1503+ else
1504+ {
1505+ __ret.field[1] = sign;
1506+ __ret.field[2] = symbol;
1507+ __ret.field[3] = none;
1508+ }
1509+ }
1510+ break;
1511+ case 4:
1512+ // 4 The sign immediately follows the symbol.
1513+ if (__precedes)
1514+ {
1515+ __ret.field[0] = symbol;
1516+ __ret.field[1] = sign;
1517+ if (__space)
1518+ {
1519+ __ret.field[2] = space;
1520+ __ret.field[3] = value;
1521+ }
1522+ else
1523+ {
1524+ __ret.field[2] = value;
1525+ __ret.field[3] = none;
1526+ }
1527+ }
1528+ else
1529+ {
1530+ __ret.field[0] = value;
1531+ if (__space)
1532+ {
1533+ __ret.field[1] = space;
1534+ __ret.field[2] = symbol;
1535+ __ret.field[3] = sign;
1536+ }
1537+ else
1538+ {
1539+ __ret.field[1] = symbol;
1540+ __ret.field[2] = sign;
1541+ __ret.field[3] = none;
1542+ }
1543+ }
1544+ break;
1545+ default:
1546+ ;
1547+ }
1548+ return __ret;
1549+ }
1550+
1551+ template<>
1552+ void
1553+ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
1554+ const char*)
1555+ {
1556+ if (!_M_data)
1557+ _M_data = new __moneypunct_cache<char, true>;
1558+
1559+ if (!__cloc)
1560+ {
1561+ // "C" locale
1562+ _M_data->_M_decimal_point = '.';
1563+ _M_data->_M_thousands_sep = ',';
1564+ _M_data->_M_grouping = "";
1565+ _M_data->_M_grouping_size = 0;
1566+ _M_data->_M_curr_symbol = "";
1567+ _M_data->_M_curr_symbol_size = 0;
1568+ _M_data->_M_positive_sign = "";
1569+ _M_data->_M_positive_sign_size = 0;
1570+ _M_data->_M_negative_sign = "";
1571+ _M_data->_M_negative_sign_size = 0;
1572+ _M_data->_M_frac_digits = 0;
1573+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1574+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1575+
1576+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1577+ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
1578+ }
1579+ else
1580+ {
1581+ // Named locale.
1582+ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
1583+ __cloc));
1584+ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
1585+ __cloc));
1586+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1587+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1588+ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1589+ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
1590+
1591+ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
1592+ if (!__nposn)
1593+ _M_data->_M_negative_sign = "()";
1594+ else
1595+ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
1596+ __cloc);
1597+ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
1598+
1599+ // _Intl == true
1600+ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
1601+ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
1602+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
1603+ __cloc));
1604+ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
1605+ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
1606+ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
1607+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1608+ __pposn);
1609+ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
1610+ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
1611+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1612+ __nposn);
1613+ }
1614+ }
1615+
1616+ template<>
1617+ void
1618+ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
1619+ const char*)
1620+ {
1621+ if (!_M_data)
1622+ _M_data = new __moneypunct_cache<char, false>;
1623+
1624+ if (!__cloc)
1625+ {
1626+ // "C" locale
1627+ _M_data->_M_decimal_point = '.';
1628+ _M_data->_M_thousands_sep = ',';
1629+ _M_data->_M_grouping = "";
1630+ _M_data->_M_grouping_size = 0;
1631+ _M_data->_M_curr_symbol = "";
1632+ _M_data->_M_curr_symbol_size = 0;
1633+ _M_data->_M_positive_sign = "";
1634+ _M_data->_M_positive_sign_size = 0;
1635+ _M_data->_M_negative_sign = "";
1636+ _M_data->_M_negative_sign_size = 0;
1637+ _M_data->_M_frac_digits = 0;
1638+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1639+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1640+
1641+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1642+ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
1643+ }
1644+ else
1645+ {
1646+ // Named locale.
1647+ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
1648+ __cloc));
1649+ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
1650+ __cloc));
1651+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1652+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1653+ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1654+ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
1655+
1656+ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
1657+ if (!__nposn)
1658+ _M_data->_M_negative_sign = "()";
1659+ else
1660+ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
1661+ __cloc);
1662+ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
1663+
1664+ // _Intl == false
1665+ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
1666+ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
1667+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
1668+ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
1669+ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
1670+ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
1671+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1672+ __pposn);
1673+ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
1674+ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
1675+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1676+ __nposn);
1677+ }
1678+ }
1679+
1680+ template<>
1681+ moneypunct<char, true>::~moneypunct()
1682+ { delete _M_data; }
1683+
1684+ template<>
1685+ moneypunct<char, false>::~moneypunct()
1686+ { delete _M_data; }
1687+
1688+#ifdef _GLIBCXX_USE_WCHAR_T
1689+ template<>
1690+ void
1691+ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
1692+#ifdef __UCLIBC_HAS_XLOCALE__
1693+ const char*)
1694+#else
1695+ const char* __name)
1696+#endif
1697+ {
1698+ if (!_M_data)
1699+ _M_data = new __moneypunct_cache<wchar_t, true>;
1700+
1701+ if (!__cloc)
1702+ {
1703+ // "C" locale
1704+ _M_data->_M_decimal_point = L'.';
1705+ _M_data->_M_thousands_sep = L',';
1706+ _M_data->_M_grouping = "";
1707+ _M_data->_M_grouping_size = 0;
1708+ _M_data->_M_curr_symbol = L"";
1709+ _M_data->_M_curr_symbol_size = 0;
1710+ _M_data->_M_positive_sign = L"";
1711+ _M_data->_M_positive_sign_size = 0;
1712+ _M_data->_M_negative_sign = L"";
1713+ _M_data->_M_negative_sign_size = 0;
1714+ _M_data->_M_frac_digits = 0;
1715+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1716+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1717+
1718+ // Use ctype::widen code without the facet...
1719+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1720+ _M_data->_M_atoms[__i] =
1721+ static_cast<wchar_t>(money_base::_S_atoms[__i]);
1722+ }
1723+ else
1724+ {
1725+ // Named locale.
1726+#ifdef __UCLIBC_HAS_XLOCALE__
1727+ __c_locale __old = __uselocale(__cloc);
1728+#else
1729+ // Switch to named locale so that mbsrtowcs will work.
1730+ char* __old = strdup(setlocale(LC_ALL, NULL));
1731+ setlocale(LC_ALL, __name);
1732+#endif
1733+
1734+#ifdef __UCLIBC_MJN3_ONLY__
1735+#warning fix this... should be monetary
1736+#endif
1737+#ifdef __UCLIBC__
1738+# ifdef __UCLIBC_HAS_XLOCALE__
1739+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
1740+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
1741+# else
1742+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
1743+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
1744+# endif
1745+#else
1746+ union { char *__s; wchar_t __w; } __u;
1747+ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
1748+ _M_data->_M_decimal_point = __u.__w;
1749+
1750+ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
1751+ _M_data->_M_thousands_sep = __u.__w;
1752+#endif
1753+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1754+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1755+
1756+ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1757+ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
1758+ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
1759+
1760+ wchar_t* __wcs_ps = 0;
1761+ wchar_t* __wcs_ns = 0;
1762+ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
1763+ try
1764+ {
1765+ mbstate_t __state;
1766+ size_t __len = strlen(__cpossign);
1767+ if (__len)
1768+ {
1769+ ++__len;
1770+ memset(&__state, 0, sizeof(mbstate_t));
1771+ __wcs_ps = new wchar_t[__len];
1772+ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
1773+ _M_data->_M_positive_sign = __wcs_ps;
1774+ }
1775+ else
1776+ _M_data->_M_positive_sign = L"";
1777+ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
1778+
1779+ __len = strlen(__cnegsign);
1780+ if (!__nposn)
1781+ _M_data->_M_negative_sign = L"()";
1782+ else if (__len)
1783+ {
1784+ ++__len;
1785+ memset(&__state, 0, sizeof(mbstate_t));
1786+ __wcs_ns = new wchar_t[__len];
1787+ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
1788+ _M_data->_M_negative_sign = __wcs_ns;
1789+ }
1790+ else
1791+ _M_data->_M_negative_sign = L"";
1792+ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
1793+
1794+ // _Intl == true.
1795+ __len = strlen(__ccurr);
1796+ if (__len)
1797+ {
1798+ ++__len;
1799+ memset(&__state, 0, sizeof(mbstate_t));
1800+ wchar_t* __wcs = new wchar_t[__len];
1801+ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
1802+ _M_data->_M_curr_symbol = __wcs;
1803+ }
1804+ else
1805+ _M_data->_M_curr_symbol = L"";
1806+ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
1807+ }
1808+ catch (...)
1809+ {
1810+ delete _M_data;
1811+ _M_data = 0;
1812+ delete __wcs_ps;
1813+ delete __wcs_ns;
1814+#ifdef __UCLIBC_HAS_XLOCALE__
1815+ __uselocale(__old);
1816+#else
1817+ setlocale(LC_ALL, __old);
1818+ free(__old);
1819+#endif
1820+ __throw_exception_again;
1821+ }
1822+
1823+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
1824+ __cloc));
1825+ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
1826+ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
1827+ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
1828+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1829+ __pposn);
1830+ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
1831+ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
1832+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1833+ __nposn);
1834+
1835+#ifdef __UCLIBC_HAS_XLOCALE__
1836+ __uselocale(__old);
1837+#else
1838+ setlocale(LC_ALL, __old);
1839+ free(__old);
1840+#endif
1841+ }
1842+ }
1843+
1844+ template<>
1845+ void
1846+ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
1847+#ifdef __UCLIBC_HAS_XLOCALE__
1848+ const char*)
1849+#else
1850+ const char* __name)
1851+#endif
1852+ {
1853+ if (!_M_data)
1854+ _M_data = new __moneypunct_cache<wchar_t, false>;
1855+
1856+ if (!__cloc)
1857+ {
1858+ // "C" locale
1859+ _M_data->_M_decimal_point = L'.';
1860+ _M_data->_M_thousands_sep = L',';
1861+ _M_data->_M_grouping = "";
1862+ _M_data->_M_grouping_size = 0;
1863+ _M_data->_M_curr_symbol = L"";
1864+ _M_data->_M_curr_symbol_size = 0;
1865+ _M_data->_M_positive_sign = L"";
1866+ _M_data->_M_positive_sign_size = 0;
1867+ _M_data->_M_negative_sign = L"";
1868+ _M_data->_M_negative_sign_size = 0;
1869+ _M_data->_M_frac_digits = 0;
1870+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1871+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1872+
1873+ // Use ctype::widen code without the facet...
1874+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1875+ _M_data->_M_atoms[__i] =
1876+ static_cast<wchar_t>(money_base::_S_atoms[__i]);
1877+ }
1878+ else
1879+ {
1880+ // Named locale.
1881+#ifdef __UCLIBC_HAS_XLOCALE__
1882+ __c_locale __old = __uselocale(__cloc);
1883+#else
1884+ // Switch to named locale so that mbsrtowcs will work.
1885+ char* __old = strdup(setlocale(LC_ALL, NULL));
1886+ setlocale(LC_ALL, __name);
1887+#endif
1888+
1889+#ifdef __UCLIBC_MJN3_ONLY__
1890+#warning fix this... should be monetary
1891+#endif
1892+#ifdef __UCLIBC__
1893+# ifdef __UCLIBC_HAS_XLOCALE__
1894+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
1895+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
1896+# else
1897+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
1898+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
1899+# endif
1900+#else
1901+ union { char *__s; wchar_t __w; } __u;
1902+ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
1903+ _M_data->_M_decimal_point = __u.__w;
1904+
1905+ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
1906+ _M_data->_M_thousands_sep = __u.__w;
1907+#endif
1908+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1909+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1910+
1911+ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1912+ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
1913+ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
1914+
1915+ wchar_t* __wcs_ps = 0;
1916+ wchar_t* __wcs_ns = 0;
1917+ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
1918+ try
1919+ {
1920+ mbstate_t __state;
1921+ size_t __len;
1922+ __len = strlen(__cpossign);
1923+ if (__len)
1924+ {
1925+ ++__len;
1926+ memset(&__state, 0, sizeof(mbstate_t));
1927+ __wcs_ps = new wchar_t[__len];
1928+ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
1929+ _M_data->_M_positive_sign = __wcs_ps;
1930+ }
1931+ else
1932+ _M_data->_M_positive_sign = L"";
1933+ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
1934+
1935+ __len = strlen(__cnegsign);
1936+ if (!__nposn)
1937+ _M_data->_M_negative_sign = L"()";
1938+ else if (__len)
1939+ {
1940+ ++__len;
1941+ memset(&__state, 0, sizeof(mbstate_t));
1942+ __wcs_ns = new wchar_t[__len];
1943+ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
1944+ _M_data->_M_negative_sign = __wcs_ns;
1945+ }
1946+ else
1947+ _M_data->_M_negative_sign = L"";
1948+ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
1949+
1950+ // _Intl == true.
1951+ __len = strlen(__ccurr);
1952+ if (__len)
1953+ {
1954+ ++__len;
1955+ memset(&__state, 0, sizeof(mbstate_t));
1956+ wchar_t* __wcs = new wchar_t[__len];
1957+ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
1958+ _M_data->_M_curr_symbol = __wcs;
1959+ }
1960+ else
1961+ _M_data->_M_curr_symbol = L"";
1962+ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
1963+ }
1964+ catch (...)
1965+ {
1966+ delete _M_data;
1967+ _M_data = 0;
1968+ delete __wcs_ps;
1969+ delete __wcs_ns;
1970+#ifdef __UCLIBC_HAS_XLOCALE__
1971+ __uselocale(__old);
1972+#else
1973+ setlocale(LC_ALL, __old);
1974+ free(__old);
1975+#endif
1976+ __throw_exception_again;
1977+ }
1978+
1979+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
1980+ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
1981+ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
1982+ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
1983+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1984+ __pposn);
1985+ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
1986+ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
1987+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1988+ __nposn);
1989+
1990+#ifdef __UCLIBC_HAS_XLOCALE__
1991+ __uselocale(__old);
1992+#else
1993+ setlocale(LC_ALL, __old);
1994+ free(__old);
1995+#endif
1996+ }
1997+ }
1998+
1999+ template<>
2000+ moneypunct<wchar_t, true>::~moneypunct()
2001+ {
2002+ if (_M_data->_M_positive_sign_size)
2003+ delete [] _M_data->_M_positive_sign;
2004+ if (_M_data->_M_negative_sign_size
2005+ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
2006+ delete [] _M_data->_M_negative_sign;
2007+ if (_M_data->_M_curr_symbol_size)
2008+ delete [] _M_data->_M_curr_symbol;
2009+ delete _M_data;
2010+ }
2011+
2012+ template<>
2013+ moneypunct<wchar_t, false>::~moneypunct()
2014+ {
2015+ if (_M_data->_M_positive_sign_size)
2016+ delete [] _M_data->_M_positive_sign;
2017+ if (_M_data->_M_negative_sign_size
2018+ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
2019+ delete [] _M_data->_M_negative_sign;
2020+ if (_M_data->_M_curr_symbol_size)
2021+ delete [] _M_data->_M_curr_symbol;
2022+ delete _M_data;
2023+ }
2024+#endif
2025+}
2026--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
2027+++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
2028@@ -0,0 +1,160 @@
2029+// std::numpunct implementation details, GNU version -*- C++ -*-
2030+
2031+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2032+//
2033+// This file is part of the GNU ISO C++ Library. This library is free
2034+// software; you can redistribute it and/or modify it under the
2035+// terms of the GNU General Public License as published by the
2036+// Free Software Foundation; either version 2, or (at your option)
2037+// any later version.
2038+
2039+// This library is distributed in the hope that it will be useful,
2040+// but WITHOUT ANY WARRANTY; without even the implied warranty of
2041+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2042+// GNU General Public License for more details.
2043+
2044+// You should have received a copy of the GNU General Public License along
2045+// with this library; see the file COPYING. If not, write to the Free
2046+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2047+// USA.
2048+
2049+// As a special exception, you may use this file as part of a free software
2050+// library without restriction. Specifically, if other files instantiate
2051+// templates or use macros or inline functions from this file, or you compile
2052+// this file and link it with other files to produce an executable, this
2053+// file does not by itself cause the resulting executable to be covered by
2054+// the GNU General Public License. This exception does not however
2055+// invalidate any other reasons why the executable file might be covered by
2056+// the GNU General Public License.
2057+
2058+//
2059+// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
2060+//
2061+
2062+// Written by Benjamin Kosnik <bkoz@redhat.com>
2063+
2064+#define _LIBC
2065+#include <locale>
2066+#undef _LIBC
2067+#include <bits/c++locale_internal.h>
2068+
2069+#ifdef __UCLIBC_MJN3_ONLY__
2070+#warning tailor for stub locale support
2071+#endif
2072+#ifndef __UCLIBC_HAS_XLOCALE__
2073+#define __nl_langinfo_l(N, L) nl_langinfo((N))
2074+#endif
2075+
2076+namespace std
2077+{
2078+ template<>
2079+ void
2080+ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
2081+ {
2082+ if (!_M_data)
2083+ _M_data = new __numpunct_cache<char>;
2084+
2085+ if (!__cloc)
2086+ {
2087+ // "C" locale
2088+ _M_data->_M_grouping = "";
2089+ _M_data->_M_grouping_size = 0;
2090+ _M_data->_M_use_grouping = false;
2091+
2092+ _M_data->_M_decimal_point = '.';
2093+ _M_data->_M_thousands_sep = ',';
2094+
2095+ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
2096+ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
2097+
2098+ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
2099+ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
2100+ }
2101+ else
2102+ {
2103+ // Named locale.
2104+ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
2105+ __cloc));
2106+ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
2107+ __cloc));
2108+
2109+ // Check for NULL, which implies no grouping.
2110+ if (_M_data->_M_thousands_sep == '\0')
2111+ _M_data->_M_grouping = "";
2112+ else
2113+ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
2114+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
2115+ }
2116+
2117+ // NB: There is no way to extact this info from posix locales.
2118+ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
2119+ _M_data->_M_truename = "true";
2120+ _M_data->_M_truename_size = 4;
2121+ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
2122+ _M_data->_M_falsename = "false";
2123+ _M_data->_M_falsename_size = 5;
2124+ }
2125+
2126+ template<>
2127+ numpunct<char>::~numpunct()
2128+ { delete _M_data; }
2129+
2130+#ifdef _GLIBCXX_USE_WCHAR_T
2131+ template<>
2132+ void
2133+ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
2134+ {
2135+ if (!_M_data)
2136+ _M_data = new __numpunct_cache<wchar_t>;
2137+
2138+ if (!__cloc)
2139+ {
2140+ // "C" locale
2141+ _M_data->_M_grouping = "";
2142+ _M_data->_M_grouping_size = 0;
2143+ _M_data->_M_use_grouping = false;
2144+
2145+ _M_data->_M_decimal_point = L'.';
2146+ _M_data->_M_thousands_sep = L',';
2147+
2148+ // Use ctype::widen code without the facet...
2149+ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
2150+ _M_data->_M_atoms_out[__i] =
2151+ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
2152+
2153+ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
2154+ _M_data->_M_atoms_in[__j] =
2155+ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
2156+ }
2157+ else
2158+ {
2159+ // Named locale.
2160+ // NB: In the GNU model wchar_t is always 32 bit wide.
2161+ union { char *__s; wchar_t __w; } __u;
2162+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
2163+ _M_data->_M_decimal_point = __u.__w;
2164+
2165+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
2166+ _M_data->_M_thousands_sep = __u.__w;
2167+
2168+ if (_M_data->_M_thousands_sep == L'\0')
2169+ _M_data->_M_grouping = "";
2170+ else
2171+ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
2172+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
2173+ }
2174+
2175+ // NB: There is no way to extact this info from posix locales.
2176+ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
2177+ _M_data->_M_truename = L"true";
2178+ _M_data->_M_truename_size = 4;
2179+ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
2180+ _M_data->_M_falsename = L"false";
2181+ _M_data->_M_falsename_size = 5;
2182+ }
2183+
2184+ template<>
2185+ numpunct<wchar_t>::~numpunct()
2186+ { delete _M_data; }
2187+ #endif
2188+}
2189--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
2190+++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
2191@@ -0,0 +1,406 @@
2192+// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
2193+
2194+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2195+//
2196+// This file is part of the GNU ISO C++ Library. This library is free
2197+// software; you can redistribute it and/or modify it under the
2198+// terms of the GNU General Public License as published by the
2199+// Free Software Foundation; either version 2, or (at your option)
2200+// any later version.
2201+
2202+// This library is distributed in the hope that it will be useful,
2203+// but WITHOUT ANY WARRANTY; without even the implied warranty of
2204+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2205+// GNU General Public License for more details.
2206+
2207+// You should have received a copy of the GNU General Public License along
2208+// with this library; see the file COPYING. If not, write to the Free
2209+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2210+// USA.
2211+
2212+// As a special exception, you may use this file as part of a free software
2213+// library without restriction. Specifically, if other files instantiate
2214+// templates or use macros or inline functions from this file, or you compile
2215+// this file and link it with other files to produce an executable, this
2216+// file does not by itself cause the resulting executable to be covered by
2217+// the GNU General Public License. This exception does not however
2218+// invalidate any other reasons why the executable file might be covered by
2219+// the GNU General Public License.
2220+
2221+//
2222+// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
2223+// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
2224+//
2225+
2226+// Written by Benjamin Kosnik <bkoz@redhat.com>
2227+
2228+#include <locale>
2229+#include <bits/c++locale_internal.h>
2230+
2231+#ifdef __UCLIBC_MJN3_ONLY__
2232+#warning tailor for stub locale support
2233+#endif
2234+#ifndef __UCLIBC_HAS_XLOCALE__
2235+#define __nl_langinfo_l(N, L) nl_langinfo((N))
2236+#endif
2237+
2238+namespace std
2239+{
2240+ template<>
2241+ void
2242+ __timepunct<char>::
2243+ _M_put(char* __s, size_t __maxlen, const char* __format,
2244+ const tm* __tm) const
2245+ {
2246+#ifdef __UCLIBC_HAS_XLOCALE__
2247+ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
2248+ _M_c_locale_timepunct);
2249+#else
2250+ char* __old = strdup(setlocale(LC_ALL, NULL));
2251+ setlocale(LC_ALL, _M_name_timepunct);
2252+ const size_t __len = strftime(__s, __maxlen, __format, __tm);
2253+ setlocale(LC_ALL, __old);
2254+ free(__old);
2255+#endif
2256+ // Make sure __s is null terminated.
2257+ if (__len == 0)
2258+ __s[0] = '\0';
2259+ }
2260+
2261+ template<>
2262+ void
2263+ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
2264+ {
2265+ if (!_M_data)
2266+ _M_data = new __timepunct_cache<char>;
2267+
2268+ if (!__cloc)
2269+ {
2270+ // "C" locale
2271+ _M_c_locale_timepunct = _S_get_c_locale();
2272+
2273+ _M_data->_M_date_format = "%m/%d/%y";
2274+ _M_data->_M_date_era_format = "%m/%d/%y";
2275+ _M_data->_M_time_format = "%H:%M:%S";
2276+ _M_data->_M_time_era_format = "%H:%M:%S";
2277+ _M_data->_M_date_time_format = "";
2278+ _M_data->_M_date_time_era_format = "";
2279+ _M_data->_M_am = "AM";
2280+ _M_data->_M_pm = "PM";
2281+ _M_data->_M_am_pm_format = "";
2282+
2283+ // Day names, starting with "C"'s Sunday.
2284+ _M_data->_M_day1 = "Sunday";
2285+ _M_data->_M_day2 = "Monday";
2286+ _M_data->_M_day3 = "Tuesday";
2287+ _M_data->_M_day4 = "Wednesday";
2288+ _M_data->_M_day5 = "Thursday";
2289+ _M_data->_M_day6 = "Friday";
2290+ _M_data->_M_day7 = "Saturday";
2291+
2292+ // Abbreviated day names, starting with "C"'s Sun.
2293+ _M_data->_M_aday1 = "Sun";
2294+ _M_data->_M_aday2 = "Mon";
2295+ _M_data->_M_aday3 = "Tue";
2296+ _M_data->_M_aday4 = "Wed";
2297+ _M_data->_M_aday5 = "Thu";
2298+ _M_data->_M_aday6 = "Fri";
2299+ _M_data->_M_aday7 = "Sat";
2300+
2301+ // Month names, starting with "C"'s January.
2302+ _M_data->_M_month01 = "January";
2303+ _M_data->_M_month02 = "February";
2304+ _M_data->_M_month03 = "March";
2305+ _M_data->_M_month04 = "April";
2306+ _M_data->_M_month05 = "May";
2307+ _M_data->_M_month06 = "June";
2308+ _M_data->_M_month07 = "July";
2309+ _M_data->_M_month08 = "August";
2310+ _M_data->_M_month09 = "September";
2311+ _M_data->_M_month10 = "October";
2312+ _M_data->_M_month11 = "November";
2313+ _M_data->_M_month12 = "December";
2314+
2315+ // Abbreviated month names, starting with "C"'s Jan.
2316+ _M_data->_M_amonth01 = "Jan";
2317+ _M_data->_M_amonth02 = "Feb";
2318+ _M_data->_M_amonth03 = "Mar";
2319+ _M_data->_M_amonth04 = "Apr";
2320+ _M_data->_M_amonth05 = "May";
2321+ _M_data->_M_amonth06 = "Jun";
2322+ _M_data->_M_amonth07 = "Jul";
2323+ _M_data->_M_amonth08 = "Aug";
2324+ _M_data->_M_amonth09 = "Sep";
2325+ _M_data->_M_amonth10 = "Oct";
2326+ _M_data->_M_amonth11 = "Nov";
2327+ _M_data->_M_amonth12 = "Dec";
2328+ }
2329+ else
2330+ {
2331+ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
2332+
2333+ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
2334+ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
2335+ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
2336+ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
2337+ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
2338+ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
2339+ __cloc);
2340+ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
2341+ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
2342+ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
2343+
2344+ // Day names, starting with "C"'s Sunday.
2345+ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
2346+ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
2347+ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
2348+ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
2349+ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
2350+ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
2351+ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
2352+
2353+ // Abbreviated day names, starting with "C"'s Sun.
2354+ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
2355+ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
2356+ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
2357+ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
2358+ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
2359+ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
2360+ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
2361+
2362+ // Month names, starting with "C"'s January.
2363+ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
2364+ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
2365+ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
2366+ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
2367+ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
2368+ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
2369+ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
2370+ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
2371+ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
2372+ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
2373+ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
2374+ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
2375+
2376+ // Abbreviated month names, starting with "C"'s Jan.
2377+ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
2378+ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
2379+ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
2380+ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
2381+ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
2382+ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
2383+ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
2384+ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
2385+ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
2386+ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
2387+ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
2388+ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
2389+ }
2390+ }
2391+
2392+#ifdef _GLIBCXX_USE_WCHAR_T
2393+ template<>
2394+ void
2395+ __timepunct<wchar_t>::
2396+ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
2397+ const tm* __tm) const
2398+ {
2399+#ifdef __UCLIBC_HAS_XLOCALE__
2400+ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
2401+ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
2402+ _M_c_locale_timepunct);
2403+#else
2404+ char* __old = strdup(setlocale(LC_ALL, NULL));
2405+ setlocale(LC_ALL, _M_name_timepunct);
2406+ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
2407+ setlocale(LC_ALL, __old);
2408+ free(__old);
2409+#endif
2410+ // Make sure __s is null terminated.
2411+ if (__len == 0)
2412+ __s[0] = L'\0';
2413+ }
2414+
2415+ template<>
2416+ void
2417+ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
2418+ {
2419+ if (!_M_data)
2420+ _M_data = new __timepunct_cache<wchar_t>;
2421+
2422+#warning wide time stuff
2423+// if (!__cloc)
2424+ {
2425+ // "C" locale
2426+ _M_c_locale_timepunct = _S_get_c_locale();
2427+
2428+ _M_data->_M_date_format = L"%m/%d/%y";
2429+ _M_data->_M_date_era_format = L"%m/%d/%y";
2430+ _M_data->_M_time_format = L"%H:%M:%S";
2431+ _M_data->_M_time_era_format = L"%H:%M:%S";
2432+ _M_data->_M_date_time_format = L"";
2433+ _M_data->_M_date_time_era_format = L"";
2434+ _M_data->_M_am = L"AM";
2435+ _M_data->_M_pm = L"PM";
2436+ _M_data->_M_am_pm_format = L"";
2437+
2438+ // Day names, starting with "C"'s Sunday.
2439+ _M_data->_M_day1 = L"Sunday";
2440+ _M_data->_M_day2 = L"Monday";
2441+ _M_data->_M_day3 = L"Tuesday";
2442+ _M_data->_M_day4 = L"Wednesday";
2443+ _M_data->_M_day5 = L"Thursday";
2444+ _M_data->_M_day6 = L"Friday";
2445+ _M_data->_M_day7 = L"Saturday";
2446+
2447+ // Abbreviated day names, starting with "C"'s Sun.
2448+ _M_data->_M_aday1 = L"Sun";
2449+ _M_data->_M_aday2 = L"Mon";
2450+ _M_data->_M_aday3 = L"Tue";
2451+ _M_data->_M_aday4 = L"Wed";
2452+ _M_data->_M_aday5 = L"Thu";
2453+ _M_data->_M_aday6 = L"Fri";
2454+ _M_data->_M_aday7 = L"Sat";
2455+
2456+ // Month names, starting with "C"'s January.
2457+ _M_data->_M_month01 = L"January";
2458+ _M_data->_M_month02 = L"February";
2459+ _M_data->_M_month03 = L"March";
2460+ _M_data->_M_month04 = L"April";
2461+ _M_data->_M_month05 = L"May";
2462+ _M_data->_M_month06 = L"June";
2463+ _M_data->_M_month07 = L"July";
2464+ _M_data->_M_month08 = L"August";
2465+ _M_data->_M_month09 = L"September";
2466+ _M_data->_M_month10 = L"October";
2467+ _M_data->_M_month11 = L"November";
2468+ _M_data->_M_month12 = L"December";
2469+
2470+ // Abbreviated month names, starting with "C"'s Jan.
2471+ _M_data->_M_amonth01 = L"Jan";
2472+ _M_data->_M_amonth02 = L"Feb";
2473+ _M_data->_M_amonth03 = L"Mar";
2474+ _M_data->_M_amonth04 = L"Apr";
2475+ _M_data->_M_amonth05 = L"May";
2476+ _M_data->_M_amonth06 = L"Jun";
2477+ _M_data->_M_amonth07 = L"Jul";
2478+ _M_data->_M_amonth08 = L"Aug";
2479+ _M_data->_M_amonth09 = L"Sep";
2480+ _M_data->_M_amonth10 = L"Oct";
2481+ _M_data->_M_amonth11 = L"Nov";
2482+ _M_data->_M_amonth12 = L"Dec";
2483+ }
2484+#if 0
2485+ else
2486+ {
2487+ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
2488+
2489+ union { char *__s; wchar_t *__w; } __u;
2490+
2491+ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
2492+ _M_data->_M_date_format = __u.__w;
2493+ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
2494+ _M_data->_M_date_era_format = __u.__w;
2495+ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
2496+ _M_data->_M_time_format = __u.__w;
2497+ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
2498+ _M_data->_M_time_era_format = __u.__w;
2499+ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
2500+ _M_data->_M_date_time_format = __u.__w;
2501+ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
2502+ _M_data->_M_date_time_era_format = __u.__w;
2503+ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
2504+ _M_data->_M_am = __u.__w;
2505+ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
2506+ _M_data->_M_pm = __u.__w;
2507+ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
2508+ _M_data->_M_am_pm_format = __u.__w;
2509+
2510+ // Day names, starting with "C"'s Sunday.
2511+ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
2512+ _M_data->_M_day1 = __u.__w;
2513+ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
2514+ _M_data->_M_day2 = __u.__w;
2515+ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
2516+ _M_data->_M_day3 = __u.__w;
2517+ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
2518+ _M_data->_M_day4 = __u.__w;
2519+ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
2520+ _M_data->_M_day5 = __u.__w;
2521+ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
2522+ _M_data->_M_day6 = __u.__w;
2523+ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
2524+ _M_data->_M_day7 = __u.__w;
2525+
2526+ // Abbreviated day names, starting with "C"'s Sun.
2527+ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
2528+ _M_data->_M_aday1 = __u.__w;
2529+ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
2530+ _M_data->_M_aday2 = __u.__w;
2531+ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
2532+ _M_data->_M_aday3 = __u.__w;
2533+ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
2534+ _M_data->_M_aday4 = __u.__w;
2535+ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
2536+ _M_data->_M_aday5 = __u.__w;
2537+ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
2538+ _M_data->_M_aday6 = __u.__w;
2539+ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
2540+ _M_data->_M_aday7 = __u.__w;
2541+
2542+ // Month names, starting with "C"'s January.
2543+ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
2544+ _M_data->_M_month01 = __u.__w;
2545+ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
2546+ _M_data->_M_month02 = __u.__w;
2547+ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
2548+ _M_data->_M_month03 = __u.__w;
2549+ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
2550+ _M_data->_M_month04 = __u.__w;
2551+ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
2552+ _M_data->_M_month05 = __u.__w;
2553+ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
2554+ _M_data->_M_month06 = __u.__w;
2555+ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
2556+ _M_data->_M_month07 = __u.__w;
2557+ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
2558+ _M_data->_M_month08 = __u.__w;
2559+ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
2560+ _M_data->_M_month09 = __u.__w;
2561+ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
2562+ _M_data->_M_month10 = __u.__w;
2563+ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
2564+ _M_data->_M_month11 = __u.__w;
2565+ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
2566+ _M_data->_M_month12 = __u.__w;
2567+
2568+ // Abbreviated month names, starting with "C"'s Jan.
2569+ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
2570+ _M_data->_M_amonth01 = __u.__w;
2571+ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
2572+ _M_data->_M_amonth02 = __u.__w;
2573+ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
2574+ _M_data->_M_amonth03 = __u.__w;
2575+ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
2576+ _M_data->_M_amonth04 = __u.__w;
2577+ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
2578+ _M_data->_M_amonth05 = __u.__w;
2579+ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
2580+ _M_data->_M_amonth06 = __u.__w;
2581+ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
2582+ _M_data->_M_amonth07 = __u.__w;
2583+ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
2584+ _M_data->_M_amonth08 = __u.__w;
2585+ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
2586+ _M_data->_M_amonth09 = __u.__w;
2587+ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
2588+ _M_data->_M_amonth10 = __u.__w;
2589+ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
2590+ _M_data->_M_amonth11 = __u.__w;
2591+ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
2592+ _M_data->_M_amonth12 = __u.__w;
2593+ }
2594+#endif // 0
2595+ }
2596+#endif
2597+}
2598--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h
2599+++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h
2600@@ -0,0 +1,68 @@
2601+// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
2602+
2603+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2604+//
2605+// This file is part of the GNU ISO C++ Library. This library is free
2606+// software; you can redistribute it and/or modify it under the
2607+// terms of the GNU General Public License as published by the
2608+// Free Software Foundation; either version 2, or (at your option)
2609+// any later version.
2610+
2611+// This library is distributed in the hope that it will be useful,
2612+// but WITHOUT ANY WARRANTY; without even the implied warranty of
2613+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2614+// GNU General Public License for more details.
2615+
2616+// You should have received a copy of the GNU General Public License along
2617+// with this library; see the file COPYING. If not, write to the Free
2618+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2619+// USA.
2620+
2621+// As a special exception, you may use this file as part of a free software
2622+// library without restriction. Specifically, if other files instantiate
2623+// templates or use macros or inline functions from this file, or you compile
2624+// this file and link it with other files to produce an executable, this
2625+// file does not by itself cause the resulting executable to be covered by
2626+// the GNU General Public License. This exception does not however
2627+// invalidate any other reasons why the executable file might be covered by
2628+// the GNU General Public License.
2629+
2630+//
2631+// ISO C++ 14882: 22.2.5.1.2 - time_get functions
2632+// ISO C++ 14882: 22.2.5.3.2 - time_put functions
2633+//
2634+
2635+// Written by Benjamin Kosnik <bkoz@redhat.com>
2636+
2637+ template<typename _CharT>
2638+ __timepunct<_CharT>::__timepunct(size_t __refs)
2639+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
2640+ _M_name_timepunct(_S_get_c_name())
2641+ { _M_initialize_timepunct(); }
2642+
2643+ template<typename _CharT>
2644+ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
2645+ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
2646+ _M_name_timepunct(_S_get_c_name())
2647+ { _M_initialize_timepunct(); }
2648+
2649+ template<typename _CharT>
2650+ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
2651+ size_t __refs)
2652+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
2653+ _M_name_timepunct(__s)
2654+ {
2655+ char* __tmp = new char[std::strlen(__s) + 1];
2656+ std::strcpy(__tmp, __s);
2657+ _M_name_timepunct = __tmp;
2658+ _M_initialize_timepunct(__cloc);
2659+ }
2660+
2661+ template<typename _CharT>
2662+ __timepunct<_CharT>::~__timepunct()
2663+ {
2664+ if (_M_name_timepunct != _S_get_c_name())
2665+ delete [] _M_name_timepunct;
2666+ delete _M_data;
2667+ _S_destroy_c_locale(_M_c_locale_timepunct);
2668+ }
2669--- gcc/libstdc++-v3/configure
2670+++ gcc/libstdc++-v3/configure
2671@@ -5764,7 +5764,7 @@
2672 enableval="$enable_clocale"
2673
2674 case "$enableval" in
2675- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
2676+ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
2677 *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
2678 echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
2679 { (exit 1); exit 1; }; } ;;
2680@@ -5789,6 +5789,9 @@
2681 # Default to "generic".
2682 if test $enable_clocale_flag = auto; then
2683 case ${target_os} in
2684+ linux-uclibc*)
2685+ enable_clocale_flag=uclibc
2686+ ;;
2687 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
2688 cat >conftest.$ac_ext <<_ACEOF
2689 /* confdefs.h. */
2690@@ -6019,6 +6022,76 @@
2691 CTIME_CC=config/locale/generic/time_members.cc
2692 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2693 ;;
2694+ uclibc)
2695+ echo "$as_me:$LINENO: result: uclibc" >&5
2696+echo "${ECHO_T}uclibc" >&6
2697+
2698+ # Declare intention to use gettext, and add support for specific
2699+ # languages.
2700+ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
2701+ ALL_LINGUAS="de fr"
2702+
2703+ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
2704+ # Extract the first word of "msgfmt", so it can be a program name with args.
2705+set dummy msgfmt; ac_word=$2
2706+echo "$as_me:$LINENO: checking for $ac_word" >&5
2707+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
2708+if test "${ac_cv_prog_check_msgfmt+set}" = set; then
2709+ echo $ECHO_N "(cached) $ECHO_C" >&6
2710+else
2711+ if test -n "$check_msgfmt"; then
2712+ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
2713+else
2714+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2715+for as_dir in $PATH
2716+do
2717+ IFS=$as_save_IFS
2718+ test -z "$as_dir" && as_dir=.
2719+ for ac_exec_ext in '' $ac_executable_extensions; do
2720+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2721+ ac_cv_prog_check_msgfmt="yes"
2722+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2723+ break 2
2724+ fi
2725+done
2726+done
2727+
2728+ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
2729+fi
2730+fi
2731+check_msgfmt=$ac_cv_prog_check_msgfmt
2732+if test -n "$check_msgfmt"; then
2733+ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
2734+echo "${ECHO_T}$check_msgfmt" >&6
2735+else
2736+ echo "$as_me:$LINENO: result: no" >&5
2737+echo "${ECHO_T}no" >&6
2738+fi
2739+
2740+ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
2741+ USE_NLS=yes
2742+ fi
2743+ # Export the build objects.
2744+ for ling in $ALL_LINGUAS; do \
2745+ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
2746+ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
2747+ done
2748+
2749+
2750+
2751+ CLOCALE_H=config/locale/uclibc/c_locale.h
2752+ CLOCALE_CC=config/locale/uclibc/c_locale.cc
2753+ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
2754+ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
2755+ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
2756+ CMESSAGES_H=config/locale/uclibc/messages_members.h
2757+ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
2758+ CMONEY_CC=config/locale/uclibc/monetary_members.cc
2759+ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
2760+ CTIME_H=config/locale/uclibc/time_members.h
2761+ CTIME_CC=config/locale/uclibc/time_members.cc
2762+ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
2763+ ;;
2764 esac
2765
2766 # This is where the testsuite looks for locale catalogs, using the
2767--- gcc/libstdc++-v3/include/c_compatibility/wchar.h
2768+++ gcc/libstdc++-v3/include/c_compatibility/wchar.h
2769@@ -101,7 +101,9 @@
2770 using std::wmemcpy;
2771 using std::wmemmove;
2772 using std::wmemset;
2773+#if _GLIBCXX_HAVE_WCSFTIME
2774 using std::wcsftime;
2775+#endif
2776
2777 #if _GLIBCXX_USE_C99
2778 using std::wcstold;
2779--- gcc/libstdc++-v3/include/c_std/std_cwchar.h
2780+++ gcc/libstdc++-v3/include/c_std/std_cwchar.h
2781@@ -182,7 +182,9 @@
2782 using ::wcscoll;
2783 using ::wcscpy;
2784 using ::wcscspn;
2785+#if _GLIBCXX_HAVE_WCSFTIME
2786 using ::wcsftime;
2787+#endif
2788 using ::wcslen;
2789 using ::wcsncat;
2790 using ::wcsncmp;