summaryrefslogtreecommitdiff
path: root/toolchain/gcc/4.2.0/205-uclibc-locale-update.patch
blob: be43c6e23fcb41e1656fa0bdb9a18ea10926466b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
--- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc	2006-03-10 15:39:14 +0100
@@ -1,6 +1,7 @@
 // Wrapper for underlying C-language localization -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 
+// Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -15,7 +16,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -46,16 +47,13 @@
     __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, 
 		   const __c_locale& __cloc)
     {
-      if (!(__err & ios_base::failbit))
-	{
-	  char* __sanity;
-	  errno = 0;
-	  float __f = __strtof_l(__s, &__sanity, __cloc);
-          if (__sanity != __s && errno != ERANGE)
-	    __v = __f;
-	  else
-	    __err |= ios_base::failbit;
-	}
+      char* __sanity;
+      errno = 0;
+      float __f = __strtof_l(__s, &__sanity, __cloc);
+      if (__sanity != __s && errno != ERANGE)
+	__v = __f;
+      else
+	__err |= ios_base::failbit;
     }
 
   template<>
@@ -63,16 +61,13 @@
     __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, 
 		   const __c_locale& __cloc)
     {
-      if (!(__err & ios_base::failbit))
-	{
-	  char* __sanity;
-	  errno = 0;
-	  double __d = __strtod_l(__s, &__sanity, __cloc);
-          if (__sanity != __s && errno != ERANGE)
-	    __v = __d;
-	  else
-	    __err |= ios_base::failbit;
-	}
+      char* __sanity;
+      errno = 0;
+      double __d = __strtod_l(__s, &__sanity, __cloc);
+      if (__sanity != __s && errno != ERANGE)
+	__v = __d;
+      else
+	__err |= ios_base::failbit;
     }
 
   template<>
@@ -80,16 +75,13 @@
     __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
 		   const __c_locale& __cloc)
     {
-      if (!(__err & ios_base::failbit))
-	{
-	  char* __sanity;
-	  errno = 0;
-	  long double __ld = __strtold_l(__s, &__sanity, __cloc);
-          if (__sanity != __s && errno != ERANGE)
-	    __v = __ld;
-	  else
-	    __err |= ios_base::failbit;
-	}
+      char* __sanity;
+      errno = 0;
+      long double __ld = __strtold_l(__s, &__sanity, __cloc);
+      if (__sanity != __s && errno != ERANGE)
+	__v = __ld;
+      else
+	__err |= ios_base::failbit;
     }
 
   void
@@ -110,7 +102,7 @@
   void
   locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
   {
-    if (_S_get_c_locale() != __cloc)
+    if (__cloc && _S_get_c_locale() != __cloc)
       __freelocale(__cloc); 
   }
 
--- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -45,15 +45,16 @@
 #ifdef __UCLIBC_MJN3_ONLY__
 #warning fix this
 #endif
-#ifdef __UCLIBC_HAS_LOCALE__
+#ifdef _GLIBCXX_USE_ICONV
 #include <iconv.h>		// For codecvt using iconv, iconv_t
 #endif
-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+#ifdef HAVE_LIBINTL_H
 #include <libintl.h> 		// For messages
 #endif
 
 #ifdef __UCLIBC_MJN3_ONLY__
 #warning what is _GLIBCXX_C_LOCALE_GNU for
+// psm: used in os/gnu-linux/ctype_noninline.h
 #endif
 #define _GLIBCXX_C_LOCALE_GNU 1
 
--- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc.uclibc200_update~	2006-03-10 15:06:17 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
--- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
--- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -33,9 +33,14 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 
+#include <features.h>
+#ifdef __UCLIBC_HAS_LOCALE__
 #define _LIBC
 #include <locale>
 #undef _LIBC
+#else
+#include <locale>
+#endif
 #include <bits/c++locale_internal.h>
 
 namespace std
@@ -138,20 +143,34 @@
   ctype<wchar_t>::
   do_is(mask __m, wchar_t __c) const
   { 
-    // Highest bitmask in ctype_base == 10, but extra in "C"
-    // library for blank.
+    // The case of __m == ctype_base::space is particularly important,
+    // due to its use in many istream functions.  Therefore we deal with
+    // it first, exploiting the knowledge that on GNU systems _M_bit[5]
+    // is the mask corresponding to ctype_base::space.  NB: an encoding
+    // change would not affect correctness!
     bool __ret = false;
-    const size_t __bitmasksize = 11; 
-    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
-      if (__m & _M_bit[__bitcur]
-	  && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
-	{
-	  __ret = true;
-	  break;
-	}
+    if (__m == _M_bit[5])
+      __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
+    else
+      {
+	// Highest bitmask in ctype_base == 10, but extra in "C"
+	// library for blank.
+	const size_t __bitmasksize = 11;
+	for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
+	  if (__m & _M_bit[__bitcur])
+	    {
+	      if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
+		{
+		  __ret = true;
+		  break;
+		}
+	      else if (__m == _M_bit[__bitcur])
+		break;
+	    }
+      }
     return __ret;    
   }
-  
+
   const wchar_t* 
   ctype<wchar_t>::
   do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
--- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h	2006-03-10 15:39:14 +0100
@@ -1,6 +1,6 @@
 // std::messages implementation details, GNU version -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -47,18 +47,21 @@
   template<typename _CharT>
      messages<_CharT>::messages(size_t __refs)
      : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), 
-     _M_name_messages(_S_get_c_name())
+       _M_name_messages(_S_get_c_name())
      { }
 
   template<typename _CharT>
      messages<_CharT>::messages(__c_locale __cloc, const char* __s, 
 				size_t __refs) 
-     : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
-     _M_name_messages(__s)
+     : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
      {
-       char* __tmp = new char[std::strlen(__s) + 1];
-       std::strcpy(__tmp, __s);
+       const size_t __len = std::strlen(__s) + 1;
+       char* __tmp = new char[__len];
+       std::memcpy(__tmp, __s, __len);
        _M_name_messages = __tmp;
+
+       // Last to avoid leaking memory if new throws.
+       _M_c_locale_messages = _S_clone_c_locale(__cloc);
      }
 
   template<typename _CharT>
--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~	2006-03-10 15:37:27 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -33,9 +33,14 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 
+#include <features.h>
+#ifdef __UCLIBC_HAS_LOCALE__
 #define _LIBC
 #include <locale>
 #undef _LIBC
+#else
+#include <locale>
+#endif
 #include <bits/c++locale_internal.h>
 
 #ifdef __UCLIBC_MJN3_ONLY__
@@ -206,7 +211,7 @@
 	  }
 	break;
       default:
-	;
+	__ret = pattern();
       }
     return __ret;
   }
--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~	2006-03-10 15:37:27 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -33,9 +33,14 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 
+#include <features.h>
+#ifdef __UCLIBC_HAS_LOCALE__
 #define _LIBC
 #include <locale>
 #undef _LIBC
+#else
+#include <locale>
+#endif
 #include <bits/c++locale_internal.h>
 
 #ifdef __UCLIBC_MJN3_ONLY__
--- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc.uclibc200_update~	2006-03-10 15:32:37 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc	2006-03-10 15:39:14 +0100
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
--- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~	2006-03-10 15:06:17 +0100
+++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h	2006-03-10 15:39:14 +0100
@@ -1,6 +1,6 @@
 // std::time_get, std::time_put implementation, GNU version -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -15,7 +15,7 @@
 
 // You should have received a copy of the GNU General Public License along
 // with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 // USA.
 
 // As a special exception, you may use this file as part of a free software
@@ -37,25 +37,33 @@
   template<typename _CharT>
     __timepunct<_CharT>::__timepunct(size_t __refs) 
     : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), 
-    _M_name_timepunct(_S_get_c_name())
+      _M_name_timepunct(_S_get_c_name())
     { _M_initialize_timepunct(); }
 
   template<typename _CharT>
     __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 
     : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL), 
-    _M_name_timepunct(_S_get_c_name())
+      _M_name_timepunct(_S_get_c_name())
     { _M_initialize_timepunct(); }
 
   template<typename _CharT>
     __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
 				     size_t __refs) 
     : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), 
-    _M_name_timepunct(__s)
+      _M_name_timepunct(NULL)
     { 
-      char* __tmp = new char[std::strlen(__s) + 1];
-      std::strcpy(__tmp, __s);
+      const size_t __len = std::strlen(__s) + 1;
+      char* __tmp = new char[__len];
+      std::memcpy(__tmp, __s, __len);
       _M_name_timepunct = __tmp;
-      _M_initialize_timepunct(__cloc); 
+
+      try
+	{ _M_initialize_timepunct(__cloc); }
+      catch(...)
+	{
+	  delete [] _M_name_timepunct;
+	  __throw_exception_again;
+	}
     }
 
   template<typename _CharT>