Mercurial > emacs
annotate src/strftime.c @ 20325:fea279940ce8
(auto-mode-alist): Add more extensions for perl-mode.
(interpreter-mode-alist): Add miniperl.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sun, 23 Nov 1997 02:13:26 +0000 |
parents | b53b022d2239 |
children | a9699fed520b |
rev | line source |
---|---|
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
2 |
19875
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
3 NOTE: The canonical source of this file is maintained with the GNU C Library. |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
4 Bugs can be reported to bug-glibc@prep.ai.mit.edu. |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
5 |
19875
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify it |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
7 under the terms of the GNU General Public License as published by the |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
8 Free Software Foundation; either version 2, or (at your option) any |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
9 later version. |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
10 |
19875
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
14 GNU General Public License for more details. |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
15 |
19875
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
17 along with this program; if not, write to the Free Software |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
278944a16af3
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18782
diff
changeset
|
19 USA. */ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
20 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
21 #ifdef HAVE_CONFIG_H |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
22 # include <config.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
23 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
24 |
20276
b53b022d2239
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20253
diff
changeset
|
25 /* Some hosts need this in order to declare localtime_r properly. */ |
b53b022d2239
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20253
diff
changeset
|
26 #ifndef _REENTRANT |
b53b022d2239
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20253
diff
changeset
|
27 # define _REENTRANT 1 |
b53b022d2239
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20253
diff
changeset
|
28 #endif |
b53b022d2239
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20253
diff
changeset
|
29 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
30 #ifdef _LIBC |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
31 # define HAVE_LIMITS_H 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
32 # define HAVE_MBLEN 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
33 # define HAVE_MBRLEN 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
34 # define HAVE_STRUCT_ERA_ENTRY 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
35 # define HAVE_TM_GMTOFF 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
36 # define HAVE_TM_ZONE 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
37 # define HAVE_TZNAME 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
38 # define HAVE_TZSET 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
39 # define MULTIBYTE_IS_FORMAT_SAFE 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
40 # define STDC_HEADERS 1 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
41 # include "../locale/localeinfo.h" |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
42 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
43 |
20010
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
44 #if defined emacs && !defined HAVE_BCOPY |
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
45 # define HAVE_MEMCPY 1 |
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
46 #endif |
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
47 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
48 #include <ctype.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
49 #include <sys/types.h> /* Some systems define `time_t' here. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
50 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
51 #ifdef TIME_WITH_SYS_TIME |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
52 # include <sys/time.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
53 # include <time.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
54 #else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
55 # ifdef HAVE_SYS_TIME_H |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
56 # include <sys/time.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
57 # else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
58 # include <time.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
59 # endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
60 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
61 #if HAVE_TZNAME |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
62 extern char *tzname[]; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
63 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
64 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
65 /* Do multibyte processing if multibytes are supported, unless |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
66 multibyte sequences are safe in formats. Multibyte sequences are |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
67 safe if they cannot contain byte sequences that look like format |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
68 conversion specifications. The GNU C Library uses UTF8 multibyte |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
69 encoding, which is safe for formats, but strftime.c can be used |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
70 with other C libraries that use unsafe encodings. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
71 #define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
72 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
73 #if DO_MULTIBYTE |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
74 # if HAVE_MBRLEN |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
75 # include <wchar.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
76 # else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
77 /* Simulate mbrlen with mblen as best we can. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
78 # define mbstate_t int |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
79 # define mbrlen(s, n, ps) mblen (s, n) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
80 # define mbsinit(ps) (*(ps) == 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
81 # endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
82 static const mbstate_t mbstate_zero; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
83 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
84 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
85 #if HAVE_LIMITS_H |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
86 # include <limits.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
87 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
88 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
89 #if STDC_HEADERS |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
90 # include <stddef.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
91 # include <stdlib.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
92 # include <string.h> |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
93 #else |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
94 # ifndef HAVE_MEMCPY |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
95 # define memcpy(d, s, n) bcopy ((s), (d), (n)) |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
96 # endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
97 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
98 |
20212
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
99 #ifdef _LIBC |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
100 # define MEMPCPY(d, s, n) __mempcpy (d, s, n) |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
101 #else |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
102 # ifndef HAVE_MEMPCPY |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
103 # define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n))) |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
104 # endif |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
105 #endif |
90f407354bdf
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20211
diff
changeset
|
106 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
107 #ifndef __P |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
108 # if defined (__GNUC__) || (defined (__STDC__) && __STDC__) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
109 # define __P(args) args |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
110 # else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
111 # define __P(args) () |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
112 # endif /* GCC. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
113 #endif /* Not __P. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
114 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
115 #ifndef PTR |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
116 # ifdef __STDC__ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
117 # define PTR void * |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
118 # else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
119 # define PTR char * |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
120 # endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
121 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
122 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
123 #ifndef CHAR_BIT |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
124 # define CHAR_BIT 8 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
125 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
126 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
127 #ifndef NULL |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
128 # define NULL 0 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
129 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
130 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
131 #define TYPE_SIGNED(t) ((t) -1 < 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
132 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
133 /* Bound on length of the string representing an integer value of type t. |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
134 Subtract one for the sign bit if t is signed; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
135 302 / 1000 is log10 (2) rounded up; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
136 add one for integer division truncation; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
137 add one more for a minus sign if t is signed. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
138 #define INT_STRLEN_BOUND(t) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
139 ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 100 + 1 + TYPE_SIGNED (t)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
140 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
141 #define TM_YEAR_BASE 1900 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
142 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
143 #ifndef __isleap |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
144 /* Nonzero if YEAR is a leap year (every 4 years, |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
145 except every 100th isn't, and every 400th is). */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
146 # define __isleap(year) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
147 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
148 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
149 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
150 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
151 #ifdef _LIBC |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
152 # define gmtime_r __gmtime_r |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
153 # define localtime_r __localtime_r |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
154 # define tzname __tzname |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
155 # define tzset __tzset |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
156 #else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
157 # if ! HAVE_LOCALTIME_R |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
158 # if ! HAVE_TM_GMTOFF |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
159 /* Approximate gmtime_r as best we can in its absence. */ |
20010
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
160 # undef gmtime_r |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
161 # define gmtime_r my_gmtime_r |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
162 static struct tm *gmtime_r __P ((const time_t *, struct tm *)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
163 static struct tm * |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
164 gmtime_r (t, tp) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
165 const time_t *t; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
166 struct tm *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
167 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
168 struct tm *l = gmtime (t); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
169 if (! l) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
170 return 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
171 *tp = *l; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
172 return tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
173 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
174 # endif /* ! HAVE_TM_GMTOFF */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
175 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
176 /* Approximate localtime_r as best we can in its absence. */ |
20010
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
177 # undef localtime_r |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
178 # define localtime_r my_ftime_localtime_r |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
179 static struct tm *localtime_r __P ((const time_t *, struct tm *)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
180 static struct tm * |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
181 localtime_r (t, tp) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
182 const time_t *t; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
183 struct tm *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
184 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
185 struct tm *l = localtime (t); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
186 if (! l) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
187 return 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
188 *tp = *l; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
189 return tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
190 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
191 # endif /* ! HAVE_LOCALTIME_R */ |
20253
a7d1d668f57f
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20252
diff
changeset
|
192 #endif /* ! defined _LIBC */ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
193 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
194 |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
195 #if !defined memset && !defined HAVE_MEMSET && !defined _LIBC |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
196 /* Some systems lack the `memset' function and we don't want to |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
197 introduce additional dependencies. */ |
18487
47be751da08b
automatically generated from GPLed version
Richard M. Stallman <rms@gnu.org>
parents:
17965
diff
changeset
|
198 /* The SGI compiler reportedly barfs on the trailing null |
47be751da08b
automatically generated from GPLed version
Richard M. Stallman <rms@gnu.org>
parents:
17965
diff
changeset
|
199 if we use a string constant as the initializer. 28 June 1997, rms. */ |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
200 static const char spaces[16] = /* " " */ |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
201 { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' }; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
202 static const char zeroes[16] = /* "0000000000000000" */ |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
203 { '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0' }; |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
204 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
205 # define memset_space(P, Len) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
206 do { \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
207 int _len = (Len); \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
208 \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
209 do \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
210 { \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
211 int _this = _len > 16 ? 16 : _len; \ |
20253
a7d1d668f57f
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20252
diff
changeset
|
212 (P) = MEMPCPY ((P), spaces, _this); \ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
213 _len -= _this; \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
214 } \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
215 while (_len > 0); \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
216 } while (0) |
17965
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
217 |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
218 # define memset_zero(P, Len) \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
219 do { \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
220 int _len = (Len); \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
221 \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
222 do \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
223 { \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
224 int _this = _len > 16 ? 16 : _len; \ |
20253
a7d1d668f57f
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20252
diff
changeset
|
225 (P) = MEMPCPY ((P), zeroes, _this); \ |
17965
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
226 _len -= _this; \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
227 } \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
228 while (_len > 0); \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
229 } while (0) |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
230 #else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
231 # define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len)) |
17965
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
232 # define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len)) |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
233 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
234 |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
235 #define add(n, f) \ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
236 do \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
237 { \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
238 int _n = (n); \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
239 int _delta = width - _n; \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
240 int _incr = _n + (_delta > 0 ? _delta : 0); \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
241 if (i + _incr >= maxsize) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
242 return 0; \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
243 if (p) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
244 { \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
245 if (_delta > 0) \ |
17965
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
246 { \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
247 if (pad == '0') \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
248 memset_zero (p, _delta); \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
249 else \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
250 memset_space (p, _delta); \ |
2ef01cc793bf
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
17502
diff
changeset
|
251 } \ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
252 f; \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
253 p += _n; \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
254 } \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
255 i += _incr; \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
256 } while (0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
257 |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
258 #define cpy(n, s) \ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
259 add ((n), \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
260 if (to_lowcase) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
261 memcpy_lowcase (p, (s), _n); \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
262 else if (to_uppcase) \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
263 memcpy_uppcase (p, (s), _n); \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
264 else \ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
265 memcpy ((PTR) p, (PTR) (s), _n)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
266 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
267 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
268 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
269 #ifdef _LIBC |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
270 # define TOUPPER(Ch) toupper (Ch) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
271 # define TOLOWER(Ch) tolower (Ch) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
272 #else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
273 # define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
274 # define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
275 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
276 /* We don't use `isdigit' here since the locale dependent |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
277 interpretation is not what we want here. We only need to accept |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
278 the arabic digits in the ASCII range. One day there is perhaps a |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
279 more reliable way to accept other sets of digits. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
280 #define ISDIGIT(Ch) ((unsigned int) (Ch) - '0' <= 9) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
281 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
282 static char *memcpy_lowcase __P ((char *dest, const char *src, size_t len)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
283 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
284 static char * |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
285 memcpy_lowcase (dest, src, len) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
286 char *dest; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
287 const char *src; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
288 size_t len; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
289 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
290 while (len-- > 0) |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
291 dest[len] = TOLOWER ((unsigned char) src[len]); |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
292 return dest; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
293 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
294 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
295 static char *memcpy_uppcase __P ((char *dest, const char *src, size_t len)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
296 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
297 static char * |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
298 memcpy_uppcase (dest, src, len) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
299 char *dest; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
300 const char *src; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
301 size_t len; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
302 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
303 while (len-- > 0) |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
304 dest[len] = TOUPPER ((unsigned char) src[len]); |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
305 return dest; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
306 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
307 |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
308 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
309 #if ! HAVE_TM_GMTOFF |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
310 /* Yield the difference between *A and *B, |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
311 measured in seconds, ignoring leap seconds. */ |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
312 # define tm_diff ftime_tm_diff |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
313 static int tm_diff __P ((const struct tm *, const struct tm *)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
314 static int |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
315 tm_diff (a, b) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
316 const struct tm *a; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
317 const struct tm *b; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
318 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
319 /* Compute intervening leap days correctly even if year is negative. |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
320 Take care to avoid int overflow in leap day calculations, |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
321 but it's OK to assume that A and B are close to each other. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
322 int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
323 int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
324 int a100 = a4 / 25 - (a4 % 25 < 0); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
325 int b100 = b4 / 25 - (b4 % 25 < 0); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
326 int a400 = a100 >> 2; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
327 int b400 = b100 >> 2; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
328 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
329 int years = a->tm_year - b->tm_year; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
330 int days = (365 * years + intervening_leap_days |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
331 + (a->tm_yday - b->tm_yday)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
332 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
333 + (a->tm_min - b->tm_min)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
334 + (a->tm_sec - b->tm_sec)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
335 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
336 #endif /* ! HAVE_TM_GMTOFF */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
337 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
338 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
339 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
340 /* The number of days from the first day of the first ISO week of this |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
341 year to the year day YDAY with week day WDAY. ISO weeks start on |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
342 Monday; the first ISO week has the year's first Thursday. YDAY may |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
343 be as small as YDAY_MINIMUM. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
344 #define ISO_WEEK_START_WDAY 1 /* Monday */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
345 #define ISO_WEEK1_WDAY 4 /* Thursday */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
346 #define YDAY_MINIMUM (-366) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
347 static int iso_week_days __P ((int, int)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
348 #ifdef __GNUC__ |
20010
cb0800f5aa96
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
19875
diff
changeset
|
349 __inline__ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
350 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
351 static int |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
352 iso_week_days (yday, wday) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
353 int yday; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
354 int wday; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
355 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
356 /* Add enough to the first operand of % to make it nonnegative. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
357 int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
358 return (yday |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
359 - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
360 + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
361 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
362 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
363 |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
364 #if !(defined _NL_CURRENT || HAVE_STRFTIME) |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
365 static char const weekday_name[][10] = |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
366 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
367 "Sunday", "Monday", "Tuesday", "Wednesday", |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
368 "Thursday", "Friday", "Saturday" |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
369 }; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
370 static char const month_name[][10] = |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
371 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
372 "January", "February", "March", "April", "May", "June", |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
373 "July", "August", "September", "October", "November", "December" |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
374 }; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
375 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
376 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
377 |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
378 #ifdef emacs |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
379 # define my_strftime emacs_strftime |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
380 /* Emacs 20.2 uses `-Dstrftime=emacs_strftime' when compiling, |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
381 because that's how strftime used to be configured. |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
382 Undo this, since it gets in the way of accessing the underlying strftime, |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
383 which is needed for things like %Ec in Solaris. |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
384 The following two lines can be removed once Emacs stops compiling with |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
385 `-Dstrftime=emacs_strftime'. */ |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
386 # undef strftime |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
387 size_t strftime __P ((char *, size_t, const char *, const struct tm *)); |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
388 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
389 # define my_strftime strftime |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
390 #endif |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
391 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
392 #if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
393 /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
394 Work around this bug by copying *tp before it might be munged. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
395 size_t _strftime_copytm __P ((char *, size_t, const char *, |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
396 const struct tm *)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
397 size_t |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
398 my_strftime (s, maxsize, format, tp) |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
399 char *s; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
400 size_t maxsize; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
401 const char *format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
402 const struct tm *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
403 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
404 struct tm tmcopy; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
405 tmcopy = *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
406 return _strftime_copytm (s, maxsize, format, &tmcopy); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
407 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
408 # undef my_strftime |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
409 # define my_strftime(S, Maxsize, Format, Tp) \ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
410 _strftime_copytm (S, Maxsize, Format, Tp) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
411 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
412 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
413 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
414 /* Write information from TP into S according to the format |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
415 string FORMAT, writing no more that MAXSIZE characters |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
416 (including the terminating '\0') and returning number of |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
417 characters written. If S is NULL, nothing will be written |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
418 anywhere, so to determine how many characters would be |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
419 written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
420 size_t |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
421 my_strftime (s, maxsize, format, tp) |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
422 char *s; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
423 size_t maxsize; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
424 const char *format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
425 const struct tm *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
426 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
427 int hour12 = tp->tm_hour; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
428 #ifdef _NL_CURRENT |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
429 const char *const a_wkday = _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
430 const char *const f_wkday = _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
431 const char *const a_month = _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
432 const char *const f_month = _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
433 const char *const ampm = _NL_CURRENT (LC_TIME, |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
434 hour12 > 11 ? PM_STR : AM_STR); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
435 size_t aw_len = strlen (a_wkday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
436 size_t am_len = strlen (a_month); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
437 size_t ap_len = strlen (ampm); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
438 #else |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
439 # if !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
440 const char *const f_wkday = weekday_name[tp->tm_wday]; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
441 const char *const f_month = month_name[tp->tm_mon]; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
442 const char *const a_wkday = f_wkday; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
443 const char *const a_month = f_month; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
444 const char *const ampm = "AMPM" + 2 * (hour12 > 11); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
445 size_t aw_len = 3; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
446 size_t am_len = 3; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
447 size_t ap_len = 2; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
448 # endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
449 #endif |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
450 #if defined _NL_CURRENT || !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
451 size_t wkday_len = strlen (f_wkday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
452 size_t month_len = strlen (f_month); |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
453 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
454 const char *zone; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
455 size_t zonelen; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
456 size_t i = 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
457 char *p = s; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
458 const char *f; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
459 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
460 zone = NULL; |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
461 #if HAVE_TM_ZONE |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
462 /* The POSIX test suite assumes that setting |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
463 the environment variable TZ to a new value before calling strftime() |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
464 will influence the result (the %Z format) even if the information in |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
465 TP is computed with a totally different time zone. |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
466 This is bogus: though POSIX allows bad behavior like this, |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
467 POSIX does not require it. Do the right thing instead. */ |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
468 zone = (const char *) tp->tm_zone; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
469 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
470 #if HAVE_TZNAME |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
471 /* POSIX.1 8.1.1 requires that whenever strftime() is called, the |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
472 time zone names contained in the external variable `tzname' shall |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
473 be set as if the tzset() function had been called. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
474 # if HAVE_TZSET |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
475 tzset (); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
476 # endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
477 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
478 if (!(zone && *zone) && tp->tm_isdst >= 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
479 zone = tzname[tp->tm_isdst]; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
480 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
481 if (! zone) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
482 zone = ""; /* POSIX.2 requires the empty string here. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
483 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
484 zonelen = strlen (zone); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
485 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
486 if (hour12 > 12) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
487 hour12 -= 12; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
488 else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
489 if (hour12 == 0) hour12 = 12; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
490 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
491 for (f = format; *f != '\0'; ++f) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
492 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
493 int pad; /* Padding for number ('-', '_', or 0). */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
494 int modifier; /* Field modifier ('E', 'O', or 0). */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
495 int digits; /* Max digits for numeric format. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
496 int number_value; /* Numeric value to be printed. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
497 int negative_number; /* 1 if the number is negative. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
498 const char *subfmt; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
499 char *bufp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
500 char buf[1 + (sizeof (int) < sizeof (time_t) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
501 ? INT_STRLEN_BOUND (time_t) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
502 : INT_STRLEN_BOUND (int))]; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
503 int width = -1; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
504 int to_lowcase = 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
505 int to_uppcase = 0; |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
506 int change_case = 0; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
507 int format_char; |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
508 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
509 #if DO_MULTIBYTE |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
510 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
511 switch (*f) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
512 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
513 case '%': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
514 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
515 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
516 case '\a': case '\b': case '\t': case '\n': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
517 case '\v': case '\f': case '\r': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
518 case ' ': case '!': case '"': case '#': case '&': case'\'': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
519 case '(': case ')': case '*': case '+': case ',': case '-': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
520 case '.': case '/': case '0': case '1': case '2': case '3': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
521 case '4': case '5': case '6': case '7': case '8': case '9': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
522 case ':': case ';': case '<': case '=': case '>': case '?': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
523 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
524 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
525 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
526 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
527 case 'Y': case 'Z': case '[': case'\\': case ']': case '^': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
528 case '_': case 'a': case 'b': case 'c': case 'd': case 'e': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
529 case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
530 case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
531 case 'r': case 's': case 't': case 'u': case 'v': case 'w': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
532 case 'x': case 'y': case 'z': case '{': case '|': case '}': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
533 case '~': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
534 /* The C Standard requires these 98 characters (plus '%') to |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
535 be in the basic execution character set. None of these |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
536 characters can start a multibyte sequence, so they need |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
537 not be analyzed further. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
538 add (1, *p = *f); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
539 continue; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
540 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
541 default: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
542 /* Copy this multibyte sequence until we reach its end, find |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
543 an error, or come back to the initial shift state. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
544 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
545 mbstate_t mbstate = mbstate_zero; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
546 size_t len = 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
547 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
548 do |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
549 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
550 size_t bytes = mbrlen (f + len, (size_t) -1, &mbstate); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
551 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
552 if (bytes == 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
553 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
554 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
555 if (bytes == (size_t) -2 || bytes == (size_t) -1) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
556 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
557 len++; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
558 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
559 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
560 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
561 len += bytes; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
562 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
563 while (! mbsinit (&mbstate)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
564 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
565 cpy (len, f); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
566 continue; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
567 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
568 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
569 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
570 #else /* ! DO_MULTIBYTE */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
571 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
572 /* Either multibyte encodings are not supported, or they are |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
573 safe for formats, so any non-'%' byte can be copied through. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
574 if (*f != '%') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
575 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
576 add (1, *p = *f); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
577 continue; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
578 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
579 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
580 #endif /* ! DO_MULTIBYTE */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
581 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
582 /* Check for flags that can modify a format. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
583 pad = 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
584 while (1) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
585 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
586 switch (*++f) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
587 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
588 /* This influences the number formats. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
589 case '_': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
590 case '-': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
591 case '0': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
592 pad = *f; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
593 continue; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
594 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
595 /* This changes textual output. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
596 case '^': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
597 to_uppcase = 1; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
598 continue; |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
599 case '#': |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
600 change_case = 1; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
601 continue; |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
602 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
603 default: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
604 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
605 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
606 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
607 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
608 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
609 /* As a GNU extension we allow to specify the field width. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
610 if (ISDIGIT (*f)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
611 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
612 width = 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
613 do |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
614 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
615 width *= 10; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
616 width += *f - '0'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
617 ++f; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
618 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
619 while (ISDIGIT (*f)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
620 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
621 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
622 /* Check for modifiers. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
623 switch (*f) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
624 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
625 case 'E': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
626 case 'O': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
627 modifier = *f++; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
628 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
629 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
630 default: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
631 modifier = 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
632 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
633 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
634 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
635 /* Now do the specified format. */ |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
636 format_char = *f; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
637 switch (format_char) |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
638 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
639 #define DO_NUMBER(d, v) \ |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
640 digits = width == -1 ? d : width; \ |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
641 number_value = v; goto do_number |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
642 #define DO_NUMBER_SPACEPAD(d, v) \ |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
643 digits = width == -1 ? d : width; \ |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
644 number_value = v; goto do_number_spacepad |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
645 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
646 case '%': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
647 if (modifier != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
648 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
649 add (1, *p = *f); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
650 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
651 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
652 case 'a': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
653 if (modifier != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
654 goto bad_format; |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
655 if (change_case) |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
656 { |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
657 to_uppcase = 1; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
658 to_lowcase = 0; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
659 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
660 #if defined _NL_CURRENT || !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
661 cpy (aw_len, a_wkday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
662 break; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
663 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
664 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
665 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
666 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
667 case 'A': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
668 if (modifier != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
669 goto bad_format; |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
670 if (change_case) |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
671 { |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
672 to_uppcase = 1; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
673 to_lowcase = 0; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
674 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
675 #if defined _NL_CURRENT || !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
676 cpy (wkday_len, f_wkday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
677 break; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
678 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
679 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
680 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
681 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
682 case 'b': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
683 case 'h': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
684 if (modifier != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
685 goto bad_format; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
686 #if defined _NL_CURRENT || !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
687 cpy (am_len, a_month); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
688 break; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
689 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
690 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
691 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
692 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
693 case 'B': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
694 if (modifier != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
695 goto bad_format; |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
696 if (change_case) |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
697 { |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
698 to_uppcase = 1; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
699 to_lowcase = 0; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
700 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
701 #if defined _NL_CURRENT || !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
702 cpy (month_len, f_month); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
703 break; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
704 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
705 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
706 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
707 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
708 case 'c': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
709 if (modifier == 'O') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
710 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
711 #ifdef _NL_CURRENT |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
712 if (! (modifier == 'E' |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
713 && *(subfmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT)) != '\0')) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
714 subfmt = _NL_CURRENT (LC_TIME, D_T_FMT); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
715 #else |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
716 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
717 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
718 # else |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
719 subfmt = "%a %b %e %H:%M:%S %Y"; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
720 # endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
721 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
722 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
723 subformat: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
724 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
725 char *old_start = p; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
726 size_t len = my_strftime (NULL, maxsize - i, subfmt, tp); |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
727 if (len == 0 && *subfmt) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
728 return 0; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
729 add (len, my_strftime (p, maxsize - i, subfmt, tp)); |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
730 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
731 if (to_uppcase) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
732 while (old_start < p) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
733 { |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
734 *old_start = TOUPPER ((unsigned char) *old_start); |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
735 ++old_start; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
736 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
737 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
738 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
739 |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
740 #if HAVE_STRFTIME && ! (defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
741 underlying_strftime: |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
742 { |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
743 /* The relevant information is available only via the |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
744 underlying strftime implementation, so use that. */ |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
745 char ufmt[4]; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
746 char *u = ufmt; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
747 char ubuf[1024]; /* enough for any single format in practice */ |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
748 size_t len; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
749 *u++ = '%'; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
750 if (modifier != 0) |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
751 *u++ = modifier; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
752 *u++ = format_char; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
753 *u = '\0'; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
754 len = strftime (ubuf, sizeof ubuf, ufmt, tp); |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
755 if (len == 0) |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
756 return 0; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
757 cpy (len, ubuf); |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
758 } |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
759 break; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
760 #endif |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
761 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
762 case 'C': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
763 if (modifier == 'O') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
764 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
765 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
766 { |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
767 #if HAVE_STRUCT_ERA_ENTRY |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
768 struct era_entry *era = _nl_get_era_entry (tp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
769 if (era) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
770 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
771 size_t len = strlen (era->name_fmt); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
772 cpy (len, era->name_fmt); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
773 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
774 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
775 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
776 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
777 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
778 # endif |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
779 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
780 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
781 |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
782 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
783 int year = tp->tm_year + TM_YEAR_BASE; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
784 DO_NUMBER (1, year / 100 - (year % 100 < 0)); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
785 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
786 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
787 case 'x': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
788 if (modifier == 'O') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
789 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
790 #ifdef _NL_CURRENT |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
791 if (! (modifier == 'E' |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
792 && *(subfmt = _NL_CURRENT (LC_TIME, ERA_D_FMT)) != '\0')) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
793 subfmt = _NL_CURRENT (LC_TIME, D_FMT); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
794 goto subformat; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
795 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
796 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
797 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
798 # else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
799 /* Fall through. */ |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
800 # endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
801 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
802 case 'D': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
803 if (modifier != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
804 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
805 subfmt = "%m/%d/%y"; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
806 goto subformat; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
807 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
808 case 'd': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
809 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
810 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
811 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
812 DO_NUMBER (2, tp->tm_mday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
813 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
814 case 'e': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
815 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
816 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
817 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
818 DO_NUMBER_SPACEPAD (2, tp->tm_mday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
819 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
820 /* All numeric formats set DIGITS and NUMBER_VALUE and then |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
821 jump to one of these two labels. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
822 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
823 do_number_spacepad: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
824 /* Force `_' flag unless overwritten by `0' flag. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
825 if (pad != '0') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
826 pad = '_'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
827 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
828 do_number: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
829 /* Format the number according to the MODIFIER flag. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
830 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
831 if (modifier == 'O' && 0 <= number_value) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
832 { |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
833 #ifdef _NL_CURRENT |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
834 /* Get the locale specific alternate representation of |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
835 the number NUMBER_VALUE. If none exist NULL is returned. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
836 const char *cp = _nl_get_alt_digit (number_value); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
837 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
838 if (cp != NULL) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
839 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
840 size_t digitlen = strlen (cp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
841 if (digitlen != 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
842 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
843 cpy (digitlen, cp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
844 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
845 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
846 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
847 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
848 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
849 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
850 # endif |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
851 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
852 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
853 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
854 unsigned int u = number_value; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
855 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
856 bufp = buf + sizeof (buf); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
857 negative_number = number_value < 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
858 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
859 if (negative_number) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
860 u = -u; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
861 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
862 do |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
863 *--bufp = u % 10 + '0'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
864 while ((u /= 10) != 0); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
865 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
866 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
867 do_number_sign_and_padding: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
868 if (negative_number) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
869 *--bufp = '-'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
870 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
871 if (pad != '-') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
872 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
873 int padding = digits - (buf + sizeof (buf) - bufp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
874 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
875 if (pad == '_') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
876 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
877 while (0 < padding--) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
878 *--bufp = ' '; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
879 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
880 else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
881 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
882 bufp += negative_number; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
883 while (0 < padding--) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
884 *--bufp = '0'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
885 if (negative_number) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
886 *--bufp = '-'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
887 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
888 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
889 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
890 cpy (buf + sizeof (buf) - bufp, bufp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
891 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
892 |
20252
cb1aec706f64
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20212
diff
changeset
|
893 case 'F': |
cb1aec706f64
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20212
diff
changeset
|
894 if (modifier != 0) |
cb1aec706f64
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20212
diff
changeset
|
895 goto bad_format; |
cb1aec706f64
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20212
diff
changeset
|
896 subfmt = "%Y-%m-%d"; |
cb1aec706f64
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20212
diff
changeset
|
897 goto subformat; |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
898 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
899 case 'H': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
900 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
901 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
902 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
903 DO_NUMBER (2, tp->tm_hour); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
904 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
905 case 'I': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
906 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
907 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
908 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
909 DO_NUMBER (2, hour12); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
910 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
911 case 'k': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
912 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
913 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
914 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
915 DO_NUMBER_SPACEPAD (2, tp->tm_hour); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
916 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
917 case 'l': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
918 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
919 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
920 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
921 DO_NUMBER_SPACEPAD (2, hour12); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
922 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
923 case 'j': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
924 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
925 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
926 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
927 DO_NUMBER (3, 1 + tp->tm_yday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
928 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
929 case 'M': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
930 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
931 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
932 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
933 DO_NUMBER (2, tp->tm_min); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
934 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
935 case 'm': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
936 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
937 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
938 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
939 DO_NUMBER (2, tp->tm_mon + 1); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
940 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
941 case 'n': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
942 add (1, *p = '\n'); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
943 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
944 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
945 case 'P': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
946 to_lowcase = 1; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
947 #if !defined _NL_CURRENT && HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
948 format_char = 'p'; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
949 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
950 /* FALLTHROUGH */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
951 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
952 case 'p': |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
953 if (change_case) |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
954 { |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
955 to_uppcase = 0; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
956 to_lowcase = 1; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
957 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
958 #if defined _NL_CURRENT || !HAVE_STRFTIME |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
959 cpy (ap_len, ampm); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
960 break; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
961 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
962 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
963 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
964 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
965 case 'R': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
966 subfmt = "%H:%M"; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
967 goto subformat; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
968 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
969 case 'r': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
970 #ifdef _NL_CURRENT |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
971 if (*(subfmt = _NL_CURRENT (LC_TIME, T_FMT_AMPM)) == '\0') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
972 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
973 subfmt = "%I:%M:%S %p"; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
974 goto subformat; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
975 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
976 case 'S': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
977 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
978 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
979 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
980 DO_NUMBER (2, tp->tm_sec); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
981 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
982 case 's': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
983 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
984 struct tm ltm; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
985 time_t t; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
986 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
987 ltm = *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
988 t = mktime (<m); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
989 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
990 /* Generate string value for T using time_t arithmetic; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
991 this works even if sizeof (long) < sizeof (time_t). */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
992 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
993 bufp = buf + sizeof (buf); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
994 negative_number = t < 0; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
995 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
996 do |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
997 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
998 int d = t % 10; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
999 t /= 10; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1000 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1001 if (negative_number) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1002 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1003 d = -d; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1004 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1005 /* Adjust if division truncates to minus infinity. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1006 if (0 < -1 % 10 && d < 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1007 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1008 t++; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1009 d += 10; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1010 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1011 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1012 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1013 *--bufp = d + '0'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1014 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1015 while (t != 0); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1016 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1017 digits = 1; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1018 goto do_number_sign_and_padding; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1019 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1020 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1021 case 'X': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1022 if (modifier == 'O') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1023 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1024 #ifdef _NL_CURRENT |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1025 if (! (modifier == 'E' |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1026 && *(subfmt = _NL_CURRENT (LC_TIME, ERA_T_FMT)) != '\0')) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1027 subfmt = _NL_CURRENT (LC_TIME, T_FMT); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1028 goto subformat; |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1029 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1030 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1031 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1032 # else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1033 /* Fall through. */ |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1034 # endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1035 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1036 case 'T': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1037 subfmt = "%H:%M:%S"; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1038 goto subformat; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1039 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1040 case 't': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1041 add (1, *p = '\t'); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1042 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1043 |
20252
cb1aec706f64
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20212
diff
changeset
|
1044 case 'f': |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1045 case 'u': /* POSIX.2 extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1046 DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1047 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1048 case 'U': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1049 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1050 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1051 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1052 DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1053 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1054 case 'V': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1055 case 'g': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1056 case 'G': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1057 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1058 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1059 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1060 int year = tp->tm_year + TM_YEAR_BASE; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1061 int days = iso_week_days (tp->tm_yday, tp->tm_wday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1062 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1063 if (days < 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1064 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1065 /* This ISO week belongs to the previous year. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1066 year--; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1067 days = iso_week_days (tp->tm_yday + (365 + __isleap (year)), |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1068 tp->tm_wday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1069 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1070 else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1071 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1072 int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1073 tp->tm_wday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1074 if (0 <= d) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1075 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1076 /* This ISO week belongs to the next year. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1077 year++; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1078 days = d; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1079 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1080 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1081 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1082 switch (*f) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1083 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1084 case 'g': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1085 DO_NUMBER (2, (year % 100 + 100) % 100); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1086 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1087 case 'G': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1088 DO_NUMBER (1, year); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1089 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1090 default: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1091 DO_NUMBER (2, days / 7 + 1); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1092 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1093 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1094 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1095 case 'W': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1096 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1097 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1098 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1099 DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1100 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1101 case 'w': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1102 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1103 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1104 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1105 DO_NUMBER (1, tp->tm_wday); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1106 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1107 case 'Y': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1108 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1109 { |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1110 #if HAVE_STRUCT_ERA_ENTRY |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1111 struct era_entry *era = _nl_get_era_entry (tp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1112 if (era) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1113 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1114 subfmt = strchr (era->name_fmt, '\0') + 1; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1115 goto subformat; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1116 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1117 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1118 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1119 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1120 # endif |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1121 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1122 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1123 if (modifier == 'O') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1124 goto bad_format; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1125 else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1126 DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1127 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1128 case 'y': |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1129 if (modifier == 'E') |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1130 { |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1131 #if HAVE_STRUCT_ERA_ENTRY |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1132 struct era_entry *era = _nl_get_era_entry (tp); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1133 if (era) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1134 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1135 int delta = tp->tm_year - era->start_date[0]; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1136 DO_NUMBER (1, (era->offset |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1137 + (era->direction == '-' ? -delta : delta))); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1138 } |
20211
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1139 #else |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1140 # if HAVE_STRFTIME |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1141 goto underlying_strftime; |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1142 # endif |
f722b33c682d
automatically generated from GPLed version
Ulrich Drepper <drepper@redhat.com>
parents:
20010
diff
changeset
|
1143 #endif |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1144 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1145 DO_NUMBER (2, (tp->tm_year % 100 + 100) % 100); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1146 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1147 case 'Z': |
18781
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
1148 if (change_case) |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
1149 { |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
1150 to_uppcase = 0; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
1151 to_lowcase = 1; |
70883b60c7a5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
18488
diff
changeset
|
1152 } |
17502
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1153 cpy (zonelen, zone); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1154 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1155 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1156 case 'z': /* GNU extension. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1157 if (tp->tm_isdst < 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1158 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1159 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1160 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1161 int diff; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1162 #if HAVE_TM_GMTOFF |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1163 diff = tp->tm_gmtoff; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1164 #else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1165 struct tm gtm; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1166 struct tm ltm; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1167 time_t lt; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1168 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1169 ltm = *tp; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1170 lt = mktime (<m); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1171 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1172 if (lt == (time_t) -1) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1173 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1174 /* mktime returns -1 for errors, but -1 is also a |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1175 valid time_t value. Check whether an error really |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1176 occurred. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1177 struct tm tm; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1178 localtime_r (<, &tm); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1179 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1180 if ((ltm.tm_sec ^ tm.tm_sec) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1181 | (ltm.tm_min ^ tm.tm_min) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1182 | (ltm.tm_hour ^ tm.tm_hour) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1183 | (ltm.tm_mday ^ tm.tm_mday) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1184 | (ltm.tm_mon ^ tm.tm_mon) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1185 | (ltm.tm_year ^ tm.tm_year)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1186 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1187 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1188 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1189 if (! gmtime_r (<, >m)) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1190 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1191 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1192 diff = tm_diff (<m, >m); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1193 #endif |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1194 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1195 if (diff < 0) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1196 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1197 add (1, *p = '-'); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1198 diff = -diff; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1199 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1200 else |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1201 add (1, *p = '+'); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1202 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1203 diff /= 60; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1204 DO_NUMBER (4, (diff / 60) * 100 + diff % 60); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1205 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1206 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1207 case '\0': /* GNU extension: % at end of format. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1208 --f; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1209 /* Fall through. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1210 default: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1211 /* Unknown format; output the format, including the '%', |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1212 since this is most likely the right thing to do if a |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1213 multibyte string has been misparsed. */ |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1214 bad_format: |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1215 { |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1216 int flen; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1217 for (flen = 1; f[1 - flen] != '%'; flen++) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1218 continue; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1219 cpy (flen, &f[1 - flen]); |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1220 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1221 break; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1222 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1223 } |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1224 |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1225 if (p) |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1226 *p = '\0'; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1227 return i; |
8f3dcea869f5
automatically generated from GPLed version
Paul Eggert <eggert@twinsun.com>
parents:
diff
changeset
|
1228 } |