OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [config/] [locale/] [gnu/] [time_members.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
2
 
3
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
4
// Free Software Foundation, Inc.
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 3, or (at your option)
10
// any later version.
11
 
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
 
17
// Under Section 7 of GPL version 3, you are granted additional
18
// permissions described in the GCC Runtime Library Exception, version
19
// 3.1, as published by the Free Software Foundation.
20
 
21
// You should have received a copy of the GNU General Public License and
22
// a copy of the GCC Runtime Library Exception along with this program;
23
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
// <http://www.gnu.org/licenses/>.
25
 
26
//
27
// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
28
// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
29
//
30
 
31
// Written by Benjamin Kosnik <bkoz@redhat.com>
32
 
33
#include <locale>
34
#include <bits/c++locale_internal.h>
35
 
36
namespace std _GLIBCXX_VISIBILITY(default)
37
{
38
_GLIBCXX_BEGIN_NAMESPACE_VERSION
39
 
40
  template<>
41
    void
42
    __timepunct<char>::
43
    _M_put(char* __s, size_t __maxlen, const char* __format,
44
           const tm* __tm) const throw()
45
    {
46
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
47
      const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
48
                                        _M_c_locale_timepunct);
49
#else
50
      char* __old = setlocale(LC_ALL, 0);
51
      const size_t __llen = strlen(__old) + 1;
52
      char* __sav = new char[__llen];
53
      memcpy(__sav, __old, __llen);
54
      setlocale(LC_ALL, _M_name_timepunct);
55
      const size_t __len = strftime(__s, __maxlen, __format, __tm);
56
      setlocale(LC_ALL, __sav);
57
      delete [] __sav;
58
#endif
59
      // Make sure __s is null terminated.
60
      if (__len == 0)
61
        __s[0] = '\0';
62
    }
63
 
64
  template<>
65
    void
66
    __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
67
    {
68
      if (!_M_data)
69
        _M_data = new __timepunct_cache<char>;
70
 
71
      if (!__cloc)
72
        {
73
          // "C" locale
74
          _M_c_locale_timepunct = _S_get_c_locale();
75
 
76
          _M_data->_M_date_format = "%m/%d/%y";
77
          _M_data->_M_date_era_format = "%m/%d/%y";
78
          _M_data->_M_time_format = "%H:%M:%S";
79
          _M_data->_M_time_era_format = "%H:%M:%S";
80
          _M_data->_M_date_time_format = "";
81
          _M_data->_M_date_time_era_format = "";
82
          _M_data->_M_am = "AM";
83
          _M_data->_M_pm = "PM";
84
          _M_data->_M_am_pm_format = "";
85
 
86
          // Day names, starting with "C"'s Sunday.
87
          _M_data->_M_day1 = "Sunday";
88
          _M_data->_M_day2 = "Monday";
89
          _M_data->_M_day3 = "Tuesday";
90
          _M_data->_M_day4 = "Wednesday";
91
          _M_data->_M_day5 = "Thursday";
92
          _M_data->_M_day6 = "Friday";
93
          _M_data->_M_day7 = "Saturday";
94
 
95
          // Abbreviated day names, starting with "C"'s Sun.
96
          _M_data->_M_aday1 = "Sun";
97
          _M_data->_M_aday2 = "Mon";
98
          _M_data->_M_aday3 = "Tue";
99
          _M_data->_M_aday4 = "Wed";
100
          _M_data->_M_aday5 = "Thu";
101
          _M_data->_M_aday6 = "Fri";
102
          _M_data->_M_aday7 = "Sat";
103
 
104
          // Month names, starting with "C"'s January.
105
          _M_data->_M_month01 = "January";
106
          _M_data->_M_month02 = "February";
107
          _M_data->_M_month03 = "March";
108
          _M_data->_M_month04 = "April";
109
          _M_data->_M_month05 = "May";
110
          _M_data->_M_month06 = "June";
111
          _M_data->_M_month07 = "July";
112
          _M_data->_M_month08 = "August";
113
          _M_data->_M_month09 = "September";
114
          _M_data->_M_month10 = "October";
115
          _M_data->_M_month11 = "November";
116
          _M_data->_M_month12 = "December";
117
 
118
          // Abbreviated month names, starting with "C"'s Jan.
119
          _M_data->_M_amonth01 = "Jan";
120
          _M_data->_M_amonth02 = "Feb";
121
          _M_data->_M_amonth03 = "Mar";
122
          _M_data->_M_amonth04 = "Apr";
123
          _M_data->_M_amonth05 = "May";
124
          _M_data->_M_amonth06 = "Jun";
125
          _M_data->_M_amonth07 = "Jul";
126
          _M_data->_M_amonth08 = "Aug";
127
          _M_data->_M_amonth09 = "Sep";
128
          _M_data->_M_amonth10 = "Oct";
129
          _M_data->_M_amonth11 = "Nov";
130
          _M_data->_M_amonth12 = "Dec";
131
        }
132
      else
133
        {
134
          _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
135
 
136
          _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
137
          _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
138
          _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
139
          _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
140
          _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
141
          _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
142
                                                             __cloc);
143
          _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
144
          _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
145
          _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
146
 
147
          // Day names, starting with "C"'s Sunday.
148
          _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
149
          _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
150
          _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
151
          _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
152
          _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
153
          _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
154
          _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
155
 
156
          // Abbreviated day names, starting with "C"'s Sun.
157
          _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
158
          _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
159
          _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
160
          _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
161
          _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
162
          _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
163
          _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
164
 
165
          // Month names, starting with "C"'s January.
166
          _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
167
          _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
168
          _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
169
          _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
170
          _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
171
          _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
172
          _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
173
          _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
174
          _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
175
          _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
176
          _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
177
          _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
178
 
179
          // Abbreviated month names, starting with "C"'s Jan.
180
          _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
181
          _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
182
          _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
183
          _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
184
          _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
185
          _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
186
          _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
187
          _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
188
          _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
189
          _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
190
          _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
191
          _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
192
        }
193
    }
194
 
195
#ifdef _GLIBCXX_USE_WCHAR_T
196
  template<>
197
    void
198
    __timepunct<wchar_t>::
199
    _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
200
           const tm* __tm) const throw()
201
    {
202
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
203
      const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
204
                                        _M_c_locale_timepunct);
205
#else
206
      char* __old = setlocale(LC_ALL, 0);
207
      const size_t __llen = strlen(__old) + 1;
208
      char* __sav = new char[__llen];
209
      memcpy(__sav, __old, __llen);
210
      setlocale(LC_ALL, _M_name_timepunct);
211
      const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
212
      setlocale(LC_ALL, __sav);
213
      delete [] __sav;
214
#endif
215
      // Make sure __s is null terminated.
216
      if (__len == 0)
217
        __s[0] = L'\0';
218
    }
219
 
220
  template<>
221
    void
222
    __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
223
    {
224
      if (!_M_data)
225
        _M_data = new __timepunct_cache<wchar_t>;
226
 
227
      if (!__cloc)
228
        {
229
          // "C" locale
230
          _M_c_locale_timepunct = _S_get_c_locale();
231
 
232
          _M_data->_M_date_format = L"%m/%d/%y";
233
          _M_data->_M_date_era_format = L"%m/%d/%y";
234
          _M_data->_M_time_format = L"%H:%M:%S";
235
          _M_data->_M_time_era_format = L"%H:%M:%S";
236
          _M_data->_M_date_time_format = L"";
237
          _M_data->_M_date_time_era_format = L"";
238
          _M_data->_M_am = L"AM";
239
          _M_data->_M_pm = L"PM";
240
          _M_data->_M_am_pm_format = L"";
241
 
242
          // Day names, starting with "C"'s Sunday.
243
          _M_data->_M_day1 = L"Sunday";
244
          _M_data->_M_day2 = L"Monday";
245
          _M_data->_M_day3 = L"Tuesday";
246
          _M_data->_M_day4 = L"Wednesday";
247
          _M_data->_M_day5 = L"Thursday";
248
          _M_data->_M_day6 = L"Friday";
249
          _M_data->_M_day7 = L"Saturday";
250
 
251
          // Abbreviated day names, starting with "C"'s Sun.
252
          _M_data->_M_aday1 = L"Sun";
253
          _M_data->_M_aday2 = L"Mon";
254
          _M_data->_M_aday3 = L"Tue";
255
          _M_data->_M_aday4 = L"Wed";
256
          _M_data->_M_aday5 = L"Thu";
257
          _M_data->_M_aday6 = L"Fri";
258
          _M_data->_M_aday7 = L"Sat";
259
 
260
          // Month names, starting with "C"'s January.
261
          _M_data->_M_month01 = L"January";
262
          _M_data->_M_month02 = L"February";
263
          _M_data->_M_month03 = L"March";
264
          _M_data->_M_month04 = L"April";
265
          _M_data->_M_month05 = L"May";
266
          _M_data->_M_month06 = L"June";
267
          _M_data->_M_month07 = L"July";
268
          _M_data->_M_month08 = L"August";
269
          _M_data->_M_month09 = L"September";
270
          _M_data->_M_month10 = L"October";
271
          _M_data->_M_month11 = L"November";
272
          _M_data->_M_month12 = L"December";
273
 
274
          // Abbreviated month names, starting with "C"'s Jan.
275
          _M_data->_M_amonth01 = L"Jan";
276
          _M_data->_M_amonth02 = L"Feb";
277
          _M_data->_M_amonth03 = L"Mar";
278
          _M_data->_M_amonth04 = L"Apr";
279
          _M_data->_M_amonth05 = L"May";
280
          _M_data->_M_amonth06 = L"Jun";
281
          _M_data->_M_amonth07 = L"Jul";
282
          _M_data->_M_amonth08 = L"Aug";
283
          _M_data->_M_amonth09 = L"Sep";
284
          _M_data->_M_amonth10 = L"Oct";
285
          _M_data->_M_amonth11 = L"Nov";
286
          _M_data->_M_amonth12 = L"Dec";
287
        }
288
      else
289
        {
290
          _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
291
 
292
          union { char *__s; wchar_t *__w; } __u;
293
 
294
          __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
295
          _M_data->_M_date_format = __u.__w;
296
          __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
297
          _M_data->_M_date_era_format = __u.__w;
298
          __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
299
          _M_data->_M_time_format = __u.__w;
300
          __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
301
          _M_data->_M_time_era_format = __u.__w;
302
          __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
303
          _M_data->_M_date_time_format = __u.__w;
304
          __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
305
          _M_data->_M_date_time_era_format = __u.__w;
306
          __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
307
          _M_data->_M_am = __u.__w;
308
          __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
309
          _M_data->_M_pm = __u.__w;
310
          __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
311
          _M_data->_M_am_pm_format = __u.__w;
312
 
313
          // Day names, starting with "C"'s Sunday.
314
          __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
315
          _M_data->_M_day1 = __u.__w;
316
          __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
317
          _M_data->_M_day2 = __u.__w;
318
          __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
319
          _M_data->_M_day3 = __u.__w;
320
          __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
321
          _M_data->_M_day4 = __u.__w;
322
          __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
323
          _M_data->_M_day5 = __u.__w;
324
          __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
325
          _M_data->_M_day6 = __u.__w;
326
          __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
327
          _M_data->_M_day7 = __u.__w;
328
 
329
          // Abbreviated day names, starting with "C"'s Sun.
330
          __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
331
          _M_data->_M_aday1 = __u.__w;
332
          __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
333
          _M_data->_M_aday2 = __u.__w;
334
          __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
335
          _M_data->_M_aday3 = __u.__w;
336
          __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
337
          _M_data->_M_aday4 = __u.__w;
338
          __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
339
          _M_data->_M_aday5 = __u.__w;
340
          __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
341
          _M_data->_M_aday6 = __u.__w;
342
          __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
343
          _M_data->_M_aday7 = __u.__w;
344
 
345
          // Month names, starting with "C"'s January.
346
          __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
347
          _M_data->_M_month01 = __u.__w;
348
          __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
349
          _M_data->_M_month02 = __u.__w;
350
          __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
351
          _M_data->_M_month03 = __u.__w;
352
          __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
353
          _M_data->_M_month04 = __u.__w;
354
          __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
355
          _M_data->_M_month05 = __u.__w;
356
          __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
357
          _M_data->_M_month06 = __u.__w;
358
          __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
359
          _M_data->_M_month07 = __u.__w;
360
          __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
361
          _M_data->_M_month08 = __u.__w;
362
          __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
363
          _M_data->_M_month09 = __u.__w;
364
          __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
365
          _M_data->_M_month10 = __u.__w;
366
          __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
367
          _M_data->_M_month11 = __u.__w;
368
          __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
369
          _M_data->_M_month12 = __u.__w;
370
 
371
          // Abbreviated month names, starting with "C"'s Jan.
372
          __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
373
          _M_data->_M_amonth01 = __u.__w;
374
          __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
375
          _M_data->_M_amonth02 = __u.__w;
376
          __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
377
          _M_data->_M_amonth03 = __u.__w;
378
          __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
379
          _M_data->_M_amonth04 = __u.__w;
380
          __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
381
          _M_data->_M_amonth05 = __u.__w;
382
          __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
383
          _M_data->_M_amonth06 = __u.__w;
384
          __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
385
          _M_data->_M_amonth07 = __u.__w;
386
          __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
387
          _M_data->_M_amonth08 = __u.__w;
388
          __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
389
          _M_data->_M_amonth09 = __u.__w;
390
          __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
391
          _M_data->_M_amonth10 = __u.__w;
392
          __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
393
          _M_data->_M_amonth11 = __u.__w;
394
          __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
395
          _M_data->_M_amonth12 = __u.__w;
396
        }
397
    }
398
#endif
399
 
400
_GLIBCXX_END_NAMESPACE_VERSION
401
} // namespace

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.