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