1.1 --- a/patches/gcc/4.3.1/600-uclibc-locale-update.patch Mon Jul 28 21:08:01 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,355 +0,0 @@
1.4 -Original patch from gentoo: gentoo/src/patchsets/gcc/4.3.1/uclibc/90_all_205-uclibc-locale-update.patch
1.5 -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
1.6 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-06-10 14:58:47.000000000 +0200
1.7 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-06-10 14:58:51.000000000 +0200
1.8 -@@ -46,16 +46,13 @@
1.9 - __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
1.10 - const __c_locale& __cloc)
1.11 - {
1.12 -- if (!(__err & ios_base::failbit))
1.13 -- {
1.14 -- char* __sanity;
1.15 -- errno = 0;
1.16 -- float __f = __strtof_l(__s, &__sanity, __cloc);
1.17 -- if (__sanity != __s && errno != ERANGE)
1.18 -- __v = __f;
1.19 -- else
1.20 -- __err |= ios_base::failbit;
1.21 -- }
1.22 -+ char* __sanity;
1.23 -+ errno = 0;
1.24 -+ float __f = __strtof_l(__s, &__sanity, __cloc);
1.25 -+ if (__sanity != __s && errno != ERANGE)
1.26 -+ __v = __f;
1.27 -+ else
1.28 -+ __err |= ios_base::failbit;
1.29 - }
1.30 -
1.31 - template<>
1.32 -@@ -63,16 +60,13 @@
1.33 - __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
1.34 - const __c_locale& __cloc)
1.35 - {
1.36 -- if (!(__err & ios_base::failbit))
1.37 -- {
1.38 -- char* __sanity;
1.39 -- errno = 0;
1.40 -- double __d = __strtod_l(__s, &__sanity, __cloc);
1.41 -- if (__sanity != __s && errno != ERANGE)
1.42 -- __v = __d;
1.43 -- else
1.44 -- __err |= ios_base::failbit;
1.45 -- }
1.46 -+ char* __sanity;
1.47 -+ errno = 0;
1.48 -+ double __d = __strtod_l(__s, &__sanity, __cloc);
1.49 -+ if (__sanity != __s && errno != ERANGE)
1.50 -+ __v = __d;
1.51 -+ else
1.52 -+ __err |= ios_base::failbit;
1.53 - }
1.54 -
1.55 - template<>
1.56 -@@ -80,16 +74,13 @@
1.57 - __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
1.58 - const __c_locale& __cloc)
1.59 - {
1.60 -- if (!(__err & ios_base::failbit))
1.61 -- {
1.62 -- char* __sanity;
1.63 -- errno = 0;
1.64 -- long double __ld = __strtold_l(__s, &__sanity, __cloc);
1.65 -- if (__sanity != __s && errno != ERANGE)
1.66 -- __v = __ld;
1.67 -- else
1.68 -- __err |= ios_base::failbit;
1.69 -- }
1.70 -+ char* __sanity;
1.71 -+ errno = 0;
1.72 -+ long double __ld = __strtold_l(__s, &__sanity, __cloc);
1.73 -+ if (__sanity != __s && errno != ERANGE)
1.74 -+ __v = __ld;
1.75 -+ else
1.76 -+ __err |= ios_base::failbit;
1.77 - }
1.78 -
1.79 - void
1.80 -@@ -110,7 +101,7 @@
1.81 - void
1.82 - locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
1.83 - {
1.84 -- if (_S_get_c_locale() != __cloc)
1.85 -+ if (__cloc && _S_get_c_locale() != __cloc)
1.86 - __freelocale(__cloc);
1.87 - }
1.88 -
1.89 -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
1.90 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-06-10 14:58:47.000000000 +0200
1.91 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-06-10 14:58:51.000000000 +0200
1.92 -@@ -39,21 +39,23 @@
1.93 - #pragma GCC system_header
1.94 -
1.95 - #include <cstring> // get std::strlen
1.96 --#include <cstdio> // get std::snprintf or std::sprintf
1.97 -+#include <cstdio> // get std::vsnprintf or std::vsprintf
1.98 - #include <clocale>
1.99 - #include <langinfo.h> // For codecvt
1.100 - #ifdef __UCLIBC_MJN3_ONLY__
1.101 - #warning fix this
1.102 - #endif
1.103 --#ifdef __UCLIBC_HAS_LOCALE__
1.104 -+#ifdef _GLIBCXX_USE_ICONV
1.105 - #include <iconv.h> // For codecvt using iconv, iconv_t
1.106 - #endif
1.107 --#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
1.108 --#include <libintl.h> // For messages
1.109 -+#ifdef HAVE_LIBINTL_H
1.110 -+#include <libintl.h> // For messages
1.111 - #endif
1.112 -+#include <cstdarg>
1.113 -
1.114 - #ifdef __UCLIBC_MJN3_ONLY__
1.115 - #warning what is _GLIBCXX_C_LOCALE_GNU for
1.116 -+// psm: used in os/gnu-linux/ctype_noninline.h
1.117 - #endif
1.118 - #define _GLIBCXX_C_LOCALE_GNU 1
1.119 -
1.120 -@@ -62,7 +64,7 @@
1.121 - #endif
1.122 - // #define _GLIBCXX_NUM_CATEGORIES 6
1.123 - #define _GLIBCXX_NUM_CATEGORIES 0
1.124 --
1.125 -+
1.126 - #ifdef __UCLIBC_HAS_XLOCALE__
1.127 - namespace __gnu_cxx
1.128 - {
1.129 -@@ -79,22 +81,24 @@
1.130 - typedef int* __c_locale;
1.131 - #endif
1.132 -
1.133 -- // Convert numeric value of type _Tv to string and return length of
1.134 -- // string. If snprintf is available use it, otherwise fall back to
1.135 -- // the unsafe sprintf which, in general, can be dangerous and should
1.136 -+ // Convert numeric value of type double to string and return length of
1.137 -+ // string. If vsnprintf is available use it, otherwise fall back to
1.138 -+ // the unsafe vsprintf which, in general, can be dangerous and should
1.139 - // be avoided.
1.140 -- template<typename _Tv>
1.141 -- int
1.142 -- __convert_from_v(char* __out,
1.143 -- const int __size __attribute__ ((__unused__)),
1.144 -- const char* __fmt,
1.145 --#ifdef __UCLIBC_HAS_XCLOCALE__
1.146 -- _Tv __v, const __c_locale& __cloc, int __prec)
1.147 -+ inline int
1.148 -+ __convert_from_v(const __c_locale&
1.149 -+#ifndef __UCLIBC_HAS_XCLOCALE__
1.150 -+ __cloc __attribute__ ((__unused__))
1.151 -+#endif
1.152 -+ ,
1.153 -+ char* __out,
1.154 -+ const int __size,
1.155 -+ const char* __fmt, ...)
1.156 - {
1.157 -+ va_list __args;
1.158 -+#ifdef __UCLIBC_HAS_XCLOCALE__
1.159 - __c_locale __old = __gnu_cxx::__uselocale(__cloc);
1.160 - #else
1.161 -- _Tv __v, const __c_locale&, int __prec)
1.162 -- {
1.163 - # ifdef __UCLIBC_HAS_LOCALE__
1.164 - char* __old = std::setlocale(LC_ALL, NULL);
1.165 - char* __sav = new char[std::strlen(__old) + 1];
1.166 -@@ -103,7 +107,9 @@
1.167 - # endif
1.168 - #endif
1.169 -
1.170 -- const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
1.171 -+ va_start(__args, __fmt);
1.172 -+ const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
1.173 -+ va_end(__args);
1.174 -
1.175 - #ifdef __UCLIBC_HAS_XCLOCALE__
1.176 - __gnu_cxx::__uselocale(__old);
1.177 -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
1.178 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-06-10 14:58:47.000000000 +0200
1.179 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-06-10 14:58:51.000000000 +0200
1.180 -@@ -33,9 +33,14 @@
1.181 -
1.182 - // Written by Benjamin Kosnik <bkoz@redhat.com>
1.183 -
1.184 -+#include <features.h>
1.185 -+#ifdef __UCLIBC_HAS_LOCALE__
1.186 - #define _LIBC
1.187 - #include <locale>
1.188 - #undef _LIBC
1.189 -+#else
1.190 -+#include <locale>
1.191 -+#endif
1.192 - #include <bits/c++locale_internal.h>
1.193 -
1.194 - namespace std
1.195 -@@ -138,20 +143,34 @@
1.196 - ctype<wchar_t>::
1.197 - do_is(mask __m, wchar_t __c) const
1.198 - {
1.199 -- // Highest bitmask in ctype_base == 10, but extra in "C"
1.200 -- // library for blank.
1.201 -+ // The case of __m == ctype_base::space is particularly important,
1.202 -+ // due to its use in many istream functions. Therefore we deal with
1.203 -+ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
1.204 -+ // is the mask corresponding to ctype_base::space. NB: an encoding
1.205 -+ // change would not affect correctness!
1.206 - bool __ret = false;
1.207 -- const size_t __bitmasksize = 11;
1.208 -- for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
1.209 -- if (__m & _M_bit[__bitcur]
1.210 -- && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
1.211 -- {
1.212 -- __ret = true;
1.213 -- break;
1.214 -- }
1.215 -+ if (__m == _M_bit[5])
1.216 -+ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
1.217 -+ else
1.218 -+ {
1.219 -+ // Highest bitmask in ctype_base == 10, but extra in "C"
1.220 -+ // library for blank.
1.221 -+ const size_t __bitmasksize = 11;
1.222 -+ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
1.223 -+ if (__m & _M_bit[__bitcur])
1.224 -+ {
1.225 -+ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
1.226 -+ {
1.227 -+ __ret = true;
1.228 -+ break;
1.229 -+ }
1.230 -+ else if (__m == _M_bit[__bitcur])
1.231 -+ break;
1.232 -+ }
1.233 -+ }
1.234 - return __ret;
1.235 - }
1.236 --
1.237 -+
1.238 - const wchar_t*
1.239 - ctype<wchar_t>::
1.240 - do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
1.241 -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
1.242 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-06-10 14:58:47.000000000 +0200
1.243 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-06-10 14:58:51.000000000 +0200
1.244 -@@ -47,18 +47,21 @@
1.245 - template<typename _CharT>
1.246 - messages<_CharT>::messages(size_t __refs)
1.247 - : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
1.248 -- _M_name_messages(_S_get_c_name())
1.249 -+ _M_name_messages(_S_get_c_name())
1.250 - { }
1.251 -
1.252 - template<typename _CharT>
1.253 - messages<_CharT>::messages(__c_locale __cloc, const char* __s,
1.254 - size_t __refs)
1.255 -- : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
1.256 -- _M_name_messages(__s)
1.257 -+ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
1.258 - {
1.259 -- char* __tmp = new char[std::strlen(__s) + 1];
1.260 -- std::strcpy(__tmp, __s);
1.261 -+ const size_t __len = std::strlen(__s) + 1;
1.262 -+ char* __tmp = new char[__len];
1.263 -+ std::memcpy(__tmp, __s, __len);
1.264 - _M_name_messages = __tmp;
1.265 -+
1.266 -+ // Last to avoid leaking memory if new throws.
1.267 -+ _M_c_locale_messages = _S_clone_c_locale(__cloc);
1.268 - }
1.269 -
1.270 - template<typename _CharT>
1.271 -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
1.272 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-06-10 14:58:51.000000000 +0200
1.273 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-06-10 14:58:51.000000000 +0200
1.274 -@@ -33,9 +33,14 @@
1.275 -
1.276 - // Written by Benjamin Kosnik <bkoz@redhat.com>
1.277 -
1.278 -+#include <features.h>
1.279 -+#ifdef __UCLIBC_HAS_LOCALE__
1.280 - #define _LIBC
1.281 - #include <locale>
1.282 - #undef _LIBC
1.283 -+#else
1.284 -+#include <locale>
1.285 -+#endif
1.286 - #include <bits/c++locale_internal.h>
1.287 -
1.288 - #ifdef __UCLIBC_MJN3_ONLY__
1.289 -@@ -206,7 +211,7 @@
1.290 - }
1.291 - break;
1.292 - default:
1.293 -- ;
1.294 -+ __ret = pattern();
1.295 - }
1.296 - return __ret;
1.297 - }
1.298 -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
1.299 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-06-10 14:58:51.000000000 +0200
1.300 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-06-10 14:58:51.000000000 +0200
1.301 -@@ -33,9 +33,14 @@
1.302 -
1.303 - // Written by Benjamin Kosnik <bkoz@redhat.com>
1.304 -
1.305 -+#include <features.h>
1.306 -+#ifdef __UCLIBC_HAS_LOCALE__
1.307 - #define _LIBC
1.308 - #include <locale>
1.309 - #undef _LIBC
1.310 -+#else
1.311 -+#include <locale>
1.312 -+#endif
1.313 - #include <bits/c++locale_internal.h>
1.314 -
1.315 - #ifdef __UCLIBC_MJN3_ONLY__
1.316 -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
1.317 ---- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2008-06-10 14:58:43.000000000 +0200
1.318 -+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.h 2008-06-10 14:58:51.000000000 +0200
1.319 -@@ -37,25 +37,33 @@
1.320 - template<typename _CharT>
1.321 - __timepunct<_CharT>::__timepunct(size_t __refs)
1.322 - : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
1.323 -- _M_name_timepunct(_S_get_c_name())
1.324 -+ _M_name_timepunct(_S_get_c_name())
1.325 - { _M_initialize_timepunct(); }
1.326 -
1.327 - template<typename _CharT>
1.328 - __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
1.329 - : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
1.330 -- _M_name_timepunct(_S_get_c_name())
1.331 -+ _M_name_timepunct(_S_get_c_name())
1.332 - { _M_initialize_timepunct(); }
1.333 -
1.334 - template<typename _CharT>
1.335 - __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
1.336 - size_t __refs)
1.337 - : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
1.338 -- _M_name_timepunct(__s)
1.339 -+ _M_name_timepunct(NULL)
1.340 - {
1.341 -- char* __tmp = new char[std::strlen(__s) + 1];
1.342 -- std::strcpy(__tmp, __s);
1.343 -+ const size_t __len = std::strlen(__s) + 1;
1.344 -+ char* __tmp = new char[__len];
1.345 -+ std::memcpy(__tmp, __s, __len);
1.346 - _M_name_timepunct = __tmp;
1.347 -- _M_initialize_timepunct(__cloc);
1.348 -+
1.349 -+ try
1.350 -+ { _M_initialize_timepunct(__cloc); }
1.351 -+ catch(...)
1.352 -+ {
1.353 -+ delete [] _M_name_timepunct;
1.354 -+ __throw_exception_again;
1.355 -+ }
1.356 - }
1.357 -
1.358 - template<typename _CharT>