diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-11-13 13:25:47 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-11-13 13:25:47 +0000 |
commit | a3e0e9ae473ae52861c5bceb8a6feb624bf30c61 (patch) | |
tree | 3ab4a7213bedeb7a7995d53867cd7d0c72d76ef0 /time | |
parent | 7f2a1e3cf8077faa2c5de78f081890302a4c8362 (diff) | |
download | glibc-a3e0e9ae473ae52861c5bceb8a6feb624bf30c61.tar.gz glibc-a3e0e9ae473ae52861c5bceb8a6feb624bf30c61.tar.xz glibc-a3e0e9ae473ae52861c5bceb8a6feb624bf30c61.zip |
Update.
1998-11-13 Ulrich Drepper <drepper@cygnus.com> * libio/bits/stdio.h: Correct and improve fread_unlocked and fwrite_unlocked optimizations. * time/tzfile.c (__tzfile_read): Set __tzname based on last names in time not to last entries in the file. (__tzfile_compute): Likewise. Fix for PR libc/863. * timezone/Makefile: Generate GB timezone data for test. * timezone/tst-timezone.c: More tests for DST switching time (disabled for now). 1998-11-13 Andreas Schwab <schwab@issan.cs.uni-dortmund.de> * sysdeps/gnu/bits/utmp.h: Rename pad member of struct utmp to
Diffstat (limited to 'time')
-rw-r--r-- | time/tzfile.c | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/time/tzfile.c b/time/tzfile.c index 7c72aad103..1bce14c3f0 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -16,11 +16,12 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stdlib.h> +#include <assert.h> +#include <limits.h> #include <stdio.h> -#include <time.h> +#include <stdlib.h> #include <string.h> -#include <limits.h> +#include <time.h> #include <unistd.h> #define NOID @@ -172,7 +173,7 @@ __tzfile_read (const char *file) if (num_transitions > 0) { - transitions = (time_t *) malloc (num_transitions * sizeof(time_t)); + transitions = (time_t *) malloc (num_transitions * sizeof (time_t)); if (transitions == NULL) goto lose; type_idxs = (unsigned char *) malloc (num_transitions); @@ -219,7 +220,7 @@ __tzfile_read (const char *file) processed when sizeof (time_t) > 4. */ i = num_transitions; while (i-- > 0) - transitions[i] = decode ((char *) transitions + i*4); + transitions[i] = decode ((char *) transitions + i * 4); } for (i = 0; i < num_types; ++i) @@ -270,12 +271,36 @@ __tzfile_read (const char *file) fclose (f); + /* First "register" all timezone names. */ + for (i = 0; i < num_types; ++i) + (void) __tzstring (&zone_names[types[i].idx]); + /* Find the standard and daylight time offsets used by the rule file. We choose the offsets in the types of each flavor that are transitioned to earliest in time. */ + __tzname[0] = NULL; __tzname[1] = NULL; - for (i = 0; i < num_types; ++i) - __tzname[types[i].isdst] = __tzstring (&zone_names[types[i].idx]); + for (i = num_transitions; i > 0; ) + { + int type = type_idxs[--i]; + int dst = types[type].isdst; + int idx = types[type].idx; + + if (__tzname[dst] == NULL) + { + __tzname[dst] = __tzstring (&zone_names[idx]); + + if (__tzname[1 - dst] != NULL) + break; + } + } + if (__tzname[0] == NULL) + { + /* This should only happen if there are no transition rules. + In this case there should be only one single type. */ + assert (num_types == 1); + __tzname[0] = __tzstring (zone_names); + } if (__tzname[1] == NULL) __tzname[1] = __tzname[0]; @@ -438,9 +463,29 @@ __tzfile_compute (time_t timer, int use_localtime, struct ttinfo *info = find_transition (timer); __daylight = rule_stdoff != rule_dstoff; __timezone = -rule_stdoff; + __tzname[0] = NULL; __tzname[1] = NULL; - for (i = 0; i < num_types; ++i) - __tzname[types[i].isdst] = __tzstring (&zone_names[types[i].idx]); + for (i = num_transitions; i > 0; ) + { + int type = type_idxs[--i]; + int dst = types[type].isdst; + int idx = types[type].idx; + + if (__tzname[dst] == NULL) + { + __tzname[dst] = __tzstring (&zone_names[idx]); + + if (__tzname[1 - dst] != NULL) + break; + } + } + if (__tzname[0] == NULL) + { + /* This should only happen if there are no transition rules. + In this case there should be only one single type. */ + assert (num_types == 1); + __tzname[0] = __tzstring (zone_names); + } if (__tzname[1] == NULL) /* There is no daylight saving time. */ __tzname[1] = __tzname[0]; |