Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/strftime.c @ 14177:c6bc5712a6a9
strftime: remove dependencies on multibyte modules
strftime depended on mbrlen, mbsinit, and wchar, but these modules
are needed only if ! MULTIBYTE_IS_FORMAT_SAFE, and that is true
only if __osf__ is defined, and I suspect OSF doesn't need these
other modules. If my guess is wrong, we'll need to come up with a
variant of strftime that doesn't need the multibyte modules.
I discovered this problem when attempting modify Emacs to use the
strftime module. With the previous gnulib, this caused Emacs to
need 31 new files, ranging from lib/config.charset to
m4/wint_t.m4. This was overkill and I expect would be offputting
to the Emacs maintainers. After this change, only 6 new files are
needed, namely strftime.[ch], srtftime.m4, stdbool.in.h,
stdbool.m4, and tm_gmtoff.m4.
* lib/strftime.c (MULTIBYTE_IS_FORMAT_SAFE): Define to 1 always.
Suggested by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00238.html>.
* m4/strftime.m4 (gl_FUNC_STRFTIME): Do not require AC_TYPE_MBSTATE_T,
and do not check for wchar.h.
* modules/strftime (Files): Remove m4/mbstate_t.m4.
(Depends-on): Remove mbrlen, mbsinit, wchar.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 18 Jan 2011 09:40:16 -0800 |
parents | 97fc9a21a8fb |
children | fa909c29c50e |
rev | line source |
---|---|
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
1 /* Copyright (C) 1991-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. |
9 | 2 |
1058 | 3 NOTE: The canonical source of this file is maintained with the GNU C Library. |
4 Bugs can be reported to bug-glibc@prep.ai.mit.edu. | |
9 | 5 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8146
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
4422 | 7 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8146
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8146
diff
changeset
|
9 (at your option) any later version. |
9 | 10 |
1058 | 11 This program is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
4422 | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | |
782 | 15 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8146
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8146
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9 | 18 |
604 | 19 #ifdef _LIBC |
794 | 20 # define HAVE_STRUCT_ERA_ENTRY 1 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
21 # define HAVE_TM_GMTOFF 1 |
604 | 22 # define HAVE_TM_ZONE 1 |
813 | 23 # define HAVE_TZNAME 1 |
24 # define HAVE_TZSET 1 | |
604 | 25 # include "../locale/localeinfo.h" |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6932
diff
changeset
|
26 #else |
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6932
diff
changeset
|
27 # include <config.h> |
7455
8d41d3f68c28
Don't include <config.h> twice; this doesn't work in some cases,
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
28 # if FPRINTFTIME |
12257
37417e58ec13
strftime.c: include ignore-value.h only when FPRINTFTIME is defined
James Youngman <jay@gnu.org>
parents:
12206
diff
changeset
|
29 # include "ignore-value.h" |
7455
8d41d3f68c28
Don't include <config.h> twice; this doesn't work in some cases,
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
30 # include "fprintftime.h" |
11110 | 31 # else |
32 # include "strftime.h" | |
7455
8d41d3f68c28
Don't include <config.h> twice; this doesn't work in some cases,
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
33 # endif |
125 | 34 #endif |
35 | |
813 | 36 #include <ctype.h> |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7888
diff
changeset
|
37 #include <time.h> |
604 | 38 |
9626
def4f669ceac
Fix problem with getdate on mingw32 reported by Simon Josefsson
Paul Eggert <eggert@cs.ucla.edu>
parents:
9309
diff
changeset
|
39 #if HAVE_TZNAME && !HAVE_DECL_TZNAME |
801
da8cea3a8036
[HAVE_TZNAME]: Declare tzname.
Jim Meyering <jim@meyering.net>
parents:
797
diff
changeset
|
40 extern char *tzname[]; |
da8cea3a8036
[HAVE_TZNAME]: Declare tzname.
Jim Meyering <jim@meyering.net>
parents:
797
diff
changeset
|
41 #endif |
da8cea3a8036
[HAVE_TZNAME]: Declare tzname.
Jim Meyering <jim@meyering.net>
parents:
797
diff
changeset
|
42 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
43 /* Do multibyte processing if multibytes are supported, unless |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
44 multibyte sequences are safe in formats. Multibyte sequences are |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
45 safe if they cannot contain byte sequences that look like format |
11043
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
46 conversion specifications. The multibyte encodings used by the |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
47 C library on the various platforms (UTF-8, GB2312, GBK, CP936, |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
48 GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
49 SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
50 cannot occur in a multibyte character except in the first byte. |
14177
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
51 |
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
52 The DEC-HANYU encoding used on OSF/1 is not safe for formats, but |
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
53 this encoding has never been seen in real-life use, so we ignore |
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
54 it. */ |
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
55 #if !(defined __osf__ && 0) |
11043
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
56 # define MULTIBYTE_IS_FORMAT_SAFE 1 |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
57 #endif |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
58 #define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
59 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
60 #if DO_MULTIBYTE |
10990
7e8a454e9758
strftime: avoid compilation failure on Solaris 2.6
Jim Meyering <meyering@redhat.com>
parents:
9626
diff
changeset
|
61 # include <wchar.h> |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
62 static const mbstate_t mbstate_zero; |
604 | 63 #endif |
64 | |
4693 | 65 #include <limits.h> |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
66 #include <stdbool.h> |
4693 | 67 #include <stddef.h> |
68 #include <stdlib.h> | |
69 #include <string.h> | |
176 | 70 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
71 #ifdef COMPILE_WIDE |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
72 # include <endian.h> |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
73 # define CHAR_T wchar_t |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
74 # define UCHAR_T unsigned int |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
75 # define L_(Str) L##Str |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
76 # define NLW(Sym) _NL_W##Sym |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
77 |
2845
d5bcf4bb7938
Merge in changes from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
2430
diff
changeset
|
78 # define MEMCPY(d, s, n) __wmemcpy (d, s, n) |
d5bcf4bb7938
Merge in changes from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
2430
diff
changeset
|
79 # define STRLEN(s) __wcslen (s) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
80 |
1109 | 81 #else |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
82 # define CHAR_T char |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
83 # define UCHAR_T unsigned char |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
84 # define L_(Str) Str |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
85 # define NLW(Sym) Sym |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
86 |
4693 | 87 # define MEMCPY(d, s, n) memcpy (d, s, n) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
88 # define STRLEN(s) strlen (s) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
89 |
1109 | 90 #endif |
91 | |
5414
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
92 /* Shift A right by B bits portably, by dividing A by 2**B and |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
93 truncating towards minus infinity. A and B should be free of side |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
94 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
95 INT_BITS is the number of useful bits in an int. GNU code can |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
96 assume that INT_BITS is at least 32. |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
97 |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
98 ISO C99 says that A >> B is implementation-defined if A < 0. Some |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
99 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
100 right in the usual way when A < 0, so SHR falls back on division if |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
101 ordinary A >> B doesn't seem to be the usual signed shift. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
102 #define SHR(a, b) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
103 (-1 >> 1 == -1 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
104 ? (a) >> (b) \ |
5414
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
105 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
106 |
5775
73ab05626d30
Propagate intprops.h comment fixes to mktime.c and strftime.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5714
diff
changeset
|
107 /* Bound on length of the string representing an integer type or expression T. |
5691
ec62790f0938
Factor int-properties macros into a single file, except for
Paul Eggert <eggert@cs.ucla.edu>
parents:
5690
diff
changeset
|
108 Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; |
ec62790f0938
Factor int-properties macros into a single file, except for
Paul Eggert <eggert@cs.ucla.edu>
parents:
5690
diff
changeset
|
109 add 1 for integer division truncation; add 1 more for a minus sign |
ec62790f0938
Factor int-properties macros into a single file, except for
Paul Eggert <eggert@cs.ucla.edu>
parents:
5690
diff
changeset
|
110 if needed. */ |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
111 #define INT_STRLEN_BOUND(t) \ |
5691
ec62790f0938
Factor int-properties macros into a single file, except for
Paul Eggert <eggert@cs.ucla.edu>
parents:
5690
diff
changeset
|
112 ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
113 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
114 #define TM_YEAR_BASE 1900 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
115 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
116 #ifndef __isleap |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
117 /* Nonzero if YEAR is a leap year (every 4 years, |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
118 except every 100th isn't, and every 400th is). */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
119 # define __isleap(year) \ |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
120 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
121 #endif |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
122 |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
123 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
124 #ifdef _LIBC |
816 | 125 # define tzname __tzname |
126 # define tzset __tzset | |
4621
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
127 #endif |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
128 |
4621
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
129 #if !HAVE_TM_GMTOFF |
8146
b31580167c2b
New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
7897
diff
changeset
|
130 /* Portable standalone applications should supply a "time.h" that |
4621
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
131 declares a POSIX-compliant localtime_r, for the benefit of older |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
132 implementations that lack localtime_r or have a nonstandard one. |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
133 See the gnulib time_r module for one way to implement this. */ |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
134 # undef __gmtime_r |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
135 # undef __localtime_r |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
136 # define __gmtime_r gmtime_r |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
137 # define __localtime_r localtime_r |
3d28ad4e18e2
Add time_r module. Change timegm, mktime, and strftime to use localtime_r
Paul Eggert <eggert@cs.ucla.edu>
parents:
4558
diff
changeset
|
138 #endif |
9 | 139 |
140 | |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
141 #ifndef FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
142 # define FPRINTFTIME 0 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
143 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
144 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
145 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
146 # define STREAM_OR_CHAR_T FILE |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
147 # define STRFTIME_ARG(x) /* empty */ |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
148 #else |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
149 # define STREAM_OR_CHAR_T CHAR_T |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
150 # define STRFTIME_ARG(x) x, |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
151 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
152 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
153 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
154 # define memset_byte(P, Len, Byte) \ |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
155 do { size_t _i; for (_i = 0; _i < Len; _i++) fputc (Byte, P); } while (0) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
156 # define memset_space(P, Len) memset_byte (P, Len, ' ') |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
157 # define memset_zero(P, Len) memset_byte (P, Len, '0') |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
158 #elif defined COMPILE_WIDE |
4693 | 159 # define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) |
160 # define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) | |
813 | 161 #else |
4693 | 162 # define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) |
163 # define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) | |
813 | 164 #endif |
165 | |
7524
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
166 #if FPRINTFTIME |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
167 # define advance(P, N) |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
168 #else |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
169 # define advance(P, N) ((P) += (N)) |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
170 #endif |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
171 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
172 #define add(n, f) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
173 do \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
174 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
175 int _n = (n); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
176 int _delta = width - _n; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
177 int _incr = _n + (_delta > 0 ? _delta : 0); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
178 if ((size_t) _incr >= maxsize - i) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
179 return 0; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
180 if (p) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
181 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
182 if (digits == 0 && _delta > 0) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
183 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
184 if (pad == L_('0')) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
185 memset_zero (p, _delta); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
186 else \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
187 memset_space (p, _delta); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
188 } \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
189 f; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
190 advance (p, _n); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
191 } \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
192 i += _incr; \ |
604 | 193 } while (0) |
813 | 194 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
195 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
196 # define add1(C) add (1, fputc (C, p)) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
197 #else |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
198 # define add1(C) add (1, *p = C) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
199 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
200 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
201 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
202 # define cpy(n, s) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
203 add ((n), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
204 do \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
205 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
206 if (to_lowcase) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
207 fwrite_lowcase (p, (s), _n); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
208 else if (to_uppcase) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
209 fwrite_uppcase (p, (s), _n); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
210 else \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
211 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
212 /* We are ignoring the value of fwrite here, in spite of the \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
213 fact that technically, that may not be valid: the fwrite \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
214 specification in POSIX 2008 defers to that of fputc, which \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
215 is intended to be consistent with the one from ISO C, \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
216 which permits failure due to ENOMEM *without* setting the \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
217 stream's error indicator. */ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
218 ignore_value (fwrite ((s), _n, 1, p)); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
219 } \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
220 } \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
221 while (0) \ |
12206
5b7b0b8645f1
fprintftime: wrap macro code argument in "do {...} while(0)"
Jim Meyering <meyering@redhat.com>
parents:
12205
diff
changeset
|
222 ) |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
223 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
224 # define cpy(n, s) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
225 add ((n), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
226 if (to_lowcase) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
227 memcpy_lowcase (p, (s), _n LOCALE_ARG); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
228 else if (to_uppcase) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
229 memcpy_uppcase (p, (s), _n LOCALE_ARG); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
230 else \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
231 MEMCPY ((void *) p, (void const *) (s), _n)) |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
232 #endif |
813 | 233 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
234 #ifdef COMPILE_WIDE |
4297
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
235 # ifndef USE_IN_EXTENDED_LOCALE_MODEL |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
236 # undef __mbsrtowcs_l |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
237 # define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
238 # endif |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
239 # define widen(os, ws, l) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
240 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
241 mbstate_t __st; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
242 const char *__s = os; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
243 memset (&__st, '\0', sizeof (__st)); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
244 l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
245 ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
246 (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
247 } |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
248 #endif |
813 | 249 |
250 | |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
251 #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
252 /* We use this code also for the extended locale handling where the |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
253 function gets as an additional argument the locale which has to be |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
254 used. To access the values we have to redefine the _NL_CURRENT |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
255 macro. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
256 # define strftime __strftime_l |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
257 # define wcsftime __wcsftime_l |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
258 # undef _NL_CURRENT |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
259 # define _NL_CURRENT(category, item) \ |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
260 (current->values[_NL_ITEM_INDEX (item)].string) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
261 # define LOCALE_ARG , loc |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
262 # define LOCALE_PARAM_PROTO , __locale_t loc |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
263 # define HELPER_LOCALE_ARG , current |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
264 #else |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
265 # define LOCALE_PARAM_PROTO |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
266 # define LOCALE_ARG |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
267 # ifdef _LIBC |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
268 # define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
269 # else |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
270 # define HELPER_LOCALE_ARG |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
271 # endif |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
272 #endif |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
273 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
274 #ifdef COMPILE_WIDE |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
275 # ifdef USE_IN_EXTENDED_LOCALE_MODEL |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
276 # define TOUPPER(Ch, L) __towupper_l (Ch, L) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
277 # define TOLOWER(Ch, L) __towlower_l (Ch, L) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
278 # else |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
279 # define TOUPPER(Ch, L) towupper (Ch) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
280 # define TOLOWER(Ch, L) towlower (Ch) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
281 # endif |
813 | 282 #else |
6932
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
283 # ifdef USE_IN_EXTENDED_LOCALE_MODEL |
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
284 # define TOUPPER(Ch, L) __toupper_l (Ch, L) |
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
285 # define TOLOWER(Ch, L) __tolower_l (Ch, L) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
286 # else |
6932
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
287 # define TOUPPER(Ch, L) toupper (Ch) |
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
288 # define TOLOWER(Ch, L) tolower (Ch) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
289 # endif |
813 | 290 #endif |
819 | 291 /* We don't use `isdigit' here since the locale dependent |
292 interpretation is not what we want here. We only need to accept | |
293 the arabic digits in the ASCII range. One day there is perhaps a | |
294 more reliable way to accept other sets of digits. */ | |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
295 #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
296 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
297 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
298 static void |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
299 fwrite_lowcase (FILE *fp, const CHAR_T *src, size_t len) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
300 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
301 while (len-- > 0) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
302 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
303 fputc (TOLOWER ((UCHAR_T) *src, loc), fp); |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
304 ++src; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
305 } |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
306 } |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
307 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
308 static void |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
309 fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
310 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
311 while (len-- > 0) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
312 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
313 fputc (TOUPPER ((UCHAR_T) *src, loc), fp); |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
314 ++src; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
315 } |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
316 } |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
317 #else |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
318 static CHAR_T * |
4693 | 319 memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
320 size_t len LOCALE_PARAM_PROTO) |
813 | 321 { |
322 while (len-- > 0) | |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
323 dest[len] = TOLOWER ((UCHAR_T) src[len], loc); |
813 | 324 return dest; |
325 } | |
9 | 326 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
327 static CHAR_T * |
4693 | 328 memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
329 size_t len LOCALE_PARAM_PROTO) |
816 | 330 { |
331 while (len-- > 0) | |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
332 dest[len] = TOUPPER ((UCHAR_T) src[len], loc); |
816 | 333 return dest; |
334 } | |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
335 #endif |
816 | 336 |
1058 | 337 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
338 #if ! HAVE_TM_GMTOFF |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
339 /* Yield the difference between *A and *B, |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
340 measured in seconds, ignoring leap seconds. */ |
1058 | 341 # define tm_diff ftime_tm_diff |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
342 static int |
4759
27c6099e6a9f
* strftime.c (tm_diff) [! HAVE_TM_GMTOFF]: Fix arg typo in previous patch.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4693
diff
changeset
|
343 tm_diff (const struct tm *a, const struct tm *b) |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
344 { |
794 | 345 /* Compute intervening leap days correctly even if year is negative. |
346 Take care to avoid int overflow in leap day calculations, | |
347 but it's OK to assume that A and B are close to each other. */ | |
5414
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
348 int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
349 int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); |
794 | 350 int a100 = a4 / 25 - (a4 % 25 < 0); |
351 int b100 = b4 / 25 - (b4 % 25 < 0); | |
5414
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
352 int a400 = SHR (a100, 2); |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
353 int b400 = SHR (b100, 2); |
794 | 354 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); |
355 int years = a->tm_year - b->tm_year; | |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
356 int days = (365 * years + intervening_leap_days |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
357 + (a->tm_yday - b->tm_yday)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
358 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
359 + (a->tm_min - b->tm_min)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
360 + (a->tm_sec - b->tm_sec)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
361 } |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
362 #endif /* ! HAVE_TM_GMTOFF */ |
9 | 363 |
604 | 364 |
9 | 365 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
366 /* The number of days from the first day of the first ISO week of this |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
367 year to the year day YDAY with week day WDAY. ISO weeks start on |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
368 Monday; the first ISO week has the year's first Thursday. YDAY may |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
369 be as small as YDAY_MINIMUM. */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
370 #define ISO_WEEK_START_WDAY 1 /* Monday */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
371 #define ISO_WEEK1_WDAY 4 /* Thursday */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
372 #define YDAY_MINIMUM (-366) |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
373 #ifdef __GNUC__ |
1058 | 374 __inline__ |
604 | 375 #endif |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
376 static int |
4693 | 377 iso_week_days (int yday, int wday) |
604 | 378 { |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
379 /* Add enough to the first operand of % to make it nonnegative. */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
380 int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
381 return (yday |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
382 - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
383 + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
384 } |
9 | 385 |
386 | |
3261 | 387 /* When compiling this file, GNU applications can #define my_strftime |
388 to a symbol (typically nstrftime) to get an extended strftime with | |
389 extra arguments UT and NS. Emacs is a special case for now, but | |
390 this Emacs-specific code can be removed once Emacs's config.h | |
391 defines my_strftime. */ | |
392 #if defined emacs && !defined my_strftime | |
393 # define my_strftime nstrftime | |
394 #endif | |
395 | |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
396 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
397 # undef my_strftime |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
398 # define my_strftime fprintftime |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
399 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
400 |
3261 | 401 #ifdef my_strftime |
402 # define extra_args , ut, ns | |
4693 | 403 # define extra_args_spec , int ut, int ns |
1109 | 404 #else |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
405 # if defined COMPILE_WIDE |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
406 # define my_strftime wcsftime |
4297
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
407 # define nl_get_alt_digit _nl_get_walt_digit |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
408 # else |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
409 # define my_strftime strftime |
4297
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
410 # define nl_get_alt_digit _nl_get_alt_digit |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
411 # endif |
3261 | 412 # define extra_args |
413 # define extra_args_spec | |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
414 /* We don't have this information in general. */ |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
415 # define ut 0 |
3261 | 416 # define ns 0 |
1109 | 417 #endif |
418 | |
860
68da68da125e
(_strftime_copytm): New function, to work around Solaris 2.5 tzset bug.
Jim Meyering <jim@meyering.net>
parents:
829
diff
changeset
|
419 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
420 /* Just like my_strftime, below, but with one more parameter, UPCASE, |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
421 to indicate that the result should be converted to upper case. */ |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
422 static size_t |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
423 strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
424 STRFTIME_ARG (size_t maxsize) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
425 const CHAR_T *format, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
426 const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) |
604 | 427 { |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
428 #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
429 struct locale_data *const current = loc->__locales[LC_TIME]; |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
430 #endif |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
431 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
432 size_t maxsize = (size_t) -1; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
433 #endif |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
434 |
604 | 435 int hour12 = tp->tm_hour; |
436 #ifdef _NL_CURRENT | |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
437 /* We cannot make the following values variables since we must delay |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
438 the evaluation of these values until really needed since some |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
439 expressions might not be valid in every situation. The `struct tm' |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
440 might be generated by a strptime() call that initialized |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
441 only a few elements. Dereference the pointers only if the format |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
442 requires this. Then it is ok to fail if the pointers are invalid. */ |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
443 # define a_wkday \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
444 ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
445 # define f_wkday \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
446 ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
447 # define a_month \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
448 ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
449 # define f_month \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
450 ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
451 # define ampm \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
452 ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
453 ? NLW(PM_STR) : NLW(AM_STR))) |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
454 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
455 # define aw_len STRLEN (a_wkday) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
456 # define am_len STRLEN (a_month) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
457 # define ap_len STRLEN (ampm) |
604 | 458 #endif |
459 const char *zone; | |
813 | 460 size_t i = 0; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
461 STREAM_OR_CHAR_T *p = s; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
462 const CHAR_T *f; |
2993
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
463 #if DO_MULTIBYTE && !defined COMPILE_WIDE |
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
464 const char *format_end = NULL; |
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
465 #endif |
582
3ec26150a8d6
(mon_week_ISO): New function to implement new %V format.
Jim Meyering <jim@meyering.net>
parents:
581
diff
changeset
|
466 |
5960
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
467 #if ! defined _LIBC && ! HAVE_RUN_TZSET_TEST |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
468 /* Solaris 2.5.x and 2.6 tzset sometimes modify the storage returned |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
469 by localtime. On such systems, we must either use the tzset and |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
470 localtime wrappers to work around the bug (which sets |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
471 HAVE_RUN_TZSET_TEST) or make a copy of the structure. */ |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
472 struct tm copy = *tp; |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
473 tp = © |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
474 #endif |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
475 |
813 | 476 zone = NULL; |
1058 | 477 #if HAVE_TM_ZONE |
478 /* The POSIX test suite assumes that setting | |
813 | 479 the environment variable TZ to a new value before calling strftime() |
480 will influence the result (the %Z format) even if the information in | |
1058 | 481 TP is computed with a totally different time zone. |
482 This is bogus: though POSIX allows bad behavior like this, | |
483 POSIX does not require it. Do the right thing instead. */ | |
604 | 484 zone = (const char *) tp->tm_zone; |
485 #endif | |
486 #if HAVE_TZNAME | |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
487 if (ut) |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
488 { |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
489 if (! (zone && *zone)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
490 zone = "GMT"; |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
491 } |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
492 else |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
493 { |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
494 /* POSIX.1 requires that local time zone information be used as |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
495 though strftime called tzset. */ |
813 | 496 # if HAVE_TZSET |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
497 tzset (); |
813 | 498 # endif |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
499 } |
604 | 500 #endif |
501 | |
502 if (hour12 > 12) | |
503 hour12 -= 12; | |
504 else | |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
505 if (hour12 == 0) |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
506 hour12 = 12; |
604 | 507 |
508 for (f = format; *f != '\0'; ++f) | |
582
3ec26150a8d6
(mon_week_ISO): New function to implement new %V format.
Jim Meyering <jim@meyering.net>
parents:
581
diff
changeset
|
509 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
510 int pad = 0; /* Padding for number ('-', '_', or 0). */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
511 int modifier; /* Field modifier ('E', 'O', or 0). */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
512 int digits = 0; /* Max digits for numeric format. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
513 int number_value; /* Numeric value to be printed. */ |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
514 unsigned int u_number_value; /* (unsigned int) number_value. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
515 bool negative_number; /* The number is negative. */ |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
516 bool always_output_a_sign; /* +/- should always be output. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
517 int tz_colon_mask; /* Bitmask of where ':' should appear. */ |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
518 const CHAR_T *subfmt; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
519 CHAR_T sign_char; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
520 CHAR_T *bufp; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
521 CHAR_T buf[1 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
522 + 2 /* for the two colons in a %::z or %:::z time zone */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
523 + (sizeof (int) < sizeof (time_t) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
524 ? INT_STRLEN_BOUND (time_t) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
525 : INT_STRLEN_BOUND (int))]; |
813 | 526 int width = -1; |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
527 bool to_lowcase = false; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
528 bool to_uppcase = upcase; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
529 size_t colons; |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
530 bool change_case = false; |
1109 | 531 int format_char; |
9 | 532 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
533 #if DO_MULTIBYTE && !defined COMPILE_WIDE |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
534 switch (*f) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
535 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
536 case L_('%'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
537 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
538 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
539 case L_('\b'): case L_('\t'): case L_('\n'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
540 case L_('\v'): case L_('\f'): case L_('\r'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
541 case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
542 case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
543 case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
544 case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
545 case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
546 case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
547 case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
548 case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
549 case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
550 case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
551 case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
552 case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
553 case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
554 case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
555 case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
556 case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
557 case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
558 case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
559 case L_('~'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
560 /* The C Standard requires these 98 characters (plus '%') to |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
561 be in the basic execution character set. None of these |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
562 characters can start a multibyte sequence, so they need |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
563 not be analyzed further. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
564 add1 (*f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
565 continue; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
566 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
567 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
568 /* Copy this multibyte sequence until we reach its end, find |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
569 an error, or come back to the initial shift state. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
570 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
571 mbstate_t mbstate = mbstate_zero; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
572 size_t len = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
573 size_t fsize; |
2993
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
574 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
575 if (! format_end) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
576 format_end = f + strlen (f) + 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
577 fsize = format_end - f; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
578 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
579 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
580 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
581 size_t bytes = mbrlen (f + len, fsize - len, &mbstate); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
582 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
583 if (bytes == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
584 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
585 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
586 if (bytes == (size_t) -2) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
587 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
588 len += strlen (f + len); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
589 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
590 } |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
591 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
592 if (bytes == (size_t) -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
593 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
594 len++; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
595 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
596 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
597 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
598 len += bytes; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
599 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
600 while (! mbsinit (&mbstate)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
601 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
602 cpy (len, f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
603 f += len - 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
604 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
605 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
606 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
607 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
608 #else /* ! DO_MULTIBYTE */ |
9 | 609 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
610 /* Either multibyte encodings are not supported, they are |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
611 safe for formats, so any non-'%' byte can be copied through, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
612 or this is the wide character version. */ |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
613 if (*f != L_('%')) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
614 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
615 add1 (*f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
616 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
617 } |
9 | 618 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
619 #endif /* ! DO_MULTIBYTE */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
620 |
829 | 621 /* Check for flags that can modify a format. */ |
813 | 622 while (1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
623 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
624 switch (*++f) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
625 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
626 /* This influences the number formats. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
627 case L_('_'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
628 case L_('-'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
629 case L_('0'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
630 pad = *f; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
631 continue; |
816 | 632 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
633 /* This changes textual output. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
634 case L_('^'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
635 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
636 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
637 case L_('#'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
638 change_case = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
639 continue; |
813 | 640 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
641 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
642 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
643 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
644 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
645 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
646 |
813 | 647 /* As a GNU extension we allow to specify the field width. */ |
819 | 648 if (ISDIGIT (*f)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
649 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
650 width = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
651 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
652 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
653 if (width > INT_MAX / 10 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
654 || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
655 /* Avoid overflow. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
656 width = INT_MAX; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
657 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
658 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
659 width *= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
660 width += *f - L_('0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
661 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
662 ++f; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
663 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
664 while (ISDIGIT (*f)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
665 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
666 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
667 /* Check for modifiers. */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
668 switch (*f) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
669 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
670 case L_('E'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
671 case L_('O'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
672 modifier = *f++; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
673 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
674 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
675 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
676 modifier = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
677 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
678 } |
9 | 679 |
604 | 680 /* Now do the specified format. */ |
1109 | 681 format_char = *f; |
682 switch (format_char) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
683 { |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
684 #define DO_NUMBER(d, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
685 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
686 number_value = v; goto do_number |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
687 #define DO_SIGNED_NUMBER(d, negative, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
688 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
689 negative_number = negative; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
690 u_number_value = v; goto do_signed_number |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
691 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
692 /* The mask is not what you might think. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
693 When the ordinal i'th bit is set, insert a colon |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
694 before the i'th digit of the time zone representation. */ |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
695 #define DO_TZ_OFFSET(d, negative, mask, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
696 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
697 negative_number = negative; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
698 tz_colon_mask = mask; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
699 u_number_value = v; goto do_tz_offset |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
700 #define DO_NUMBER_SPACEPAD(d, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
701 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
702 number_value = v; goto do_number_spacepad |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
703 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
704 case L_('%'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
705 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
706 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
707 add1 (*f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
708 break; |
604 | 709 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
710 case L_('a'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
711 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
712 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
713 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
714 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
715 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
716 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
717 } |
6893 | 718 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
719 cpy (aw_len, a_wkday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
720 break; |
1109 | 721 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
722 goto underlying_strftime; |
1109 | 723 #endif |
604 | 724 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
725 case 'A': |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
726 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
727 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
728 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
729 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
730 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
731 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
732 } |
6893 | 733 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
734 cpy (STRLEN (f_wkday), f_wkday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
735 break; |
1109 | 736 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
737 goto underlying_strftime; |
1109 | 738 #endif |
604 | 739 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
740 case L_('b'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
741 case L_('h'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
742 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
743 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
744 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
745 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
746 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
747 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
748 goto bad_format; |
6893 | 749 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
750 cpy (am_len, a_month); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
751 break; |
1109 | 752 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
753 goto underlying_strftime; |
1109 | 754 #endif |
604 | 755 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
756 case L_('B'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
757 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
758 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
759 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
760 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
761 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
762 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
763 } |
6893 | 764 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
765 cpy (STRLEN (f_month), f_month); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
766 break; |
1109 | 767 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
768 goto underlying_strftime; |
1109 | 769 #endif |
9 | 770 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
771 case L_('c'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
772 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
773 goto bad_format; |
604 | 774 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
775 if (! (modifier == 'E' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
776 && (*(subfmt = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
777 (const CHAR_T *) _NL_CURRENT (LC_TIME, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
778 NLW(ERA_D_T_FMT))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
779 != '\0'))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
780 subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); |
604 | 781 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
782 goto underlying_strftime; |
604 | 783 #endif |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
784 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
785 subformat: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
786 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
787 size_t len = strftime_case_ (to_uppcase, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
788 NULL, STRFTIME_ARG ((size_t) -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
789 subfmt, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
790 tp extra_args LOCALE_ARG); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
791 add (len, strftime_case_ (to_uppcase, p, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
792 STRFTIME_ARG (maxsize - i) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
793 subfmt, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
794 tp extra_args LOCALE_ARG)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
795 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
796 break; |
604 | 797 |
6893 | 798 #if !(defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
799 underlying_strftime: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
800 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
801 /* The relevant information is available only via the |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
802 underlying strftime implementation, so use that. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
803 char ufmt[5]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
804 char *u = ufmt; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
805 char ubuf[1024]; /* enough for any single format in practice */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
806 size_t len; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
807 /* Make sure we're calling the actual underlying strftime. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
808 In some cases, config.h contains something like |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
809 "#define strftime rpl_strftime". */ |
2378
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
810 # ifdef strftime |
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
811 # undef strftime |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
812 size_t strftime (); |
2378
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
813 # endif |
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
814 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
815 /* The space helps distinguish strftime failure from empty |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
816 output. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
817 *u++ = ' '; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
818 *u++ = '%'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
819 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
820 *u++ = modifier; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
821 *u++ = format_char; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
822 *u = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
823 len = strftime (ubuf, sizeof ubuf, ufmt, tp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
824 if (len != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
825 cpy (len - 1, ubuf + 1); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
826 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
827 break; |
1109 | 828 #endif |
829 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
830 case L_('C'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
831 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
832 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
833 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
834 { |
1109 | 835 #if HAVE_STRUCT_ERA_ENTRY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
836 struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
837 if (era) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
838 { |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
839 # ifdef COMPILE_WIDE |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
840 size_t len = __wcslen (era->era_wname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
841 cpy (len, era->era_wname); |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
842 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
843 size_t len = strlen (era->era_name); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
844 cpy (len, era->era_name); |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
845 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
846 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
847 } |
1109 | 848 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
849 goto underlying_strftime; |
1109 | 850 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
851 } |
1109 | 852 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
853 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
854 int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
855 century -= tp->tm_year % 100 < 0 && 0 < century; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
856 DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
857 } |
9 | 858 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
859 case L_('x'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
860 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
861 goto bad_format; |
604 | 862 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
863 if (! (modifier == L_('E') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
864 && (*(subfmt = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
865 (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
866 != L_('\0')))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
867 subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
868 goto subformat; |
1109 | 869 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
870 goto underlying_strftime; |
604 | 871 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
872 case L_('D'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
873 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
874 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
875 subfmt = L_("%m/%d/%y"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
876 goto subformat; |
604 | 877 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
878 case L_('d'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
879 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
880 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
881 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
882 DO_NUMBER (2, tp->tm_mday); |
604 | 883 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
884 case L_('e'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
885 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
886 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
887 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
888 DO_NUMBER_SPACEPAD (2, tp->tm_mday); |
176 | 889 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
890 /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
891 and then jump to one of these labels. */ |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
892 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
893 do_tz_offset: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
894 always_output_a_sign = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
895 goto do_number_body; |
604 | 896 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
897 do_number_spacepad: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
898 /* Force `_' flag unless overridden by `0' or `-' flag. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
899 if (pad != L_('0') && pad != L_('-')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
900 pad = L_('_'); |
176 | 901 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
902 do_number: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
903 /* Format NUMBER_VALUE according to the MODIFIER flag. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
904 negative_number = number_value < 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
905 u_number_value = number_value; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
906 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
907 do_signed_number: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
908 always_output_a_sign = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
909 tz_colon_mask = 0; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
910 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
911 do_number_body: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
912 /* Format U_NUMBER_VALUE according to the MODIFIER flag. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
913 NEGATIVE_NUMBER is nonzero if the original number was |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
914 negative; in this case it was converted directly to |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
915 unsigned int (i.e., modulo (UINT_MAX + 1)) without |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
916 negating it. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
917 if (modifier == L_('O') && !negative_number) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
918 { |
1109 | 919 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
920 /* Get the locale specific alternate representation of |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
921 the number. If none exist NULL is returned. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
922 const CHAR_T *cp = nl_get_alt_digit (u_number_value |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
923 HELPER_LOCALE_ARG); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
924 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
925 if (cp != NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
926 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
927 size_t digitlen = STRLEN (cp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
928 if (digitlen != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
929 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
930 cpy (digitlen, cp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
931 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
932 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
933 } |
1109 | 934 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
935 goto underlying_strftime; |
1109 | 936 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
937 } |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
938 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
939 bufp = buf + sizeof (buf) / sizeof (buf[0]); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
940 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
941 if (negative_number) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
942 u_number_value = - u_number_value; |
604 | 943 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
944 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
945 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
946 if (tz_colon_mask & 1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
947 *--bufp = ':'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
948 tz_colon_mask >>= 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
949 *--bufp = u_number_value % 10 + L_('0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
950 u_number_value /= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
951 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
952 while (u_number_value != 0 || tz_colon_mask != 0); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
953 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
954 do_number_sign_and_padding: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
955 if (digits < width) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
956 digits = width; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
957 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
958 sign_char = (negative_number ? L_('-') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
959 : always_output_a_sign ? L_('+') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
960 : 0); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
961 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
962 if (pad == L_('-')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
963 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
964 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
965 add1 (sign_char); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
966 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
967 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
968 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
969 int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
970 - bufp) - !!sign_char; |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
971 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
972 if (padding > 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
973 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
974 if (pad == L_('_')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
975 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
976 if ((size_t) padding >= maxsize - i) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
977 return 0; |
4298 | 978 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
979 if (p) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
980 memset_space (p, padding); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
981 i += padding; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
982 width = width > padding ? width - padding : 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
983 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
984 add1 (sign_char); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
985 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
986 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
987 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
988 if ((size_t) digits >= maxsize - i) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
989 return 0; |
4298 | 990 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
991 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
992 add1 (sign_char); |
4298 | 993 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
994 if (p) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
995 memset_zero (p, padding); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
996 i += padding; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
997 width = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
998 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
999 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1000 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1001 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1002 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1003 add1 (sign_char); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1004 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1005 } |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1006 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1007 cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1008 break; |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1009 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1010 case L_('F'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1011 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1012 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1013 subfmt = L_("%Y-%m-%d"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1014 goto subformat; |
604 | 1015 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1016 case L_('H'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1017 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1018 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1019 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1020 DO_NUMBER (2, tp->tm_hour); |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1021 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1022 case L_('I'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1023 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1024 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1025 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1026 DO_NUMBER (2, hour12); |
604 | 1027 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1028 case L_('k'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1029 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1030 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1031 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1032 DO_NUMBER_SPACEPAD (2, tp->tm_hour); |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1033 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1034 case L_('l'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1035 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1036 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1037 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1038 DO_NUMBER_SPACEPAD (2, hour12); |
604 | 1039 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1040 case L_('j'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1041 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1042 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1043 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1044 DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1045 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1046 case L_('M'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1047 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1048 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1049 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1050 DO_NUMBER (2, tp->tm_min); |
604 | 1051 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1052 case L_('m'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1053 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1054 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1055 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1056 DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); |
604 | 1057 |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1058 #ifndef _LIBC |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1059 case L_('N'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1060 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1061 goto bad_format; |
3261 | 1062 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1063 number_value = ns; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1064 if (width == -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1065 width = 9; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1066 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1067 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1068 /* Take an explicit width less than 9 as a precision. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1069 int j; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1070 for (j = width; j < 9; j++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1071 number_value /= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1072 } |
3261 | 1073 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1074 DO_NUMBER (width, number_value); |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1075 #endif |
3261 | 1076 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1077 case L_('n'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1078 add1 (L_('\n')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1079 break; |
604 | 1080 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1081 case L_('P'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1082 to_lowcase = true; |
6893 | 1083 #ifndef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1084 format_char = L_('p'); |
1109 | 1085 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1086 /* FALLTHROUGH */ |
813 | 1087 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1088 case L_('p'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1089 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1090 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1091 to_uppcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1092 to_lowcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1093 } |
6893 | 1094 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1095 cpy (ap_len, ampm); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1096 break; |
1109 | 1097 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1098 goto underlying_strftime; |
1109 | 1099 #endif |
9 | 1100 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1101 case L_('R'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1102 subfmt = L_("%H:%M"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1103 goto subformat; |
604 | 1104 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1105 case L_('r'): |
6893 | 1106 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1107 if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1108 NLW(T_FMT_AMPM))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1109 == L_('\0')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1110 subfmt = L_("%I:%M:%S %p"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1111 goto subformat; |
6893 | 1112 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1113 goto underlying_strftime; |
4558 | 1114 #endif |
604 | 1115 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1116 case L_('S'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1117 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1118 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1119 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1120 DO_NUMBER (2, tp->tm_sec); |
604 | 1121 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1122 case L_('s'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1123 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1124 struct tm ltm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1125 time_t t; |
726
8867c987f8cf
(strftime): Accommodate the broken C compiler
Jim Meyering <jim@meyering.net>
parents:
691
diff
changeset
|
1126 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1127 ltm = *tp; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1128 t = mktime (<m); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1129 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1130 /* Generate string value for T using time_t arithmetic; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1131 this works even if sizeof (long) < sizeof (time_t). */ |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1132 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1133 bufp = buf + sizeof (buf) / sizeof (buf[0]); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1134 negative_number = t < 0; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1135 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1136 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1137 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1138 int d = t % 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1139 t /= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1140 *--bufp = (negative_number ? -d : d) + L_('0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1141 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1142 while (t != 0); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1143 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1144 digits = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1145 always_output_a_sign = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1146 goto do_number_sign_and_padding; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1147 } |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
1148 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1149 case L_('X'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1150 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1151 goto bad_format; |
604 | 1152 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1153 if (! (modifier == L_('E') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1154 && (*(subfmt = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1155 (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1156 != L_('\0')))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1157 subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1158 goto subformat; |
1109 | 1159 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1160 goto underlying_strftime; |
604 | 1161 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1162 case L_('T'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1163 subfmt = L_("%H:%M:%S"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1164 goto subformat; |
604 | 1165 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1166 case L_('t'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1167 add1 (L_('\t')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1168 break; |
604 | 1169 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1170 case L_('u'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1171 DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1172 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1173 case L_('U'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1174 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1175 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1176 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1177 DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); |
604 | 1178 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1179 case L_('V'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1180 case L_('g'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1181 case L_('G'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1182 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1183 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1184 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1185 /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1186 is a leap year, except that YEAR and YEAR - 1 both work |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1187 correctly even when (tp->tm_year + TM_YEAR_BASE) would |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1188 overflow. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1189 int year = (tp->tm_year |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1190 + (tp->tm_year < 0 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1191 ? TM_YEAR_BASE % 400 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1192 : TM_YEAR_BASE % 400 - 400)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1193 int year_adjust = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1194 int days = iso_week_days (tp->tm_yday, tp->tm_wday); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1195 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1196 if (days < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1197 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1198 /* This ISO week belongs to the previous year. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1199 year_adjust = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1200 days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1201 tp->tm_wday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1202 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1203 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1204 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1205 int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1206 tp->tm_wday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1207 if (0 <= d) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1208 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1209 /* This ISO week belongs to the next year. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1210 year_adjust = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1211 days = d; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1212 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1213 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1214 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1215 switch (*f) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1216 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1217 case L_('g'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1218 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1219 int yy = (tp->tm_year % 100 + year_adjust) % 100; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1220 DO_NUMBER (2, (0 <= yy |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1221 ? yy |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1222 : tp->tm_year < -TM_YEAR_BASE - year_adjust |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1223 ? -yy |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1224 : yy + 100)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1225 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1226 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1227 case L_('G'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1228 DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1229 (tp->tm_year + (unsigned int) TM_YEAR_BASE |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1230 + year_adjust)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1231 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1232 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1233 DO_NUMBER (2, days / 7 + 1); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1234 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1235 } |
604 | 1236 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1237 case L_('W'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1238 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1239 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1240 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1241 DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); |
604 | 1242 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1243 case L_('w'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1244 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1245 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1246 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1247 DO_NUMBER (1, tp->tm_wday); |
604 | 1248 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1249 case L_('Y'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1250 if (modifier == 'E') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1251 { |
1109 | 1252 #if HAVE_STRUCT_ERA_ENTRY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1253 struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1254 if (era) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1255 { |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1256 # ifdef COMPILE_WIDE |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1257 subfmt = era->era_wformat; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1258 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1259 subfmt = era->era_format; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1260 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1261 goto subformat; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1262 } |
1109 | 1263 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1264 goto underlying_strftime; |
1109 | 1265 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1266 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1267 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1268 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1269 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1270 DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1271 tp->tm_year + (unsigned int) TM_YEAR_BASE); |
604 | 1272 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1273 case L_('y'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1274 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1275 { |
1109 | 1276 #if HAVE_STRUCT_ERA_ENTRY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1277 struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1278 if (era) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1279 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1280 int delta = tp->tm_year - era->start_date[0]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1281 DO_NUMBER (1, (era->offset |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1282 + delta * era->absolute_direction)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1283 } |
1109 | 1284 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1285 goto underlying_strftime; |
1109 | 1286 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1287 } |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
1288 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1289 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1290 int yy = tp->tm_year % 100; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1291 if (yy < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1292 yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1293 DO_NUMBER (2, yy); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1294 } |
604 | 1295 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1296 case L_('Z'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1297 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1298 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1299 to_uppcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1300 to_lowcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1301 } |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1302 |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1303 #if HAVE_TZNAME |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1304 /* The tzset() call might have changed the value. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1305 if (!(zone && *zone) && tp->tm_isdst >= 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1306 zone = tzname[tp->tm_isdst != 0]; |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1307 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1308 if (! zone) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1309 zone = ""; |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1310 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1311 #ifdef COMPILE_WIDE |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1312 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1313 /* The zone string is always given in multibyte form. We have |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1314 to transform it first. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1315 wchar_t *wczone; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1316 size_t len; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1317 widen (zone, wczone, len); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1318 cpy (len, wczone); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1319 } |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1320 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1321 cpy (strlen (zone), zone); |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1322 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1323 break; |
604 | 1324 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1325 case L_(':'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1326 /* :, ::, and ::: are valid only just before 'z'. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1327 :::: etc. are rejected later. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1328 for (colons = 1; f[colons] == L_(':'); colons++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1329 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1330 if (f[colons] != L_('z')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1331 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1332 f += colons; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1333 goto do_z_conversion; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1334 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1335 case L_('z'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1336 colons = 0; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1337 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1338 do_z_conversion: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1339 if (tp->tm_isdst < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1340 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1341 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1342 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1343 int diff; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1344 int hour_diff; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1345 int min_diff; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1346 int sec_diff; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1347 #if HAVE_TM_GMTOFF |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1348 diff = tp->tm_gmtoff; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1349 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1350 if (ut) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1351 diff = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1352 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1353 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1354 struct tm gtm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1355 struct tm ltm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1356 time_t lt; |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1357 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1358 ltm = *tp; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1359 lt = mktime (<m); |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1360 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1361 if (lt == (time_t) -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1362 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1363 /* mktime returns -1 for errors, but -1 is also a |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1364 valid time_t value. Check whether an error really |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1365 occurred. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1366 struct tm tm; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1367 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1368 if (! __localtime_r (<, &tm) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1369 || ((ltm.tm_sec ^ tm.tm_sec) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1370 | (ltm.tm_min ^ tm.tm_min) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1371 | (ltm.tm_hour ^ tm.tm_hour) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1372 | (ltm.tm_mday ^ tm.tm_mday) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1373 | (ltm.tm_mon ^ tm.tm_mon) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1374 | (ltm.tm_year ^ tm.tm_year))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1375 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1376 } |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1377 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1378 if (! __gmtime_r (<, >m)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1379 break; |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1380 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1381 diff = tm_diff (<m, >m); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1382 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1383 #endif |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
1384 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1385 hour_diff = diff / 60 / 60; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1386 min_diff = diff / 60 % 60; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1387 sec_diff = diff % 60; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1388 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1389 switch (colons) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1390 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1391 case 0: /* +hhmm */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1392 DO_TZ_OFFSET (5, diff < 0, 0, hour_diff * 100 + min_diff); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1393 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1394 case 1: tz_hh_mm: /* +hh:mm */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1395 DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1396 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1397 case 2: tz_hh_mm_ss: /* +hh:mm:ss */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1398 DO_TZ_OFFSET (9, diff < 0, 024, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1399 hour_diff * 10000 + min_diff * 100 + sec_diff); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1400 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1401 case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1402 if (sec_diff != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1403 goto tz_hh_mm_ss; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1404 if (min_diff != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1405 goto tz_hh_mm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1406 DO_TZ_OFFSET (3, diff < 0, 0, hour_diff); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1407 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1408 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1409 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1410 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1411 } |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
1412 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1413 case L_('\0'): /* GNU extension: % at end of format. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1414 --f; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1415 /* Fall through. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1416 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1417 /* Unknown format; output the format, including the '%', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1418 since this is most likely the right thing to do if a |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1419 multibyte string has been misparsed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1420 bad_format: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1421 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1422 int flen; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1423 for (flen = 1; f[1 - flen] != L_('%'); flen++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1424 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1425 cpy (flen, &f[1 - flen]); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1426 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1427 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1428 } |
9 | 1429 } |
604 | 1430 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1431 #if ! FPRINTFTIME |
1775
96099c7ba283
Update from master source in libc, removing %f.
Jim Meyering <jim@meyering.net>
parents:
1557
diff
changeset
|
1432 if (p && maxsize != 0) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1433 *p = L_('\0'); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1434 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1435 |
604 | 1436 return i; |
9 | 1437 } |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1438 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1439 /* Write information from TP into S according to the format |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1440 string FORMAT, writing no more that MAXSIZE characters |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1441 (including the terminating '\0') and returning number of |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1442 characters written. If S is NULL, nothing will be written |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1443 anywhere, so to determine how many characters would be |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1444 written, use NULL for S and (size_t) -1 for MAXSIZE. */ |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1445 size_t |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1446 my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1447 const CHAR_T *format, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1448 const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1449 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1450 return strftime_case_ (false, s, STRFTIME_ARG (maxsize) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1451 format, tp extra_args LOCALE_ARG); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1452 } |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1453 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1454 #if defined _LIBC && ! FPRINTFTIME |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1455 libc_hidden_def (my_strftime) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1456 #endif |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1457 |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1458 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1459 #if defined emacs && ! FPRINTFTIME |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1460 /* For Emacs we have a separate interface which corresponds to the normal |
3261 | 1461 strftime function plus the ut argument, but without the ns argument. */ |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1462 size_t |
4693 | 1463 emacs_strftimeu (char *s, size_t maxsize, const char *format, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1464 const struct tm *tp, int ut) |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1465 { |
3261 | 1466 return my_strftime (s, maxsize, format, tp, ut, 0); |
1535
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1467 } |
72809df6189a
Don't invoke localtime_r or gmtime_r unless it's the GNU C
Jim Meyering <jim@meyering.net>
parents:
1532
diff
changeset
|
1468 #endif |