This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A time question


Hi,

There is a bug in the time code.

# gcc t.c
# TZ=JKL3:10PNM4:40 a.out

will print some garbage. It is because __tzfile_default doesn't reset
num_types when it sets types. Could someone please take a look?

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
----t.c--
#include <stdio.h>
#include <time.h>

extern char *__tzname [];

main ()
{
  time_t  clockval = 586185855L;
  (void) ctime(&clockval);
  printf ("%s\n", __tzname [1]);
}
----
Sat Oct 24 16:32:44 1998  H.J. Lu  <hjl@gnu.org>

	* time/tzfile.c (__tzfile_default): Set num_types to 2.

Index: time/tzfile.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/time/tzfile.c,v
retrieving revision 1.1.1.12
diff -u -p -r1.1.1.12 tzfile.c
--- tzfile.c	1998/09/11 13:55:04	1.1.1.12
+++ tzfile.c	1998/10/24 23:29:43
@@ -382,6 +382,7 @@ __tzfile_default (const char *std, const
   types[1].idx = stdlen;
   types[1].offset = dstoff;
   types[1].isdst = 1;
+  num_types = 2;
 
   /* Reset the zone names to point to the user's names.  */
   __tzname[0] = (char *) std;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]