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