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