update kernel from 2.6.32.7 to 2.6.32.8, thanks tripolar
[openwrt.git] / toolchain / gcc / patches / 4.2.4 / 205-uclibc-locale-update.patch
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
5 @@ -46,16 +46,13 @@
6 __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
7 const __c_locale& __cloc)
8 {
9 - if (!(__err & ios_base::failbit))
10 - {
11 - char* __sanity;
12 - errno = 0;
13 - float __f = __strtof_l(__s, &__sanity, __cloc);
14 - if (__sanity != __s && errno != ERANGE)
15 - __v = __f;
16 - else
17 - __err |= ios_base::failbit;
18 - }
19 + char* __sanity;
20 + errno = 0;
21 + float __f = __strtof_l(__s, &__sanity, __cloc);
22 + if (__sanity != __s && errno != ERANGE)
23 + __v = __f;
24 + else
25 + __err |= ios_base::failbit;
26 }
27
28 template<>
29 @@ -63,16 +60,13 @@
30 __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
31 const __c_locale& __cloc)
32 {
33 - if (!(__err & ios_base::failbit))
34 - {
35 - char* __sanity;
36 - errno = 0;
37 - double __d = __strtod_l(__s, &__sanity, __cloc);
38 - if (__sanity != __s && errno != ERANGE)
39 - __v = __d;
40 - else
41 - __err |= ios_base::failbit;
42 - }
43 + char* __sanity;
44 + errno = 0;
45 + double __d = __strtod_l(__s, &__sanity, __cloc);
46 + if (__sanity != __s && errno != ERANGE)
47 + __v = __d;
48 + else
49 + __err |= ios_base::failbit;
50 }
51
52 template<>
53 @@ -80,16 +74,13 @@
54 __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
55 const __c_locale& __cloc)
56 {
57 - if (!(__err & ios_base::failbit))
58 - {
59 - char* __sanity;
60 - errno = 0;
61 - long double __ld = __strtold_l(__s, &__sanity, __cloc);
62 - if (__sanity != __s && errno != ERANGE)
63 - __v = __ld;
64 - else
65 - __err |= ios_base::failbit;
66 - }
67 + char* __sanity;
68 + errno = 0;
69 + long double __ld = __strtold_l(__s, &__sanity, __cloc);
70 + if (__sanity != __s && errno != ERANGE)
71 + __v = __ld;
72 + else
73 + __err |= ios_base::failbit;
74 }
75
76 void
77 @@ -110,7 +101,7 @@
78 void
79 locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
80 {
81 - if (_S_get_c_locale() != __cloc)
82 + if (__cloc && _S_get_c_locale() != __cloc)
83 __freelocale(__cloc);
84 }
85
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
90 @@ -33,9 +33,14 @@
91
92 // Written by Benjamin Kosnik <bkoz@redhat.com>
93
94 +#include <features.h>
95 +#ifdef __UCLIBC_HAS_LOCALE__
96 #define _LIBC
97 #include <locale>
98 #undef _LIBC
99 +#else
100 +#include <locale>
101 +#endif
102 #include <bits/c++locale_internal.h>
103
104 namespace std
105 @@ -138,20 +143,34 @@
106 ctype<wchar_t>::
107 do_is(mask __m, wchar_t __c) const
108 {
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!
116 bool __ret = false;
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))
121 - {
122 - __ret = true;
123 - break;
124 - }
125 + if (__m == _M_bit[5])
126 + __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
127 + else
128 + {
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])
134 + {
135 + if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
136 + {
137 + __ret = true;
138 + break;
139 + }
140 + else if (__m == _M_bit[__bitcur])
141 + break;
142 + }
143 + }
144 return __ret;
145 }
146 -
147 +
148 const wchar_t*
149 ctype<wchar_t>::
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
155 @@ -47,18 +47,21 @@
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())
161 { }
162
163 template<typename _CharT>
164 messages<_CharT>::messages(__c_locale __cloc, const char* __s,
165 size_t __refs)
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)
169 {
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;
176 +
177 + // Last to avoid leaking memory if new throws.
178 + _M_c_locale_messages = _S_clone_c_locale(__cloc);
179 }
180
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
186 @@ -33,9 +33,14 @@
187
188 // Written by Benjamin Kosnik <bkoz@redhat.com>
189
190 +#include <features.h>
191 +#ifdef __UCLIBC_HAS_LOCALE__
192 #define _LIBC
193 #include <locale>
194 #undef _LIBC
195 +#else
196 +#include <locale>
197 +#endif
198 #include <bits/c++locale_internal.h>
199
200 #ifdef __UCLIBC_MJN3_ONLY__
201 @@ -206,7 +211,7 @@
202 }
203 break;
204 default:
205 - ;
206 + __ret = pattern();
207 }
208 return __ret;
209 }
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
214 @@ -33,9 +33,14 @@
215
216 // Written by Benjamin Kosnik <bkoz@redhat.com>
217
218 +#include <features.h>
219 +#ifdef __UCLIBC_HAS_LOCALE__
220 #define _LIBC
221 #include <locale>
222 #undef _LIBC
223 +#else
224 +#include <locale>
225 +#endif
226 #include <bits/c++locale_internal.h>
227
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
233 @@ -37,25 +37,33 @@
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(); }
240
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(); }
247
248 template<typename _CharT>
249 __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
250 size_t __refs)
251 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
252 - _M_name_timepunct(__s)
253 + _M_name_timepunct(NULL)
254 {
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);
262 +
263 + try
264 + { _M_initialize_timepunct(__cloc); }
265 + catch(...)
266 + {
267 + delete [] _M_name_timepunct;
268 + __throw_exception_again;
269 + }
270 }
271
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
277 @@ -39,21 +39,23 @@
278 #pragma GCC system_header
279
280 #include <cstring> // get std::strlen
281 -#include <cstdio> // get std::snprintf or std::sprintf
282 +#include <cstdio> // get std::vsnprintf or std::vsprintf
283 #include <clocale>
284 #include <langinfo.h> // For codecvt
285 #ifdef __UCLIBC_MJN3_ONLY__
286 #warning fix this
287 #endif
288 -#ifdef __UCLIBC_HAS_LOCALE__
289 +#ifdef _GLIBCXX_USE_ICONV
290 #include <iconv.h> // For codecvt using iconv, iconv_t
291 #endif
292 -#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
293 -#include <libintl.h> // For messages
294 +#ifdef HAVE_LIBINTL_H
295 +#include <libintl.h> // For messages
296 #endif
297 +#include <cstdarg>
298
299 #ifdef __UCLIBC_MJN3_ONLY__
300 #warning what is _GLIBCXX_C_LOCALE_GNU for
301 +// psm: used in os/gnu-linux/ctype_noninline.h
302 #endif
303 #define _GLIBCXX_C_LOCALE_GNU 1
304
305 @@ -62,7 +64,7 @@
306 #endif
307 // #define _GLIBCXX_NUM_CATEGORIES 6
308 #define _GLIBCXX_NUM_CATEGORIES 0
309 -
310 +
311 #ifdef __UCLIBC_HAS_XLOCALE__
312 namespace __gnu_cxx
313 {
314 @@ -79,22 +81,24 @@
315 typedef int* __c_locale;
316 #endif
317
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
324 // be avoided.
325 - template<typename _Tv>
326 - int
327 - __convert_from_v(char* __out,
328 - const int __size __attribute__ ((__unused__)),
329 - const char* __fmt,
330 -#ifdef __UCLIBC_HAS_XCLOCALE__
331 - _Tv __v, const __c_locale& __cloc, int __prec)
332 + inline int
333 + __convert_from_v(const __c_locale&
334 +#ifndef __UCLIBC_HAS_XCLOCALE__
335 + __cloc __attribute__ ((__unused__))
336 +#endif
337 + ,
338 + char* __out,
339 + const int __size,
340 + const char* __fmt, ...)
341 {
342 + va_list __args;
343 +#ifdef __UCLIBC_HAS_XCLOCALE__
344 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
345 #else
346 - _Tv __v, const __c_locale&, int __prec)
347 - {
348 # ifdef __UCLIBC_HAS_LOCALE__
349 char* __old = std::setlocale(LC_ALL, NULL);
350 char* __sav = new char[std::strlen(__old) + 1];
351 @@ -103,7 +107,9 @@
352 # endif
353 #endif
354
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);
358 + va_end(__args);
359
360 #ifdef __UCLIBC_HAS_XCLOCALE__
361 __gnu_cxx::__uselocale(__old);
This page took 0.058708 seconds and 5 git commands to generate.