| 285 | /* A UT time zone, and its initializer. */ |
| 286 | static timezone_t gmtz; |
| 287 | static void |
| 288 | gmtzinit(void) |
| 289 | { |
| 290 | if (USE_LOCALTIME_RZ) { |
| 291 | /* Try "GMT" first to find out whether this is one of the rare |
| 292 | platforms where time_t counts leap seconds; this works due to |
| 293 | the "Zone GMT 0 - GMT" line in the "etcetera" file. If "GMT" |
| 294 | fails, fall back on "GMT0" which might be similar due to the |
| 295 | "Link GMT GMT0" line in the "backward" file, and which |
| 296 | should work on all POSIX platforms. The rest of zdump does not |
| 297 | use the "GMT" abbreviation that comes from this setting, so it |
| 298 | is OK to use "GMT" here rather than the modern "UTC" which |
| 299 | would not work on platforms that omit the "backward" file. */ |
| 300 | gmtz = tzalloc("GMT"); |
| 301 | if (!gmtz) { |
| 302 | static char const gmt0[] = "GMT0"; |
| 303 | gmtz = tzalloc(gmt0); |
| 304 | if (!gmtz) { |
| 305 | char const *e = strerror(errno); |
| 306 | fprintf(stderr, _("%s: unknown timezone '%s': %s\n"), |
| 307 | progname, gmt0, e); |
| 308 | exit(EXIT_FAILURE); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | /* Convert *TP to UT, storing the broken-down time into *TMP. |
| 315 | Return TMP if successful, NULL otherwise. This is like gmtime_r(TP, TMP), |