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