205-uclibc-locale-update.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. --- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
  2. +++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100
  3. @@ -46,16 +47,13 @@
  4. __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
  5. const __c_locale& __cloc)
  6. {
  7. - if (!(__err & ios_base::failbit))
  8. - {
  9. - char* __sanity;
  10. - errno = 0;
  11. - float __f = __strtof_l(__s, &__sanity, __cloc);
  12. - if (__sanity != __s && errno != ERANGE)
  13. - __v = __f;
  14. - else
  15. - __err |= ios_base::failbit;
  16. - }
  17. + char* __sanity;
  18. + errno = 0;
  19. + float __f = __strtof_l(__s, &__sanity, __cloc);
  20. + if (__sanity != __s && errno != ERANGE)
  21. + __v = __f;
  22. + else
  23. + __err |= ios_base::failbit;
  24. }
  25. template<>
  26. @@ -63,16 +61,13 @@
  27. __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
  28. const __c_locale& __cloc)
  29. {
  30. - if (!(__err & ios_base::failbit))
  31. - {
  32. - char* __sanity;
  33. - errno = 0;
  34. - double __d = __strtod_l(__s, &__sanity, __cloc);
  35. - if (__sanity != __s && errno != ERANGE)
  36. - __v = __d;
  37. - else
  38. - __err |= ios_base::failbit;
  39. - }
  40. + char* __sanity;
  41. + errno = 0;
  42. + double __d = __strtod_l(__s, &__sanity, __cloc);
  43. + if (__sanity != __s && errno != ERANGE)
  44. + __v = __d;
  45. + else
  46. + __err |= ios_base::failbit;
  47. }
  48. template<>
  49. @@ -80,16 +75,13 @@
  50. __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
  51. const __c_locale& __cloc)
  52. {
  53. - if (!(__err & ios_base::failbit))
  54. - {
  55. - char* __sanity;
  56. - errno = 0;
  57. - long double __ld = __strtold_l(__s, &__sanity, __cloc);
  58. - if (__sanity != __s && errno != ERANGE)
  59. - __v = __ld;
  60. - else
  61. - __err |= ios_base::failbit;
  62. - }
  63. + char* __sanity;
  64. + errno = 0;
  65. + long double __ld = __strtold_l(__s, &__sanity, __cloc);
  66. + if (__sanity != __s && errno != ERANGE)
  67. + __v = __ld;
  68. + else
  69. + __err |= ios_base::failbit;
  70. }
  71. void
  72. @@ -110,7 +102,7 @@
  73. void
  74. locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
  75. {
  76. - if (_S_get_c_locale() != __cloc)
  77. + if (__cloc && _S_get_c_locale() != __cloc)
  78. __freelocale(__cloc);
  79. }
  80. --- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100
  81. +++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100
  82. @@ -33,9 +33,14 @@
  83. // Written by Benjamin Kosnik <bkoz@redhat.com>
  84. +#include <features.h>
  85. +#ifdef __UCLIBC_HAS_LOCALE__
  86. #define _LIBC
  87. #include <locale>
  88. #undef _LIBC
  89. +#else
  90. +#include <locale>
  91. +#endif
  92. #include <bits/c++locale_internal.h>
  93. namespace std
  94. @@ -138,20 +143,34 @@
  95. ctype<wchar_t>::
  96. do_is(mask __m, wchar_t __c) const
  97. {
  98. - // Highest bitmask in ctype_base == 10, but extra in "C"
  99. - // library for blank.
  100. + // The case of __m == ctype_base::space is particularly important,
  101. + // due to its use in many istream functions. Therefore we deal with
  102. + // it first, exploiting the knowledge that on GNU systems _M_bit[5]
  103. + // is the mask corresponding to ctype_base::space. NB: an encoding
  104. + // change would not affect correctness!
  105. bool __ret = false;
  106. - const size_t __bitmasksize = 11;
  107. - for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
  108. - if (__m & _M_bit[__bitcur]
  109. - && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
  110. - {
  111. - __ret = true;
  112. - break;
  113. - }
  114. + if (__m == _M_bit[5])
  115. + __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
  116. + else
  117. + {
  118. + // Highest bitmask in ctype_base == 10, but extra in "C"
  119. + // library for blank.
  120. + const size_t __bitmasksize = 11;
  121. + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
  122. + if (__m & _M_bit[__bitcur])
  123. + {
  124. + if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
  125. + {
  126. + __ret = true;
  127. + break;
  128. + }
  129. + else if (__m == _M_bit[__bitcur])
  130. + break;
  131. + }
  132. + }
  133. return __ret;
  134. }
  135. -
  136. +
  137. const wchar_t*
  138. ctype<wchar_t>::
  139. do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
  140. --- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100
  141. +++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100
  142. @@ -47,18 +47,21 @@
  143. template<typename _CharT>
  144. messages<_CharT>::messages(size_t __refs)
  145. : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
  146. - _M_name_messages(_S_get_c_name())
  147. + _M_name_messages(_S_get_c_name())
  148. { }
  149. template<typename _CharT>
  150. messages<_CharT>::messages(__c_locale __cloc, const char* __s,
  151. size_t __refs)
  152. - : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
  153. - _M_name_messages(__s)
  154. + : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
  155. {
  156. - char* __tmp = new char[std::strlen(__s) + 1];
  157. - std::strcpy(__tmp, __s);
  158. + const size_t __len = std::strlen(__s) + 1;
  159. + char* __tmp = new char[__len];
  160. + std::memcpy(__tmp, __s, __len);
  161. _M_name_messages = __tmp;
  162. +
  163. + // Last to avoid leaking memory if new throws.
  164. + _M_c_locale_messages = _S_clone_c_locale(__cloc);
  165. }
  166. template<typename _CharT>
  167. --- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
  168. +++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100
  169. @@ -33,9 +33,14 @@
  170. // Written by Benjamin Kosnik <bkoz@redhat.com>
  171. +#include <features.h>
  172. +#ifdef __UCLIBC_HAS_LOCALE__
  173. #define _LIBC
  174. #include <locale>
  175. #undef _LIBC
  176. +#else
  177. +#include <locale>
  178. +#endif
  179. #include <bits/c++locale_internal.h>
  180. #ifdef __UCLIBC_MJN3_ONLY__
  181. @@ -206,7 +211,7 @@
  182. }
  183. break;
  184. default:
  185. - ;
  186. + __ret = pattern();
  187. }
  188. return __ret;
  189. }
  190. --- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100
  191. +++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100
  192. @@ -33,9 +33,14 @@
  193. // Written by Benjamin Kosnik <bkoz@redhat.com>
  194. +#include <features.h>
  195. +#ifdef __UCLIBC_HAS_LOCALE__
  196. #define _LIBC
  197. #include <locale>
  198. #undef _LIBC
  199. +#else
  200. +#include <locale>
  201. +#endif
  202. #include <bits/c++locale_internal.h>
  203. #ifdef __UCLIBC_MJN3_ONLY__
  204. --- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100
  205. +++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100
  206. @@ -37,25 +37,33 @@
  207. template<typename _CharT>
  208. __timepunct<_CharT>::__timepunct(size_t __refs)
  209. : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
  210. - _M_name_timepunct(_S_get_c_name())
  211. + _M_name_timepunct(_S_get_c_name())
  212. { _M_initialize_timepunct(); }
  213. template<typename _CharT>
  214. __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
  215. : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
  216. - _M_name_timepunct(_S_get_c_name())
  217. + _M_name_timepunct(_S_get_c_name())
  218. { _M_initialize_timepunct(); }
  219. template<typename _CharT>
  220. __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
  221. size_t __refs)
  222. : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
  223. - _M_name_timepunct(__s)
  224. + _M_name_timepunct(NULL)
  225. {
  226. - char* __tmp = new char[std::strlen(__s) + 1];
  227. - std::strcpy(__tmp, __s);
  228. + const size_t __len = std::strlen(__s) + 1;
  229. + char* __tmp = new char[__len];
  230. + std::memcpy(__tmp, __s, __len);
  231. _M_name_timepunct = __tmp;
  232. - _M_initialize_timepunct(__cloc);
  233. +
  234. + try
  235. + { _M_initialize_timepunct(__cloc); }
  236. + catch(...)
  237. + {
  238. + delete [] _M_name_timepunct;
  239. + __throw_exception_again;
  240. + }
  241. }
  242. template<typename _CharT>
  243. --- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200
  244. +++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200
  245. @@ -39,21 +39,23 @@
  246. #pragma GCC system_header
  247. #include <cstring> // get std::strlen
  248. -#include <cstdio> // get std::snprintf or std::sprintf
  249. +#include <cstdio> // get std::vsnprintf or std::vsprintf
  250. #include <clocale>
  251. #include <langinfo.h> // For codecvt
  252. #ifdef __UCLIBC_MJN3_ONLY__
  253. #warning fix this
  254. #endif
  255. -#ifdef __UCLIBC_HAS_LOCALE__
  256. +#ifdef _GLIBCXX_USE_ICONV
  257. #include <iconv.h> // For codecvt using iconv, iconv_t
  258. #endif
  259. -#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
  260. -#include <libintl.h> // For messages
  261. +#ifdef HAVE_LIBINTL_H
  262. +#include <libintl.h> // For messages
  263. #endif
  264. +#include <cstdarg>
  265. #ifdef __UCLIBC_MJN3_ONLY__
  266. #warning what is _GLIBCXX_C_LOCALE_GNU for
  267. +// psm: used in os/gnu-linux/ctype_noninline.h
  268. #endif
  269. #define _GLIBCXX_C_LOCALE_GNU 1
  270. @@ -62,7 +64,7 @@
  271. #endif
  272. // #define _GLIBCXX_NUM_CATEGORIES 6
  273. #define _GLIBCXX_NUM_CATEGORIES 0
  274. -
  275. +
  276. #ifdef __UCLIBC_HAS_XLOCALE__
  277. namespace __gnu_cxx
  278. {
  279. @@ -79,22 +81,24 @@
  280. typedef int* __c_locale;
  281. #endif
  282. - // Convert numeric value of type _Tv to string and return length of
  283. - // string. If snprintf is available use it, otherwise fall back to
  284. - // the unsafe sprintf which, in general, can be dangerous and should
  285. + // Convert numeric value of type double to string and return length of
  286. + // string. If vsnprintf is available use it, otherwise fall back to
  287. + // the unsafe vsprintf which, in general, can be dangerous and should
  288. // be avoided.
  289. - template<typename _Tv>
  290. - int
  291. - __convert_from_v(char* __out,
  292. - const int __size __attribute__ ((__unused__)),
  293. - const char* __fmt,
  294. -#ifdef __UCLIBC_HAS_XCLOCALE__
  295. - _Tv __v, const __c_locale& __cloc, int __prec)
  296. + inline int
  297. + __convert_from_v(const __c_locale&
  298. +#ifndef __UCLIBC_HAS_XCLOCALE__
  299. + __cloc __attribute__ ((__unused__))
  300. +#endif
  301. + ,
  302. + char* __out,
  303. + const int __size,
  304. + const char* __fmt, ...)
  305. {
  306. + va_list __args;
  307. +#ifdef __UCLIBC_HAS_XCLOCALE__
  308. __c_locale __old = __gnu_cxx::__uselocale(__cloc);
  309. #else
  310. - _Tv __v, const __c_locale&, int __prec)
  311. - {
  312. # ifdef __UCLIBC_HAS_LOCALE__
  313. char* __old = std::setlocale(LC_ALL, NULL);
  314. char* __sav = new char[std::strlen(__old) + 1];
  315. @@ -103,7 +107,9 @@
  316. # endif
  317. #endif
  318. - const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
  319. + va_start(__args, __fmt);
  320. + const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
  321. + va_end(__args);
  322. #ifdef __UCLIBC_HAS_XCLOCALE__
  323. __gnu_cxx::__uselocale(__old);