1 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/c_locale.cc
2 ===================================================================
3 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-05-21 13:45:45.253289024 +0200
4 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-05-21 13:45:46.729290157 +0200
6 __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
7 const __c_locale& __cloc)
9 - if (!(__err & ios_base::failbit))
13 - float __f = __strtof_l(__s, &__sanity, __cloc);
14 - if (__sanity != __s && errno != ERANGE)
17 - __err |= ios_base::failbit;
21 + float __f = __strtof_l(__s, &__sanity, __cloc);
22 + if (__sanity != __s && errno != ERANGE)
25 + __err |= ios_base::failbit;
30 __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
31 const __c_locale& __cloc)
33 - if (!(__err & ios_base::failbit))
37 - double __d = __strtod_l(__s, &__sanity, __cloc);
38 - if (__sanity != __s && errno != ERANGE)
41 - __err |= ios_base::failbit;
45 + double __d = __strtod_l(__s, &__sanity, __cloc);
46 + if (__sanity != __s && errno != ERANGE)
49 + __err |= ios_base::failbit;
54 __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
55 const __c_locale& __cloc)
57 - if (!(__err & ios_base::failbit))
61 - long double __ld = __strtold_l(__s, &__sanity, __cloc);
62 - if (__sanity != __s && errno != ERANGE)
65 - __err |= ios_base::failbit;
69 + long double __ld = __strtold_l(__s, &__sanity, __cloc);
70 + if (__sanity != __s && errno != ERANGE)
73 + __err |= ios_base::failbit;
79 locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
81 - if (_S_get_c_locale() != __cloc)
82 + if (__cloc && _S_get_c_locale() != __cloc)
86 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/ctype_members.cc
87 ===================================================================
88 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-05-21 13:45:45.257288137 +0200
89 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-05-21 13:45:46.729290157 +0200
92 // Written by Benjamin Kosnik <bkoz@redhat.com>
94 +#include <features.h>
95 +#ifdef __UCLIBC_HAS_LOCALE__
102 #include <bits/c++locale_internal.h>
105 @@ -138,20 +143,34 @@
107 do_is(mask __m, wchar_t __c) const
109 - // Highest bitmask in ctype_base == 10, but extra in "C"
110 - // library for blank.
111 + // The case of __m == ctype_base::space is particularly important,
112 + // due to its use in many istream functions. Therefore we deal with
113 + // it first, exploiting the knowledge that on GNU systems _M_bit[5]
114 + // is the mask corresponding to ctype_base::space. NB: an encoding
115 + // change would not affect correctness!
117 - const size_t __bitmasksize = 11;
118 - for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
119 - if (__m & _M_bit[__bitcur]
120 - && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
125 + if (__m == _M_bit[5])
126 + __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
129 + // Highest bitmask in ctype_base == 10, but extra in "C"
130 + // library for blank.
131 + const size_t __bitmasksize = 11;
132 + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
133 + if (__m & _M_bit[__bitcur])
135 + if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
140 + else if (__m == _M_bit[__bitcur])
150 do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
151 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/messages_members.h
152 ===================================================================
153 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-05-21 13:45:45.257288137 +0200
154 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-05-21 13:45:46.729290157 +0200
156 template<typename _CharT>
157 messages<_CharT>::messages(size_t __refs)
158 : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
159 - _M_name_messages(_S_get_c_name())
160 + _M_name_messages(_S_get_c_name())
163 template<typename _CharT>
164 messages<_CharT>::messages(__c_locale __cloc, const char* __s,
166 - : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
167 - _M_name_messages(__s)
168 + : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
170 - char* __tmp = new char[std::strlen(__s) + 1];
171 - std::strcpy(__tmp, __s);
172 + const size_t __len = std::strlen(__s) + 1;
173 + char* __tmp = new char[__len];
174 + std::memcpy(__tmp, __s, __len);
175 _M_name_messages = __tmp;
177 + // Last to avoid leaking memory if new throws.
178 + _M_c_locale_messages = _S_clone_c_locale(__cloc);
181 template<typename _CharT>
182 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/monetary_members.cc
183 ===================================================================
184 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-05-21 13:45:46.105290284 +0200
185 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-05-21 13:45:46.729290157 +0200
188 // Written by Benjamin Kosnik <bkoz@redhat.com>
190 +#include <features.h>
191 +#ifdef __UCLIBC_HAS_LOCALE__
198 #include <bits/c++locale_internal.h>
200 #ifdef __UCLIBC_MJN3_ONLY__
210 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/numeric_members.cc
211 ===================================================================
212 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-05-21 13:45:46.105290284 +0200
213 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-05-21 13:45:46.733288711 +0200
216 // Written by Benjamin Kosnik <bkoz@redhat.com>
218 +#include <features.h>
219 +#ifdef __UCLIBC_HAS_LOCALE__
226 #include <bits/c++locale_internal.h>
228 #ifdef __UCLIBC_MJN3_ONLY__
229 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/time_members.h
230 ===================================================================
231 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2008-05-21 13:45:43.933287929 +0200
232 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/time_members.h 2008-05-21 13:45:46.733288711 +0200
234 template<typename _CharT>
235 __timepunct<_CharT>::__timepunct(size_t __refs)
236 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
237 - _M_name_timepunct(_S_get_c_name())
238 + _M_name_timepunct(_S_get_c_name())
239 { _M_initialize_timepunct(); }
241 template<typename _CharT>
242 __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
243 : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
244 - _M_name_timepunct(_S_get_c_name())
245 + _M_name_timepunct(_S_get_c_name())
246 { _M_initialize_timepunct(); }
248 template<typename _CharT>
249 __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
251 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
252 - _M_name_timepunct(__s)
253 + _M_name_timepunct(NULL)
255 - char* __tmp = new char[std::strlen(__s) + 1];
256 - std::strcpy(__tmp, __s);
257 + const size_t __len = std::strlen(__s) + 1;
258 + char* __tmp = new char[__len];
259 + std::memcpy(__tmp, __s, __len);
260 _M_name_timepunct = __tmp;
261 - _M_initialize_timepunct(__cloc);
264 + { _M_initialize_timepunct(__cloc); }
267 + delete [] _M_name_timepunct;
268 + __throw_exception_again;
272 template<typename _CharT>
273 Index: gcc-4.2.3/libstdc++-v3/config/locale/uclibc/c_locale.h
274 ===================================================================
275 --- gcc-4.2.3.orig/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-05-21 13:45:45.257288137 +0200
276 +++ gcc-4.2.3/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-05-21 13:45:46.733288711 +0200
278 #pragma GCC system_header
280 #include <cstring> // get std::strlen
281 -#include <cstdio> // get std::snprintf or std::sprintf
282 +#include <cstdio> // get std::vsnprintf or std::vsprintf
284 #include <langinfo.h> // For codecvt
285 #ifdef __UCLIBC_MJN3_ONLY__
288 -#ifdef __UCLIBC_HAS_LOCALE__
289 +#ifdef _GLIBCXX_USE_ICONV
290 #include <iconv.h> // For codecvt using iconv, iconv_t
292 -#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
293 -#include <libintl.h> // For messages
294 +#ifdef HAVE_LIBINTL_H
295 +#include <libintl.h> // For messages
299 #ifdef __UCLIBC_MJN3_ONLY__
300 #warning what is _GLIBCXX_C_LOCALE_GNU for
301 +// psm: used in os/gnu-linux/ctype_noninline.h
303 #define _GLIBCXX_C_LOCALE_GNU 1
307 // #define _GLIBCXX_NUM_CATEGORIES 6
308 #define _GLIBCXX_NUM_CATEGORIES 0
311 #ifdef __UCLIBC_HAS_XLOCALE__
315 typedef int* __c_locale;
318 - // Convert numeric value of type _Tv to string and return length of
319 - // string. If snprintf is available use it, otherwise fall back to
320 - // the unsafe sprintf which, in general, can be dangerous and should
321 + // Convert numeric value of type double to string and return length of
322 + // string. If vsnprintf is available use it, otherwise fall back to
323 + // the unsafe vsprintf which, in general, can be dangerous and should
325 - template<typename _Tv>
327 - __convert_from_v(char* __out,
328 - const int __size __attribute__ ((__unused__)),
330 -#ifdef __UCLIBC_HAS_XCLOCALE__
331 - _Tv __v, const __c_locale& __cloc, int __prec)
333 + __convert_from_v(const __c_locale&
334 +#ifndef __UCLIBC_HAS_XCLOCALE__
335 + __cloc __attribute__ ((__unused__))
340 + const char* __fmt, ...)
343 +#ifdef __UCLIBC_HAS_XCLOCALE__
344 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
346 - _Tv __v, const __c_locale&, int __prec)
348 # ifdef __UCLIBC_HAS_LOCALE__
349 char* __old = std::setlocale(LC_ALL, NULL);
350 char* __sav = new char[std::strlen(__old) + 1];
355 - const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
356 + va_start(__args, __fmt);
357 + const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
360 #ifdef __UCLIBC_HAS_XCLOCALE__
361 __gnu_cxx::__uselocale(__old);