Third go at renaming patches to contain neither the package name nor the package version.
1 Original patch from gentoo: gentoo/src/patchsets/gcc/4.3.1/uclibc/90_all_205-uclibc-locale-update.patch
2 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc
3 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-06-10 14:58:47.000000000 +0200
4 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-06-10 14:58:51.000000000 +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 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.h gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h
87 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-06-10 14:58:47.000000000 +0200
88 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-06-10 14:58:51.000000000 +0200
90 #pragma GCC system_header
92 #include <cstring> // get std::strlen
93 -#include <cstdio> // get std::snprintf or std::sprintf
94 +#include <cstdio> // get std::vsnprintf or std::vsprintf
96 #include <langinfo.h> // For codecvt
97 #ifdef __UCLIBC_MJN3_ONLY__
100 -#ifdef __UCLIBC_HAS_LOCALE__
101 +#ifdef _GLIBCXX_USE_ICONV
102 #include <iconv.h> // For codecvt using iconv, iconv_t
104 -#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
105 -#include <libintl.h> // For messages
106 +#ifdef HAVE_LIBINTL_H
107 +#include <libintl.h> // For messages
111 #ifdef __UCLIBC_MJN3_ONLY__
112 #warning what is _GLIBCXX_C_LOCALE_GNU for
113 +// psm: used in os/gnu-linux/ctype_noninline.h
115 #define _GLIBCXX_C_LOCALE_GNU 1
119 // #define _GLIBCXX_NUM_CATEGORIES 6
120 #define _GLIBCXX_NUM_CATEGORIES 0
123 #ifdef __UCLIBC_HAS_XLOCALE__
127 typedef int* __c_locale;
130 - // Convert numeric value of type _Tv to string and return length of
131 - // string. If snprintf is available use it, otherwise fall back to
132 - // the unsafe sprintf which, in general, can be dangerous and should
133 + // Convert numeric value of type double to string and return length of
134 + // string. If vsnprintf is available use it, otherwise fall back to
135 + // the unsafe vsprintf which, in general, can be dangerous and should
137 - template<typename _Tv>
139 - __convert_from_v(char* __out,
140 - const int __size __attribute__ ((__unused__)),
142 -#ifdef __UCLIBC_HAS_XCLOCALE__
143 - _Tv __v, const __c_locale& __cloc, int __prec)
145 + __convert_from_v(const __c_locale&
146 +#ifndef __UCLIBC_HAS_XCLOCALE__
147 + __cloc __attribute__ ((__unused__))
152 + const char* __fmt, ...)
155 +#ifdef __UCLIBC_HAS_XCLOCALE__
156 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
158 - _Tv __v, const __c_locale&, int __prec)
160 # ifdef __UCLIBC_HAS_LOCALE__
161 char* __old = std::setlocale(LC_ALL, NULL);
162 char* __sav = new char[std::strlen(__old) + 1];
167 - const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
168 + va_start(__args, __fmt);
169 + const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
172 #ifdef __UCLIBC_HAS_XCLOCALE__
173 __gnu_cxx::__uselocale(__old);
174 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc
175 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-06-10 14:58:47.000000000 +0200
176 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-06-10 14:58:51.000000000 +0200
179 // Written by Benjamin Kosnik <bkoz@redhat.com>
181 +#include <features.h>
182 +#ifdef __UCLIBC_HAS_LOCALE__
189 #include <bits/c++locale_internal.h>
192 @@ -138,20 +143,34 @@
194 do_is(mask __m, wchar_t __c) const
196 - // Highest bitmask in ctype_base == 10, but extra in "C"
197 - // library for blank.
198 + // The case of __m == ctype_base::space is particularly important,
199 + // due to its use in many istream functions. Therefore we deal with
200 + // it first, exploiting the knowledge that on GNU systems _M_bit[5]
201 + // is the mask corresponding to ctype_base::space. NB: an encoding
202 + // change would not affect correctness!
204 - const size_t __bitmasksize = 11;
205 - for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
206 - if (__m & _M_bit[__bitcur]
207 - && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
212 + if (__m == _M_bit[5])
213 + __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
216 + // Highest bitmask in ctype_base == 10, but extra in "C"
217 + // library for blank.
218 + const size_t __bitmasksize = 11;
219 + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
220 + if (__m & _M_bit[__bitcur])
222 + if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
227 + else if (__m == _M_bit[__bitcur])
237 do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
238 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/messages_members.h gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h
239 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-06-10 14:58:47.000000000 +0200
240 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-06-10 14:58:51.000000000 +0200
242 template<typename _CharT>
243 messages<_CharT>::messages(size_t __refs)
244 : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
245 - _M_name_messages(_S_get_c_name())
246 + _M_name_messages(_S_get_c_name())
249 template<typename _CharT>
250 messages<_CharT>::messages(__c_locale __cloc, const char* __s,
252 - : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
253 - _M_name_messages(__s)
254 + : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
256 - char* __tmp = new char[std::strlen(__s) + 1];
257 - std::strcpy(__tmp, __s);
258 + const size_t __len = std::strlen(__s) + 1;
259 + char* __tmp = new char[__len];
260 + std::memcpy(__tmp, __s, __len);
261 _M_name_messages = __tmp;
263 + // Last to avoid leaking memory if new throws.
264 + _M_c_locale_messages = _S_clone_c_locale(__cloc);
267 template<typename _CharT>
268 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc
269 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-06-10 14:58:51.000000000 +0200
270 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-06-10 14:58:51.000000000 +0200
273 // Written by Benjamin Kosnik <bkoz@redhat.com>
275 +#include <features.h>
276 +#ifdef __UCLIBC_HAS_LOCALE__
283 #include <bits/c++locale_internal.h>
285 #ifdef __UCLIBC_MJN3_ONLY__
295 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc
296 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-06-10 14:58:51.000000000 +0200
297 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-06-10 14:58:51.000000000 +0200
300 // Written by Benjamin Kosnik <bkoz@redhat.com>
302 +#include <features.h>
303 +#ifdef __UCLIBC_HAS_LOCALE__
310 #include <bits/c++locale_internal.h>
312 #ifdef __UCLIBC_MJN3_ONLY__
313 diff -durN gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/time_members.h gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.h
314 --- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2008-06-10 14:58:43.000000000 +0200
315 +++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.h 2008-06-10 14:58:51.000000000 +0200
317 template<typename _CharT>
318 __timepunct<_CharT>::__timepunct(size_t __refs)
319 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
320 - _M_name_timepunct(_S_get_c_name())
321 + _M_name_timepunct(_S_get_c_name())
322 { _M_initialize_timepunct(); }
324 template<typename _CharT>
325 __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
326 : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
327 - _M_name_timepunct(_S_get_c_name())
328 + _M_name_timepunct(_S_get_c_name())
329 { _M_initialize_timepunct(); }
331 template<typename _CharT>
332 __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
334 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
335 - _M_name_timepunct(__s)
336 + _M_name_timepunct(NULL)
338 - char* __tmp = new char[std::strlen(__s) + 1];
339 - std::strcpy(__tmp, __s);
340 + const size_t __len = std::strlen(__s) + 1;
341 + char* __tmp = new char[__len];
342 + std::memcpy(__tmp, __s, __len);
343 _M_name_timepunct = __tmp;
344 - _M_initialize_timepunct(__cloc);
347 + { _M_initialize_timepunct(__cloc); }
350 + delete [] _M_name_timepunct;
351 + __throw_exception_again;
355 template<typename _CharT>