long int change; /* Seconds of correction to apply. */
};
+extern char * __tzstring (const char *); /* Defined in tzset.c. */
+
static struct ttinfo *find_transition (time_t timer);
static void compute_tzname_max (size_t);
/* No user specification; use the site-wide default. */
file = TZDEFAULT;
else if (*file == '\0')
- /* User specified the empty string; use UTC explicitly. */
- file = "Universal";
+ /* User specified the empty string; use UTC with no leap seconds. */
+ return;
else
{
/* We must not allow to read an arbitrary file in a setuid
program. So we fail for any file which is not in the
- directory hierachy starting at TZDIR. */
+ directory hierachy starting at TZDIR
+ and which is not the system wide default TZDEFAULT. */
if (__libc_enable_secure
&& ((*file == '/'
- && (memcmp(file, TZDEFAULT, sizeof(TZDEFAULT) -1))
+ && memcmp (file, TZDEFAULT, sizeof TZDEFAULT)
&& memcmp (file, default_tzdir, sizeof (default_tzdir) - 1))
|| strstr (file, "../") != NULL))
- /* This test a certainly a bit too restrictive but it should
- catch all critical case. */
+ /* This test is certainly a bit too restrictive but it should
+ catch all critical cases. */
return;
}
for (i = 0; i < num_isstd; ++i)
{
- char c = getc (f);
+ int c = getc (f);
if (c == EOF)
goto lose;
types[i].isstd = c != 0;
for (i = 0; i < num_isgmt; ++i)
{
- char c = getc (f);
+ int c = getc (f);
if (c == EOF)
goto lose;
types[i].isgmt = c != 0;
info = find_transition (0);
for (i = 0; i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
++i)
- __tzname[types[i].isdst] = &zone_names[types[i].idx];
+ __tzname[types[i].isdst] = __tzstring (&zone_names[types[i].idx]);
if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
- __tzname[info->isdst] = &zone_names[info->idx];
+ __tzname[info->isdst] = __tzstring (&zone_names[info->idx]);
compute_tzname_max (chars);
from the TZDEFRULES file. */
void
-__tzfile_default (char *std, char *dst, long int stdoff, long int dstoff)
+__tzfile_default (const char *std, const char *dst,
+ long int stdoff, long int dstoff)
{
size_t stdlen, dstlen, i;
long int rule_offset, rule_stdoff, rule_dstoff;
types[1].isdst = 1;
/* Reset the zone names to point to the user's names. */
- __tzname[0] = &zone_names[0];
- __tzname[1] = &zone_names[stdlen];
+ __tzname[0] = (char *) std;
+ __tzname[1] = (char *) dst;
compute_tzname_max (stdlen + dstlen);
}
}
\f
int
-__tzfile_compute (time_t timer, long int *leap_correct, int *leap_hit)
+__tzfile_compute (time_t timer, int use_localtime,
+ long int *leap_correct, int *leap_hit)
{
- struct ttinfo *info;
register size_t i;
- info = find_transition (timer);
- __daylight = info->isdst;
- __timezone = info->offset;
- for (i = 0; i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
- ++i)
- __tzname[types[i].isdst] = &zone_names[types[i].idx];
- if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
- __tzname[info->isdst] = &zone_names[info->idx];
+ if (use_localtime)
+ {
+ struct ttinfo *info = find_transition (timer);
+ __daylight = info->isdst;
+ __timezone = info->offset;
+ for (i = 0;
+ i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
+ ++i)
+ __tzname[types[i].isdst] = &zone_names[types[i].idx];
+ if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
+ __tzname[info->isdst] = &zone_names[info->idx];
+ }
*leap_correct = 0L;
*leap_hit = 0;
return 1;
}
\f
-void
+static void
compute_tzname_max (size_t chars)
{
- extern size_t __tzname_cur_max; /* Defined in __tzset.c. */
+ extern size_t __tzname_cur_max; /* Defined in tzset.c. */
const char *p;