diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-01-06 22:07:28 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-01-06 22:07:28 +0000 |
commit | df4ef2ab9c0899b2670067cd97e58f7eb2913e00 (patch) | |
tree | 4cb343b5ba9ccdc9c0b96144412567b6a4eda0ee /time | |
parent | 6f9e7002f38ae778b3ff2f586a3e5766382228e9 (diff) | |
download | glibc-df4ef2ab9c0899b2670067cd97e58f7eb2913e00.tar.gz |
update from main archive 960105cvs/libc-970107cvs/libc-970106
Diffstat (limited to 'time')
-rw-r--r-- | time/ap.c | 16 | ||||
-rw-r--r-- | time/localtime.c | 11 | ||||
-rw-r--r-- | time/sys/time.h | 3 | ||||
-rw-r--r-- | time/tzset.c | 18 |
4 files changed, 29 insertions, 19 deletions
@@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,11 +20,12 @@ #include <stdlib.h> #include <time.h> #include <malloc.h> +#include <mcheck.h> /* Prints the time in the form "hh:mm ?M", where ? is A or P. A simple test for strftime(). */ int -main (int argc, char **argv) +main (int argc, char *argv[]) { char buf[20]; time_t t; @@ -32,14 +33,13 @@ main (int argc, char **argv) mcheck (NULL); if (argc != 1) - fprintf(stderr, "Usage: %s\n", argv[0]); + fprintf (stderr, "Usage: %s\n", argv[0]); - t = time((time_t *) NULL); - if (strftime(buf, sizeof(buf), "%I:%M %p", localtime(&t)) == 0) - exit(EXIT_FAILURE); + t = time ((time_t *) NULL); + if (strftime (buf, sizeof (buf), "%I:%M %p", localtime (&t)) == 0) + exit (EXIT_FAILURE); - puts(buf); + puts (buf); - exit(EXIT_SUCCESS); return EXIT_SUCCESS; } diff --git a/time/localtime.c b/time/localtime.c index f228776952..ab8fc1ac45 100644 --- a/time/localtime.c +++ b/time/localtime.c @@ -1,5 +1,5 @@ /* Convert `time_t' to `struct tm' in local time zone. - Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,7 +25,7 @@ struct tm _tmbuf; /* Prototype for the internal function to get information based on TZ. */ -extern void __tzset_internal __P ((void)); +extern void __tzset_internal __P ((int always)); extern int __tz_compute __P ((time_t timer, struct tm *tp)); extern int __tzfile_compute __P ((time_t timer, long int *leap_correct, int *leap_hit)); @@ -90,8 +90,8 @@ localtime (timer) __libc_lock_lock (__tzset_lock); - /* Make sure the database is initialized. */ - __tzset_internal (); + /* Update internal database according to current TZ setting. */ + __tzset_internal (1); result = localtime_internal (timer, &_tmbuf); @@ -110,6 +110,9 @@ __localtime_r (timer, tp) __libc_lock_lock (__tzset_lock); + /* Make sure the database is initialized. */ + __tzset_internal (0); + result = localtime_internal (timer, tp); __libc_lock_unlock (__tzset_lock); diff --git a/time/sys/time.h b/time/sys/time.h index f6c6f74878..5519f716ca 100644 --- a/time/sys/time.h +++ b/time/sys/time.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 94, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,7 @@ #include <features.h> #include <time.h> +#include <sys/select.h> #define __need_timeval #include <timebits.h> diff --git a/time/tzset.c b/time/tzset.c index 886ac6c0c8..13360b445b 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -77,15 +77,21 @@ static int compute_change __P ((tz_rule *rule, int year)); static char *old_tz = NULL; /* Interpret the TZ envariable. */ -void __tzset_internal __P ((void)); +void __tzset_internal __P ((int always)); void -__tzset_internal () +__tzset_internal (always) + int always; { + static int is_initialized = 0; register const char *tz; register size_t l; unsigned short int hh, mm, ss; unsigned short int whichrule; + if (is_initialized && !always) + return; + is_initialized = 1; + /* Examine the TZ environment variable. */ tz = getenv ("TZ"); @@ -375,7 +381,7 @@ size_t __tzname_cur_max; long int __tzname_max () { - __tzset_internal (); + __tzset_internal (0); return __tzname_cur_max; } @@ -473,7 +479,7 @@ __tz_compute (timer, tm) time_t timer; const struct tm *tm; { - __tzset_internal (); + __tzset_internal (0); if (! compute_change (&tz_rules[0], 1900 + tm->tm_year) || ! compute_change (&tz_rules[1], 1900 + tm->tm_year)) @@ -510,7 +516,7 @@ __tzset (void) { __libc_lock_lock (__tzset_lock); - __tzset_internal (); + __tzset_internal (1); if (!__use_tzfile) { |