Mercurial > hg > octave-lojdl > gnulib-hg
annotate lib/strftime.c @ 17476:6057744acd2c default tip master
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Fri, 16 Aug 2013 06:32:22 -0700 |
parents | ba79ea8176b5 |
children |
rev | line source |
---|---|
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16358
diff
changeset
|
1 /* Copyright (C) 1991-2001, 2003-2007, 2009-2013 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 |
8d41d3f68c28
Don't include <config.h> twice; this doesn't work in some cases,
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
29 # include "fprintftime.h" |
11110 | 30 # else |
31 # 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
|
32 # endif |
125 | 33 #endif |
34 | |
813 | 35 #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
|
36 #include <time.h> |
604 | 37 |
9626
def4f669ceac
Fix problem with getdate on mingw32 reported by Simon Josefsson
Paul Eggert <eggert@cs.ucla.edu>
parents:
9309
diff
changeset
|
38 #if HAVE_TZNAME && !HAVE_DECL_TZNAME |
801
da8cea3a8036
[HAVE_TZNAME]: Declare tzname.
Jim Meyering <jim@meyering.net>
parents:
797
diff
changeset
|
39 extern char *tzname[]; |
da8cea3a8036
[HAVE_TZNAME]: Declare tzname.
Jim Meyering <jim@meyering.net>
parents:
797
diff
changeset
|
40 #endif |
da8cea3a8036
[HAVE_TZNAME]: Declare tzname.
Jim Meyering <jim@meyering.net>
parents:
797
diff
changeset
|
41 |
16358 | 42 /* Do multibyte processing if multibyte encodings are supported, unless |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 |
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
51 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
|
52 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
|
53 it. */ |
c6bc5712a6a9
strftime: remove dependencies on multibyte modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
54 #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
|
55 # 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
|
56 #endif |
3dd9bde3c382
Revisit the condition when to use multibyte parsing in strftime.
Bruno Haible <bruno@clisp.org>
parents:
11042
diff
changeset
|
57 #define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
58 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
59 #if DO_MULTIBYTE |
10990
7e8a454e9758
strftime: avoid compilation failure on Solaris 2.6
Jim Meyering <meyering@redhat.com>
parents:
9626
diff
changeset
|
60 # include <wchar.h> |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
61 static const mbstate_t mbstate_zero; |
604 | 62 #endif |
63 | |
4693 | 64 #include <limits.h> |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
65 #include <stdbool.h> |
4693 | 66 #include <stddef.h> |
67 #include <stdlib.h> | |
68 #include <string.h> | |
176 | 69 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
70 #ifdef COMPILE_WIDE |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
71 # include <endian.h> |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
72 # define CHAR_T wchar_t |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
73 # define UCHAR_T unsigned int |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
74 # define L_(Str) L##Str |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
75 # define NLW(Sym) _NL_W##Sym |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
76 |
2845
d5bcf4bb7938
Merge in changes from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
2430
diff
changeset
|
77 # 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
|
78 # define STRLEN(s) __wcslen (s) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
79 |
1109 | 80 #else |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
81 # define CHAR_T char |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
82 # define UCHAR_T unsigned char |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
83 # define L_(Str) Str |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
84 # define NLW(Sym) Sym |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
85 |
4693 | 86 # 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
|
87 # define STRLEN(s) strlen (s) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
88 |
1109 | 89 #endif |
90 | |
5414
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
91 /* 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 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
|
101 #define SHR(a, b) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
102 (-1 >> 1 == -1 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
103 ? (a) >> (b) \ |
5414
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
104 : (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
|
105 |
5775
73ab05626d30
Propagate intprops.h comment fixes to mktime.c and strftime.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5714
diff
changeset
|
106 /* 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
|
107 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
|
108 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
|
109 if needed. */ |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
110 #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
|
111 ((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
|
112 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
113 #define TM_YEAR_BASE 1900 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
114 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
115 #ifndef __isleap |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
116 /* 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
|
117 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
|
118 # define __isleap(year) \ |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
119 ((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
|
120 #endif |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
121 |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
122 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
123 #ifdef _LIBC |
816 | 124 # define tzname __tzname |
125 # 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
|
126 #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
|
127 |
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
|
128 #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
|
129 /* 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
|
130 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
|
131 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
|
132 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
|
133 # 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
|
134 # 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
|
135 # 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
|
136 # 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
|
137 #endif |
9 | 138 |
139 | |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
140 #ifndef FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
141 # define FPRINTFTIME 0 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
142 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
143 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
144 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
145 # 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
|
146 # 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
|
147 #else |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
148 # 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
|
149 # 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
|
150 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
151 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
152 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
153 # 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
|
154 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
|
155 # 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
|
156 # 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
|
157 #elif defined COMPILE_WIDE |
4693 | 158 # define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) |
159 # define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) | |
813 | 160 #else |
4693 | 161 # define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) |
162 # define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) | |
813 | 163 #endif |
164 | |
7524
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
165 #if FPRINTFTIME |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
166 # define advance(P, N) |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
167 #else |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
168 # define advance(P, N) ((P) += (N)) |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
169 #endif |
066fb9a1e386
* lib/strftime.c (advance): New macro.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7455
diff
changeset
|
170 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
171 #define add(n, f) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
172 do \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
173 { \ |
14443
fa909c29c50e
strftime: don't assume a byte count fits in 'int'
Paul Eggert <eggert@cs.ucla.edu>
parents:
14177
diff
changeset
|
174 size_t _n = (n); \ |
14445
e0be175bb753
strftime: fix a bug in yesterday's change
Jim Meyering <meyering@redhat.com>
parents:
14443
diff
changeset
|
175 size_t _w = (width < 0 ? 0 : width); \ |
e0be175bb753
strftime: fix a bug in yesterday's change
Jim Meyering <meyering@redhat.com>
parents:
14443
diff
changeset
|
176 size_t _incr = _n < _w ? _w : _n; \ |
14443
fa909c29c50e
strftime: don't assume a byte count fits in 'int'
Paul Eggert <eggert@cs.ucla.edu>
parents:
14177
diff
changeset
|
177 if (_incr >= maxsize - i) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
178 return 0; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
179 if (p) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
180 { \ |
14445
e0be175bb753
strftime: fix a bug in yesterday's change
Jim Meyering <meyering@redhat.com>
parents:
14443
diff
changeset
|
181 if (digits == 0 && _n < _w) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
182 { \ |
14443
fa909c29c50e
strftime: don't assume a byte count fits in 'int'
Paul Eggert <eggert@cs.ucla.edu>
parents:
14177
diff
changeset
|
183 size_t _delta = width - _n; \ |
12421
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 \ |
17270
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
211 { \ |
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
212 /* Ignore the value of fwrite. The caller can determine whether \ |
17279
ba79ea8176b5
Fix misspellings of "occurred".
Paul Eggert <eggert@cs.ucla.edu>
parents:
17270
diff
changeset
|
213 an error occurred by inspecting ferror (P). All known fwrite \ |
17270
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
214 implementations set the stream's error indicator when they \ |
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
215 fail due to ENOMEM etc., even though C11 and POSIX.1-2008 do \ |
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
216 not require this. */ \ |
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
217 fwrite (s, _n, 1, p); \ |
8b492e35b987
fprintftime: bring back and reword fwrite comment
Paul Eggert <eggert@cs.ucla.edu>
parents:
17266
diff
changeset
|
218 } \ |
12421
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 while (0) \ |
12206
5b7b0b8645f1
fprintftime: wrap macro code argument in "do {...} while(0)"
Jim Meyering <meyering@redhat.com>
parents:
12205
diff
changeset
|
221 ) |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
222 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
223 # define cpy(n, s) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
224 add ((n), \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
225 if (to_lowcase) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
226 memcpy_lowcase (p, (s), _n LOCALE_ARG); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
227 else if (to_uppcase) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
228 memcpy_uppcase (p, (s), _n LOCALE_ARG); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
229 else \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
230 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
|
231 #endif |
813 | 232 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
233 #ifdef COMPILE_WIDE |
4297
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
234 # ifndef USE_IN_EXTENDED_LOCALE_MODEL |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
235 # undef __mbsrtowcs_l |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
236 # 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
|
237 # endif |
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
238 # define widen(os, ws, l) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
239 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
240 mbstate_t __st; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
241 const char *__s = os; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
242 memset (&__st, '\0', sizeof (__st)); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
243 l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
244 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
|
245 (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
|
246 } |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
247 #endif |
813 | 248 |
249 | |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
250 #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
|
251 /* 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
|
252 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
|
253 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
|
254 macro. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
255 # define strftime __strftime_l |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
256 # define wcsftime __wcsftime_l |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
257 # undef _NL_CURRENT |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
258 # define _NL_CURRENT(category, item) \ |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
259 (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
|
260 # define LOCALE_ARG , loc |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
261 # 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
|
262 # define HELPER_LOCALE_ARG , current |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
263 #else |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
264 # define LOCALE_PARAM_PROTO |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
265 # define LOCALE_ARG |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
266 # ifdef _LIBC |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
267 # 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
|
268 # else |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
269 # define HELPER_LOCALE_ARG |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
270 # endif |
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 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
273 #ifdef COMPILE_WIDE |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
274 # 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
|
275 # 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
|
276 # 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
|
277 # else |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
278 # 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
|
279 # 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
|
280 # endif |
813 | 281 #else |
6932
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
282 # ifdef USE_IN_EXTENDED_LOCALE_MODEL |
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
283 # define TOUPPER(Ch, L) __toupper_l (Ch, L) |
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
284 # 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
|
285 # else |
6932
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
286 # define TOUPPER(Ch, L) toupper (Ch) |
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6893
diff
changeset
|
287 # define TOLOWER(Ch, L) tolower (Ch) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
288 # endif |
813 | 289 #endif |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
290 /* We don't use 'isdigit' here since the locale dependent |
819 | 291 interpretation is not what we want here. We only need to accept |
292 the arabic digits in the ASCII range. One day there is perhaps a | |
293 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
|
294 #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
|
295 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
296 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
297 static void |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
298 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
|
299 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
300 while (len-- > 0) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
301 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
302 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
|
303 ++src; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
304 } |
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 static void |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
308 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
|
309 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
310 while (len-- > 0) |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
311 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
312 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
|
313 ++src; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
314 } |
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 #else |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
317 static CHAR_T * |
4693 | 318 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
|
319 size_t len LOCALE_PARAM_PROTO) |
813 | 320 { |
321 while (len-- > 0) | |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
322 dest[len] = TOLOWER ((UCHAR_T) src[len], loc); |
813 | 323 return dest; |
324 } | |
9 | 325 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
326 static CHAR_T * |
4693 | 327 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
|
328 size_t len LOCALE_PARAM_PROTO) |
816 | 329 { |
330 while (len-- > 0) | |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
331 dest[len] = TOUPPER ((UCHAR_T) src[len], loc); |
816 | 332 return dest; |
333 } | |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
334 #endif |
816 | 335 |
1058 | 336 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
337 #if ! HAVE_TM_GMTOFF |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
338 /* Yield the difference between *A and *B, |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
339 measured in seconds, ignoring leap seconds. */ |
1058 | 340 # define tm_diff ftime_tm_diff |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
341 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
|
342 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
|
343 { |
794 | 344 /* Compute intervening leap days correctly even if year is negative. |
345 Take care to avoid int overflow in leap day calculations, | |
346 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
|
347 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
|
348 int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); |
794 | 349 int a100 = a4 / 25 - (a4 % 25 < 0); |
350 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
|
351 int a400 = SHR (a100, 2); |
1b5e702ecdd1
(SHR): New macro, which is a portable
Paul Eggert <eggert@cs.ucla.edu>
parents:
5402
diff
changeset
|
352 int b400 = SHR (b100, 2); |
794 | 353 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); |
354 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
|
355 int days = (365 * years + intervening_leap_days |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
356 + (a->tm_yday - b->tm_yday)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
357 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
|
358 + (a->tm_min - b->tm_min)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
359 + (a->tm_sec - b->tm_sec)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
360 } |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
361 #endif /* ! HAVE_TM_GMTOFF */ |
9 | 362 |
604 | 363 |
9 | 364 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
365 /* 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
|
366 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
|
367 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
|
368 be as small as YDAY_MINIMUM. */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
369 #define ISO_WEEK_START_WDAY 1 /* Monday */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
370 #define ISO_WEEK1_WDAY 4 /* Thursday */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
371 #define YDAY_MINIMUM (-366) |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
372 #ifdef __GNUC__ |
1058 | 373 __inline__ |
604 | 374 #endif |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
375 static int |
4693 | 376 iso_week_days (int yday, int wday) |
604 | 377 { |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
378 /* 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
|
379 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
|
380 return (yday |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
381 - (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
|
382 + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
383 } |
9 | 384 |
385 | |
3261 | 386 /* When compiling this file, GNU applications can #define my_strftime |
387 to a symbol (typically nstrftime) to get an extended strftime with | |
388 extra arguments UT and NS. Emacs is a special case for now, but | |
389 this Emacs-specific code can be removed once Emacs's config.h | |
390 defines my_strftime. */ | |
391 #if defined emacs && !defined my_strftime | |
392 # define my_strftime nstrftime | |
393 #endif | |
394 | |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
395 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
396 # undef my_strftime |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
397 # define my_strftime fprintftime |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
398 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
399 |
3261 | 400 #ifdef my_strftime |
401 # define extra_args , ut, ns | |
4693 | 402 # define extra_args_spec , int ut, int ns |
1109 | 403 #else |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
404 # if defined COMPILE_WIDE |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
405 # define my_strftime wcsftime |
4297
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
406 # 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
|
407 # else |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
408 # define my_strftime strftime |
4297
30aa99ec2725
(widen) [COMPILE_WIDE]: Merge nearly-identical definitions.
Jim Meyering <jim@meyering.net>
parents:
4296
diff
changeset
|
409 # 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
|
410 # endif |
3261 | 411 # define extra_args |
412 # 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
|
413 /* 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
|
414 # define ut 0 |
3261 | 415 # define ns 0 |
1109 | 416 #endif |
417 | |
860
68da68da125e
(_strftime_copytm): New function, to work around Solaris 2.5 tzset bug.
Jim Meyering <jim@meyering.net>
parents:
829
diff
changeset
|
418 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
419 /* 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
|
420 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
|
421 static size_t |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
422 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
|
423 STRFTIME_ARG (size_t maxsize) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
424 const CHAR_T *format, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
425 const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) |
604 | 426 { |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
427 #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
|
428 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
|
429 #endif |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
430 #if FPRINTFTIME |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
431 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
|
432 #endif |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
433 |
604 | 434 int hour12 = tp->tm_hour; |
435 #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
|
436 /* 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
|
437 the evaluation of these values until really needed since some |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
438 expressions might not be valid in every situation. The 'struct tm' |
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
|
439 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
|
440 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
|
441 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
|
442 # define a_wkday \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
443 ((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
|
444 # define f_wkday \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
445 ((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
|
446 # define a_month \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
447 ((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
|
448 # define f_month \ |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
449 ((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
|
450 # define ampm \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
451 ((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
|
452 ? 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
|
453 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
454 # define aw_len STRLEN (a_wkday) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
455 # define am_len STRLEN (a_month) |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
456 # define ap_len STRLEN (ampm) |
604 | 457 #endif |
458 const char *zone; | |
813 | 459 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
|
460 STREAM_OR_CHAR_T *p = s; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
461 const CHAR_T *f; |
2993
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
462 #if DO_MULTIBYTE && !defined COMPILE_WIDE |
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
463 const char *format_end = NULL; |
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
464 #endif |
582
3ec26150a8d6
(mon_week_ISO): New function to implement new %V format.
Jim Meyering <jim@meyering.net>
parents:
581
diff
changeset
|
465 |
5960
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
466 #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
|
467 /* 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 tp = © |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
473 #endif |
2a0d593683dc
Remove the dependency of the strftime module on the tzset module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
474 |
813 | 475 zone = NULL; |
1058 | 476 #if HAVE_TM_ZONE |
477 /* The POSIX test suite assumes that setting | |
813 | 478 the environment variable TZ to a new value before calling strftime() |
479 will influence the result (the %Z format) even if the information in | |
1058 | 480 TP is computed with a totally different time zone. |
481 This is bogus: though POSIX allows bad behavior like this, | |
482 POSIX does not require it. Do the right thing instead. */ | |
604 | 483 zone = (const char *) tp->tm_zone; |
484 #endif | |
485 #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
|
486 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
|
487 { |
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 if (! (zone && *zone)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
489 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
|
490 } |
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 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
|
492 { |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
493 /* 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
|
494 though strftime called tzset. */ |
813 | 495 # 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
|
496 tzset (); |
813 | 497 # 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
|
498 } |
604 | 499 #endif |
500 | |
501 if (hour12 > 12) | |
502 hour12 -= 12; | |
503 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
|
504 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
|
505 hour12 = 12; |
604 | 506 |
507 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
|
508 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
509 int pad = 0; /* Padding for number ('-', '_', or 0). */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
510 int modifier; /* Field modifier ('E', 'O', or 0). */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
511 int digits = 0; /* Max digits for numeric format. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 CHAR_T sign_char; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
519 CHAR_T *bufp; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
520 CHAR_T buf[1 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
521 + 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
|
522 + (sizeof (int) < sizeof (time_t) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
523 ? INT_STRLEN_BOUND (time_t) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
524 : INT_STRLEN_BOUND (int))]; |
813 | 525 int width = -1; |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
526 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
|
527 bool to_uppcase = upcase; |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
528 size_t colons; |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
529 bool change_case = false; |
1109 | 530 int format_char; |
9 | 531 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
532 #if DO_MULTIBYTE && !defined COMPILE_WIDE |
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
533 switch (*f) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
534 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
535 case L_('%'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
536 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
537 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
538 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
|
539 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
|
540 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
|
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_('0'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 case L_('~'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
559 /* 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
|
560 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
|
561 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
|
562 not be analyzed further. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
563 add1 (*f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
564 continue; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
565 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
566 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
567 /* 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
|
568 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
|
569 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
570 mbstate_t mbstate = mbstate_zero; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
571 size_t len = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
572 size_t fsize; |
2993
9231fb44e77d
(my_strftime): Do not invoke mbrlen with a
Jim Meyering <jim@meyering.net>
parents:
2923
diff
changeset
|
573 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
574 if (! format_end) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
575 format_end = f + strlen (f) + 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
576 fsize = format_end - f; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
577 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
578 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
579 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
580 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
|
581 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
582 if (bytes == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
583 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
584 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
585 if (bytes == (size_t) -2) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
586 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
587 len += strlen (f + len); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
588 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
589 } |
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
|
590 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
591 if (bytes == (size_t) -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
592 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
593 len++; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
594 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
595 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
596 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
597 len += bytes; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
598 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
599 while (! mbsinit (&mbstate)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
600 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
601 cpy (len, f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
602 f += len - 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
603 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
604 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
605 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
606 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
607 #else /* ! DO_MULTIBYTE */ |
9 | 608 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
609 /* 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
|
610 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
|
611 or this is the wide character version. */ |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
612 if (*f != L_('%')) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
613 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
614 add1 (*f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
615 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
616 } |
9 | 617 |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
618 #endif /* ! DO_MULTIBYTE */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
619 |
829 | 620 /* Check for flags that can modify a format. */ |
813 | 621 while (1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
622 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
623 switch (*++f) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
624 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
625 /* This influences the number formats. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
626 case L_('_'): |
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_('0'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
629 pad = *f; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
630 continue; |
816 | 631 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
632 /* This changes textual output. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
633 case L_('^'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
634 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
635 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
636 case L_('#'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
637 change_case = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
638 continue; |
813 | 639 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
640 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
641 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
642 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
643 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
644 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
645 |
813 | 646 /* As a GNU extension we allow to specify the field width. */ |
819 | 647 if (ISDIGIT (*f)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
648 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
649 width = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
650 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
651 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
652 if (width > INT_MAX / 10 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
653 || (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
|
654 /* Avoid overflow. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
655 width = INT_MAX; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
656 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
657 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
658 width *= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
659 width += *f - L_('0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
660 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
661 ++f; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
662 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
663 while (ISDIGIT (*f)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
664 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
665 |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
666 /* Check for modifiers. */ |
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
667 switch (*f) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
668 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
669 case L_('E'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
670 case L_('O'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
671 modifier = *f++; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
672 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
673 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
674 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
675 modifier = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
676 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
677 } |
9 | 678 |
604 | 679 /* Now do the specified format. */ |
1109 | 680 format_char = *f; |
681 switch (format_char) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
682 { |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
683 #define DO_NUMBER(d, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
684 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
685 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
|
686 #define DO_SIGNED_NUMBER(d, negative, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
687 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
688 negative_number = negative; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
689 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
|
690 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
691 /* The mask is not what you might think. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
692 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
|
693 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
|
694 #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
|
695 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
696 negative_number = negative; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
697 tz_colon_mask = mask; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
698 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
|
699 #define DO_NUMBER_SPACEPAD(d, v) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
700 digits = d; \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
701 number_value = v; goto do_number_spacepad |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
702 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
703 case L_('%'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
704 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
705 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
706 add1 (*f); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
707 break; |
604 | 708 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
709 case L_('a'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
710 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
711 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
712 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
713 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
714 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
715 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
716 } |
6893 | 717 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
718 cpy (aw_len, a_wkday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
719 break; |
1109 | 720 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
721 goto underlying_strftime; |
1109 | 722 #endif |
604 | 723 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
724 case 'A': |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
725 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
726 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
727 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
728 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
729 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
730 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
731 } |
6893 | 732 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
733 cpy (STRLEN (f_wkday), f_wkday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
734 break; |
1109 | 735 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
736 goto underlying_strftime; |
1109 | 737 #endif |
604 | 738 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
739 case L_('b'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
740 case L_('h'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
741 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
742 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
743 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
744 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
745 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
746 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
747 goto bad_format; |
6893 | 748 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
749 cpy (am_len, a_month); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
750 break; |
1109 | 751 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
752 goto underlying_strftime; |
1109 | 753 #endif |
604 | 754 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
755 case L_('B'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
756 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
757 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
758 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
759 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
760 to_uppcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
761 to_lowcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
762 } |
6893 | 763 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
764 cpy (STRLEN (f_month), f_month); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
765 break; |
1109 | 766 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
767 goto underlying_strftime; |
1109 | 768 #endif |
9 | 769 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
770 case L_('c'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
771 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
772 goto bad_format; |
604 | 773 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
774 if (! (modifier == 'E' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
775 && (*(subfmt = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
776 (const CHAR_T *) _NL_CURRENT (LC_TIME, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
777 NLW(ERA_D_T_FMT))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
778 != '\0'))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
779 subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); |
604 | 780 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
781 goto underlying_strftime; |
604 | 782 #endif |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
783 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
784 subformat: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
785 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
786 size_t len = strftime_case_ (to_uppcase, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
787 NULL, STRFTIME_ARG ((size_t) -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
788 subfmt, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
789 tp extra_args LOCALE_ARG); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
790 add (len, strftime_case_ (to_uppcase, p, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
791 STRFTIME_ARG (maxsize - i) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
792 subfmt, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
793 tp extra_args LOCALE_ARG)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
794 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
795 break; |
604 | 796 |
6893 | 797 #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
|
798 underlying_strftime: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
799 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
800 /* The relevant information is available only via the |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
801 underlying strftime implementation, so use that. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
802 char ufmt[5]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
803 char *u = ufmt; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
804 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
|
805 size_t len; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
806 /* 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
|
807 In some cases, config.h contains something like |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
808 "#define strftime rpl_strftime". */ |
2378
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
809 # ifdef strftime |
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
810 # undef strftime |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
811 size_t strftime (); |
2378
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
812 # endif |
524f131fc113
(my_strftime): Make sure we call the system
Jim Meyering <jim@meyering.net>
parents:
2082
diff
changeset
|
813 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
814 /* The space helps distinguish strftime failure from empty |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
815 output. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
816 *u++ = ' '; |
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 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
819 *u++ = modifier; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
820 *u++ = format_char; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
821 *u = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
822 len = strftime (ubuf, sizeof ubuf, ufmt, tp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
823 if (len != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
824 cpy (len - 1, ubuf + 1); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
825 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
826 break; |
1109 | 827 #endif |
828 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
829 case L_('C'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
830 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
831 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
832 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
833 { |
1109 | 834 #if HAVE_STRUCT_ERA_ENTRY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
835 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
|
836 if (era) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
837 { |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
838 # ifdef COMPILE_WIDE |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
839 size_t len = __wcslen (era->era_wname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
840 cpy (len, era->era_wname); |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
841 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
842 size_t len = strlen (era->era_name); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
843 cpy (len, era->era_name); |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
844 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
845 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
846 } |
1109 | 847 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
848 goto underlying_strftime; |
1109 | 849 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
850 } |
1109 | 851 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
852 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
853 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
|
854 century -= tp->tm_year % 100 < 0 && 0 < century; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
855 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
|
856 } |
9 | 857 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
858 case L_('x'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
859 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
860 goto bad_format; |
604 | 861 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
862 if (! (modifier == L_('E') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
863 && (*(subfmt = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
864 (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
|
865 != L_('\0')))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
866 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
|
867 goto subformat; |
1109 | 868 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
869 goto underlying_strftime; |
604 | 870 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
871 case L_('D'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
872 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
873 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
874 subfmt = L_("%m/%d/%y"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
875 goto subformat; |
604 | 876 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
877 case L_('d'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
878 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
879 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
880 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
881 DO_NUMBER (2, tp->tm_mday); |
604 | 882 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
883 case L_('e'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
884 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
885 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
886 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
887 DO_NUMBER_SPACEPAD (2, tp->tm_mday); |
176 | 888 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
889 /* 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
|
890 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
|
891 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
892 do_tz_offset: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
893 always_output_a_sign = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
894 goto do_number_body; |
604 | 895 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
896 do_number_spacepad: |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
897 /* Force '_' flag unless overridden by '0' or '-' flag. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
898 if (pad != L_('0') && pad != L_('-')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
899 pad = L_('_'); |
176 | 900 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
901 do_number: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
902 /* Format NUMBER_VALUE according to the MODIFIER flag. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
903 negative_number = number_value < 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
904 u_number_value = number_value; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
905 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
906 do_signed_number: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
907 always_output_a_sign = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
908 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
|
909 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
910 do_number_body: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
911 /* 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
|
912 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
|
913 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
|
914 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
|
915 negating it. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
916 if (modifier == L_('O') && !negative_number) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
917 { |
1109 | 918 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
919 /* Get the locale specific alternate representation of |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
920 the number. If none exist NULL is returned. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
921 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
|
922 HELPER_LOCALE_ARG); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
923 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
924 if (cp != NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
925 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
926 size_t digitlen = STRLEN (cp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
927 if (digitlen != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
928 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
929 cpy (digitlen, cp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
930 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
931 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
932 } |
1109 | 933 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
934 goto underlying_strftime; |
1109 | 935 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
936 } |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
937 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
938 bufp = buf + sizeof (buf) / sizeof (buf[0]); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
939 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
940 if (negative_number) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
941 u_number_value = - u_number_value; |
604 | 942 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
943 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
944 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
945 if (tz_colon_mask & 1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
946 *--bufp = ':'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
947 tz_colon_mask >>= 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
948 *--bufp = u_number_value % 10 + L_('0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
949 u_number_value /= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
950 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
951 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
|
952 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
953 do_number_sign_and_padding: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
954 if (digits < width) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
955 digits = width; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
956 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
957 sign_char = (negative_number ? L_('-') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
958 : always_output_a_sign ? L_('+') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
959 : 0); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
960 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
961 if (pad == L_('-')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
962 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
963 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
964 add1 (sign_char); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
965 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
966 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
967 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
968 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
|
969 - bufp) - !!sign_char; |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
970 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
971 if (padding > 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
972 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
973 if (pad == L_('_')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
974 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
975 if ((size_t) padding >= maxsize - i) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
976 return 0; |
4298 | 977 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
978 if (p) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
979 memset_space (p, padding); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
980 i += padding; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
981 width = width > padding ? width - padding : 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
982 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
983 add1 (sign_char); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
984 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
985 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
986 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
987 if ((size_t) digits >= maxsize - i) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
988 return 0; |
4298 | 989 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
990 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
991 add1 (sign_char); |
4298 | 992 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
993 if (p) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
994 memset_zero (p, padding); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
995 i += padding; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
996 width = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
997 } |
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 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1000 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1001 if (sign_char) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1002 add1 (sign_char); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1003 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1004 } |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1005 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1006 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
|
1007 break; |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1008 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1009 case L_('F'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1010 if (modifier != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1011 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1012 subfmt = L_("%Y-%m-%d"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1013 goto subformat; |
604 | 1014 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1015 case L_('H'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1016 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1017 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1018 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1019 DO_NUMBER (2, tp->tm_hour); |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1020 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1021 case L_('I'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1022 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1023 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1024 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1025 DO_NUMBER (2, hour12); |
604 | 1026 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1027 case L_('k'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1028 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1029 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1030 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1031 DO_NUMBER_SPACEPAD (2, tp->tm_hour); |
546
baaeb11e50e5
(add_num_tz): New function.
Jim Meyering <jim@meyering.net>
parents:
307
diff
changeset
|
1032 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1033 case L_('l'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1034 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1035 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1036 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1037 DO_NUMBER_SPACEPAD (2, hour12); |
604 | 1038 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1039 case L_('j'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1040 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1041 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1042 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1043 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
|
1044 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1045 case L_('M'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1046 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1047 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1048 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1049 DO_NUMBER (2, tp->tm_min); |
604 | 1050 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1051 case L_('m'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1052 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1053 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1054 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1055 DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); |
604 | 1056 |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1057 #ifndef _LIBC |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1058 case L_('N'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1059 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1060 goto bad_format; |
3261 | 1061 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1062 number_value = ns; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1063 if (width == -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1064 width = 9; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1065 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1066 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1067 /* 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
|
1068 int j; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1069 for (j = width; j < 9; j++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1070 number_value /= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1071 } |
3261 | 1072 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1073 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
|
1074 #endif |
3261 | 1075 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1076 case L_('n'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1077 add1 (L_('\n')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1078 break; |
604 | 1079 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1080 case L_('P'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1081 to_lowcase = true; |
6893 | 1082 #ifndef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1083 format_char = L_('p'); |
1109 | 1084 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1085 /* FALLTHROUGH */ |
813 | 1086 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1087 case L_('p'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1088 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1089 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1090 to_uppcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1091 to_lowcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1092 } |
6893 | 1093 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1094 cpy (ap_len, ampm); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1095 break; |
1109 | 1096 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1097 goto underlying_strftime; |
1109 | 1098 #endif |
9 | 1099 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1100 case L_('R'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1101 subfmt = L_("%H:%M"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1102 goto subformat; |
604 | 1103 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1104 case L_('r'): |
6893 | 1105 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1106 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
|
1107 NLW(T_FMT_AMPM))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1108 == L_('\0')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1109 subfmt = L_("%I:%M:%S %p"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1110 goto subformat; |
6893 | 1111 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1112 goto underlying_strftime; |
4558 | 1113 #endif |
604 | 1114 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1115 case L_('S'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1116 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1117 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1118 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1119 DO_NUMBER (2, tp->tm_sec); |
604 | 1120 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1121 case L_('s'): /* GNU extension. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1122 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1123 struct tm ltm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1124 time_t t; |
726
8867c987f8cf
(strftime): Accommodate the broken C compiler
Jim Meyering <jim@meyering.net>
parents:
691
diff
changeset
|
1125 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1126 ltm = *tp; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1127 t = mktime (<m); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1128 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1129 /* 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
|
1130 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
|
1131 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1132 bufp = buf + sizeof (buf) / sizeof (buf[0]); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1133 negative_number = t < 0; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1134 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1135 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1136 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1137 int d = t % 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1138 t /= 10; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1139 *--bufp = (negative_number ? -d : d) + L_('0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1140 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1141 while (t != 0); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1142 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1143 digits = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1144 always_output_a_sign = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1145 goto do_number_sign_and_padding; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1146 } |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
1147 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1148 case L_('X'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1149 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1150 goto bad_format; |
604 | 1151 #ifdef _NL_CURRENT |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1152 if (! (modifier == L_('E') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1153 && (*(subfmt = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1154 (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
|
1155 != L_('\0')))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1156 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
|
1157 goto subformat; |
1109 | 1158 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1159 goto underlying_strftime; |
604 | 1160 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1161 case L_('T'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1162 subfmt = L_("%H:%M:%S"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1163 goto subformat; |
604 | 1164 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1165 case L_('t'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1166 add1 (L_('\t')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1167 break; |
604 | 1168 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1169 case L_('u'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1170 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
|
1171 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1172 case L_('U'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1173 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1174 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1175 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1176 DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); |
604 | 1177 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1178 case L_('V'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1179 case L_('g'): |
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 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1182 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1183 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1184 /* 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
|
1185 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
|
1186 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
|
1187 overflow. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1188 int year = (tp->tm_year |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1189 + (tp->tm_year < 0 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1190 ? TM_YEAR_BASE % 400 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1191 : TM_YEAR_BASE % 400 - 400)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1192 int year_adjust = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1193 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
|
1194 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1195 if (days < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1196 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1197 /* This ISO week belongs to the previous year. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1198 year_adjust = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1199 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
|
1200 tp->tm_wday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1201 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1202 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1203 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1204 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
|
1205 tp->tm_wday); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1206 if (0 <= d) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1207 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1208 /* This ISO week belongs to the next year. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1209 year_adjust = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1210 days = d; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1211 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1212 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1213 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1214 switch (*f) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1215 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1216 case L_('g'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1217 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1218 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
|
1219 DO_NUMBER (2, (0 <= yy |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1220 ? yy |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1221 : tp->tm_year < -TM_YEAR_BASE - year_adjust |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1222 ? -yy |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1223 : yy + 100)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1224 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1225 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1226 case L_('G'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1227 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
|
1228 (tp->tm_year + (unsigned int) TM_YEAR_BASE |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1229 + year_adjust)); |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1230 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1231 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1232 DO_NUMBER (2, days / 7 + 1); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1233 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1234 } |
604 | 1235 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1236 case L_('W'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1237 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1238 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1239 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1240 DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); |
604 | 1241 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1242 case L_('w'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1243 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1244 goto bad_format; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1245 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1246 DO_NUMBER (1, tp->tm_wday); |
604 | 1247 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1248 case L_('Y'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1249 if (modifier == 'E') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1250 { |
1109 | 1251 #if HAVE_STRUCT_ERA_ENTRY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1252 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
|
1253 if (era) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1254 { |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1255 # ifdef COMPILE_WIDE |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1256 subfmt = era->era_wformat; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1257 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1258 subfmt = era->era_format; |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1259 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1260 goto subformat; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1261 } |
1109 | 1262 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1263 goto underlying_strftime; |
1109 | 1264 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1265 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1266 if (modifier == L_('O')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1267 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1268 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1269 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
|
1270 tp->tm_year + (unsigned int) TM_YEAR_BASE); |
604 | 1271 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1272 case L_('y'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1273 if (modifier == L_('E')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1274 { |
1109 | 1275 #if HAVE_STRUCT_ERA_ENTRY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1276 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
|
1277 if (era) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1278 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1279 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
|
1280 DO_NUMBER (1, (era->offset |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1281 + delta * era->absolute_direction)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1282 } |
1109 | 1283 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1284 goto underlying_strftime; |
1109 | 1285 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1286 } |
5690
e44b4f85ad9b
Include <stdbool.h>. Use bool where appropriate,
Paul Eggert <eggert@cs.ucla.edu>
parents:
5414
diff
changeset
|
1287 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1288 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1289 int yy = tp->tm_year % 100; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1290 if (yy < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1291 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
|
1292 DO_NUMBER (2, yy); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1293 } |
604 | 1294 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1295 case L_('Z'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1296 if (change_case) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1297 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1298 to_uppcase = false; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1299 to_lowcase = true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1300 } |
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
|
1301 |
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 #if HAVE_TZNAME |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1303 /* The tzset() call might have changed the value. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1304 if (!(zone && *zone) && tp->tm_isdst >= 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1305 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
|
1306 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1307 if (! zone) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1308 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
|
1309 |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1310 #ifdef COMPILE_WIDE |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1311 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1312 /* 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
|
1313 to transform it first. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1314 wchar_t *wczone; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1315 size_t len; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1316 widen (zone, wczone, len); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1317 cpy (len, wczone); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1318 } |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1319 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1320 cpy (strlen (zone), zone); |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1321 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1322 break; |
604 | 1323 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1324 case L_(':'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1325 /* :, ::, and ::: are valid only just before 'z'. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1326 :::: etc. are rejected later. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1327 for (colons = 1; f[colons] == L_(':'); colons++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1328 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1329 if (f[colons] != L_('z')) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1330 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1331 f += colons; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1332 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
|
1333 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1334 case L_('z'): |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1335 colons = 0; |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1336 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1337 do_z_conversion: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1338 if (tp->tm_isdst < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1339 break; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1340 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1341 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1342 int diff; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1343 int hour_diff; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1344 int min_diff; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1345 int sec_diff; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1346 #if HAVE_TM_GMTOFF |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1347 diff = tp->tm_gmtoff; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1348 #else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1349 if (ut) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1350 diff = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1351 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1352 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1353 struct tm gtm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1354 struct tm ltm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1355 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
|
1356 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1357 ltm = *tp; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1358 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
|
1359 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1360 if (lt == (time_t) -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1361 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1362 /* 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
|
1363 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
|
1364 occurred. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1365 struct tm tm; |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1366 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1367 if (! __localtime_r (<, &tm) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1368 || ((ltm.tm_sec ^ tm.tm_sec) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1369 | (ltm.tm_min ^ tm.tm_min) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1370 | (ltm.tm_hour ^ tm.tm_hour) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1371 | (ltm.tm_mday ^ tm.tm_mday) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1372 | (ltm.tm_mon ^ tm.tm_mon) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1373 | (ltm.tm_year ^ tm.tm_year))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1374 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1375 } |
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
|
1376 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1377 if (! __gmtime_r (<, >m)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1378 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
|
1379 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1380 diff = tm_diff (<m, >m); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1381 } |
691
6813ffe12e6a
(strftime): New version, from GNU libc.
Jim Meyering <jim@meyering.net>
parents:
687
diff
changeset
|
1382 #endif |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
1383 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1384 hour_diff = diff / 60 / 60; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1385 min_diff = diff / 60 % 60; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1386 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
|
1387 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1388 switch (colons) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1389 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1390 case 0: /* +hhmm */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1391 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
|
1392 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1393 case 1: tz_hh_mm: /* +hh:mm */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1394 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
|
1395 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1396 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
|
1397 DO_TZ_OFFSET (9, diff < 0, 024, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1398 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
|
1399 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1400 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
|
1401 if (sec_diff != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1402 goto tz_hh_mm_ss; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1403 if (min_diff != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1404 goto tz_hh_mm; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1405 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
|
1406 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1407 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1408 goto bad_format; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1409 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1410 } |
672
d4a380613840
Update from GNU libc -- this adds back %z and %s
Jim Meyering <jim@meyering.net>
parents:
668
diff
changeset
|
1411 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1412 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
|
1413 --f; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1414 /* Fall through. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1415 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1416 /* Unknown format; output the format, including the '%', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1417 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
|
1418 multibyte string has been misparsed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1419 bad_format: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1420 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1421 int flen; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1422 for (flen = 1; f[1 - flen] != L_('%'); flen++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1423 continue; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1424 cpy (flen, &f[1 - flen]); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1425 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1426 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1427 } |
9 | 1428 } |
604 | 1429 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1430 #if ! FPRINTFTIME |
1775
96099c7ba283
Update from master source in libc, removing %f.
Jim Meyering <jim@meyering.net>
parents:
1557
diff
changeset
|
1431 if (p && maxsize != 0) |
2082
35c2c4e86de2
Sync with the GNU C Library.
Jim Meyering <jim@meyering.net>
parents:
2060
diff
changeset
|
1432 *p = L_('\0'); |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1433 #endif |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1434 |
604 | 1435 return i; |
9 | 1436 } |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1437 |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1438 /* 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
|
1439 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
|
1440 (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
|
1441 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
|
1442 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
|
1443 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
|
1444 size_t |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1445 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
|
1446 const CHAR_T *format, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12257
diff
changeset
|
1447 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
|
1448 { |
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1449 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
|
1450 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
|
1451 } |
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 #if defined _LIBC && ! FPRINTFTIME |
4296
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1454 libc_hidden_def (my_strftime) |
2da9db9c7ef8
(my_strftime): Merge in locale-related changes from libc.
Jim Meyering <jim@meyering.net>
parents:
3670
diff
changeset
|
1455 #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
|
1456 |
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 |
6273
52428341346b
* strftime.c (my_strftime): Rewrite the previous change slightly,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6062
diff
changeset
|
1458 #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
|
1459 /* For Emacs we have a separate interface which corresponds to the normal |
3261 | 1460 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
|
1461 size_t |
4693 | 1462 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
|
1463 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
|
1464 { |
3261 | 1465 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
|
1466 } |
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 #endif |