From a3b5844025aa90fd28f3bf5a27be116852761f4e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 16 Jun 1996 04:52:54 +0000 Subject: Sun Jun 16 00:40:20 1996 Roland McGrath * time/Makefile ($(installed-localtime-file)): If target exists, do nothing but print a message; if not, make it an absolute symlink. * time/tzset.c (__tzset): After stripping leading :, call __tzfile_read on TZ even if it's empty or null. * time/tzfile.c (__tzfile_read): Use "Universal" if passed "". --- time/tzset.c | 64 ++++++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) (limited to 'time/tzset.c') diff --git a/time/tzset.c b/time/tzset.c index 5f949dce5f..d3a33dc1ce 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -99,45 +99,41 @@ DEFUN_VOID(__tzset) /* Examine the TZ environment variable. */ tz = getenv ("TZ"); - if (tz != NULL) + /* A leading colon means "implementation defined syntax". + We ignore the colon and always use the same algorithm: + try a data file, and if none exists parse the 1003.1 syntax. */ + if (tz && *tz == ':') + ++tz; + + /* Try to read a data file. */ + __tzfile_read (tz); + if (__use_tzfile) { - /* A leading colon means "implementation defined syntax". - We ignore the colon and always use the same algorithm: - try a data file, and if none exists parse the 1003.1 syntax. */ - if (*tz == ':') - ++tz; - - __tzfile_read (tz); - if (__use_tzfile) - { - __tzset_run = 1; - return; - } + __tzset_run = 1; + return; } + /* No data file found. Default to UTC if nothing specified. */ + if (tz == NULL || *tz == '\0') { - __tzfile_read((char *) NULL); - if (!__use_tzfile) - { - const char UTC[] = "UTC"; - size_t len = sizeof UTC; - tz_rules[0].name = (char *) malloc(len); - if (tz_rules[0].name == NULL) - return; - tz_rules[1].name = (char *) malloc(len); - if (tz_rules[1].name == NULL) - return; - memcpy ((PTR) tz_rules[0].name, UTC, len); - memcpy ((PTR) tz_rules[1].name, UTC, len); - tz_rules[0].type = tz_rules[1].type = J0; - tz_rules[0].m = tz_rules[0].n = tz_rules[0].d = 0; - tz_rules[1].m = tz_rules[1].n = tz_rules[1].d = 0; - tz_rules[0].secs = tz_rules[1].secs = 0; - tz_rules[0].offset = tz_rules[1].offset = 0L; - tz_rules[0].change = tz_rules[1].change = (time_t) -1; - tz_rules[0].computed_for = tz_rules[1].computed_for = 0; - } + static const char UTC[] = "UTC"; + size_t len = sizeof UTC; + tz_rules[0].name = (char *) malloc(len); + if (tz_rules[0].name == NULL) + return; + tz_rules[1].name = (char *) malloc(len); + if (tz_rules[1].name == NULL) + return; + memcpy ((PTR) tz_rules[0].name, UTC, len); + memcpy ((PTR) tz_rules[1].name, UTC, len); + tz_rules[0].type = tz_rules[1].type = J0; + tz_rules[0].m = tz_rules[0].n = tz_rules[0].d = 0; + tz_rules[1].m = tz_rules[1].n = tz_rules[1].d = 0; + tz_rules[0].secs = tz_rules[1].secs = 0; + tz_rules[0].offset = tz_rules[1].offset = 0L; + tz_rules[0].change = tz_rules[1].change = (time_t) -1; + tz_rules[0].computed_for = tz_rules[1].computed_for = 0; __tzset_run = 1; return; } -- cgit v1.2.3