|
18 | 18 | #include <string.h>
|
19 | 19 | #include <stdint.h> /* for INT64_MAX and INT64_MIN */
|
20 | 20 |
|
21 |
| -/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ |
22 |
| -#define is_digit(c) ((unsigned) (c) - '0' <= 9) |
23 |
| - |
24 | 21 | #if 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
25 |
| -#define ATTRIBUTE_CONST __attribute__ ((const)) |
26 | 22 | #define ATTRIBUTE_PURE __attribute__ ((__pure__))
|
27 |
| -#define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) |
28 | 23 | #else
|
29 |
| -#define ATTRIBUTE_CONST /* empty */ |
30 |
| -#define ATTRIBUTE_PURE /* empty */ |
31 |
| -#define ATTRIBUTE_FORMAT(spec) /* empty */ |
32 |
| -#endif |
33 |
| - |
34 |
| -#if !defined(__STDC_VERSION__) && !defined restrict |
35 |
| -#define restrict /* empty */ |
| 24 | +#define ATTRIBUTE_PURE /* empty */ |
36 | 25 | #endif
|
37 | 26 |
|
38 | 27 | #ifdef __clang__
|
@@ -79,88 +68,13 @@ static int64_t const time_t_max = INT64_MAX;
|
79 | 68 | #define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
|
80 | 69 | #define MONSPERYEAR 12
|
81 | 70 |
|
82 |
| -#define TM_SUNDAY 0 |
83 |
| -#define TM_MONDAY 1 |
84 |
| -#define TM_TUESDAY 2 |
85 |
| -#define TM_WEDNESDAY 3 |
86 |
| -#define TM_THURSDAY 4 |
87 |
| -#define TM_FRIDAY 5 |
88 |
| -#define TM_SATURDAY 6 |
89 |
| - |
90 |
| -#define TM_JANUARY 0 |
91 |
| -#define TM_FEBRUARY 1 |
92 |
| -#define TM_MARCH 2 |
93 |
| -#define TM_APRIL 3 |
94 |
| -#define TM_MAY 4 |
95 |
| -#define TM_JUNE 5 |
96 |
| -#define TM_JULY 6 |
97 |
| -#define TM_AUGUST 7 |
98 |
| -#define TM_SEPTEMBER 8 |
99 |
| -#define TM_OCTOBER 9 |
100 |
| -#define TM_NOVEMBER 10 |
101 |
| -#define TM_DECEMBER 11 |
102 |
| - |
103 | 71 | #define TM_YEAR_BASE 1900
|
104 | 72 |
|
105 | 73 | #define EPOCH_YEAR 1970
|
106 |
| -#define EPOCH_WDAY TM_THURSDAY |
| 74 | +#define EPOCH_WDAY 4 /* TM_THURSDAY */ |
107 | 75 |
|
108 | 76 | #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
109 | 77 |
|
110 |
| -/* |
111 |
| -** Since everything in isleap is modulo 400 (or a factor of 400), we know that |
112 |
| -** isleap(y) == isleap(y % 400) |
113 |
| -** and so |
114 |
| -** isleap(a + b) == isleap((a + b) % 400) |
115 |
| -** or |
116 |
| -** isleap(a + b) == isleap(a % 400 + b % 400) |
117 |
| -** This is true even if % means modulo rather than Fortran remainder |
118 |
| -** (which is allowed by C89 but not C99). |
119 |
| -** We use this to avoid addition overflow problems. |
120 |
| -*/ |
121 |
| - |
122 |
| -#define isleap_sum(a, b) isleap ((a) % 400 + (b) % 400) |
123 |
| - |
124 |
| -#ifndef TZ_ABBR_MAX_LEN |
125 |
| -#define TZ_ABBR_MAX_LEN 16 |
126 |
| -#endif /* !defined TZ_ABBR_MAX_LEN */ |
127 |
| - |
128 |
| -#ifndef TZ_ABBR_CHAR_SET |
129 |
| -#define TZ_ABBR_CHAR_SET "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._" |
130 |
| -#endif /* !defined TZ_ABBR_CHAR_SET */ |
131 |
| - |
132 |
| -#ifndef TZ_ABBR_ERR_CHAR |
133 |
| -#define TZ_ABBR_ERR_CHAR '_' |
134 |
| -#endif /* !defined TZ_ABBR_ERR_CHAR */ |
135 |
| - |
136 |
| -#ifndef WILDABBR |
137 |
| -/* |
138 |
| -** Someone might make incorrect use of a time zone abbreviation: |
139 |
| -** 1. They might reference tzname[0] before calling tzset (explicitly |
140 |
| -** or implicitly). |
141 |
| -** 2. They might reference tzname[1] before calling tzset (explicitly |
142 |
| -** or implicitly). |
143 |
| -** 3. They might reference tzname[1] after setting to a time zone |
144 |
| -** in which Daylight Saving Time is never observed. |
145 |
| -** 4. They might reference tzname[0] after setting to a time zone |
146 |
| -** in which Standard Time is never observed. |
147 |
| -** 5. They might reference tm.TM_ZONE after calling offtime. |
148 |
| -** What's best to do in the above cases is open to debate; |
149 |
| -** for now, we just set things up so that in any of the five cases |
150 |
| -** WILDABBR is used. Another possibility: initialize tzname[0] to the |
151 |
| -** string "tzname[0] used before set", and similarly for the other cases. |
152 |
| -** And another: initialize tzname[0] to "ERA", with an explanation in the |
153 |
| -** manual page of what this "time zone abbreviation" means (doing this so |
154 |
| -** that tzname[0] has the "normal" length of three characters). |
155 |
| -*/ |
156 |
| -#define WILDABBR " " |
157 |
| -#endif /* !defined WILDABBR */ |
158 |
| - |
159 |
| -#ifdef TM_ZONE |
160 |
| -static const char wildabbr[] = WILDABBR; |
161 |
| -static const char gmt[] = "GMT"; |
162 |
| -#endif |
163 |
| - |
164 | 78 | struct ttinfo { /* time type information */
|
165 | 79 | int_fast32_t tt_gmtoff; /* UT offset in seconds */
|
166 | 80 | int tt_isdst; /* used to set tm_isdst */
|
@@ -206,10 +120,6 @@ struct rule {
|
206 | 120 | int_fast32_t r_time; /* transition time of rule */
|
207 | 121 | };
|
208 | 122 |
|
209 |
| -#define JULIAN_DAY 0 /* Jn - Julian day */ |
210 |
| -#define DAY_OF_YEAR 1 /* n - day of year */ |
211 |
| -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ |
212 |
| - |
213 | 123 | /*
|
214 | 124 | ** Prototypes for static functions.
|
215 | 125 | */
|
@@ -286,14 +196,6 @@ gmtsub (const int64_t *const timep, const int_fast32_t offset, struct bson_tm *c
|
286 | 196 | gmtload (gmtptr);
|
287 | 197 | }
|
288 | 198 | result = timesub (timep, offset, gmtptr, tmp);
|
289 |
| -#ifdef TM_ZONE |
290 |
| - /* |
291 |
| - ** Could get fancy here and deliver something such as |
292 |
| - ** "UT+xxxx" or "UT-xxxx" if offset is non-zero, |
293 |
| - ** but this is no time for a treasure hunt. |
294 |
| - */ |
295 |
| - tmp->TM_ZONE = offset ? wildabbr : gmtptr ? gmtptr->chars : gmt; |
296 |
| -#endif /* defined TM_ZONE */ |
297 | 199 | return result;
|
298 | 200 | }
|
299 | 201 |
|
|
0 commit comments