OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / glibc / glibc-2.3.6-tz1.patch
1 --- glibc-2.3.6/time/tzset.old  2004-12-07 08:50:41.000000000 +1000
2 +++ glibc-2.3.6/time/tzset.c    2008-09-10 20:08:39.000000000 +1000
3 @@ -21,10 +21,12 @@
4  #include <bits/libc-lock.h>
5  #include <stddef.h>
6  #include <stdio.h>
7 +#include <stdio_ext.h>
8  #include <stdlib.h>
9  #include <string.h>
10  #include <time.h>
11 -
12 +#include <unistd.h>
13 +#include <sys/stat.h>
14  
15  #define NOID
16  #include <timezone/tzfile.h>
17 @@ -160,6 +162,29 @@
18  
19    /* Examine the TZ environment variable.  */
20    tz = getenv ("TZ");
21 +  if (tz == NULL) {
22 +    /* Load our TZ file from our sysconfig directory */
23 +    struct stat64 st;
24 +    FILE *ptzf;
25 +    
26 +    /* Stat the file to make sure it exists, and to get the size of the TZ string */
27 +    if (stat64(POSIX_TZ_FILE, &st) == 0) {
28 +      if (st.st_size > 256)
29 +        return;
30 +      /* After we've checked we're not going to smash our stack, allocate */ 
31 +      tzbuf = __alloca(st.st_size + 1);
32 +      /* Open the file, and read a line. That is all the file should contain */
33 +      if ((ptzf = fopen(POSIX_TZ_FILE, "r")) != NULL) {
34 +        /* No threads reading this stream.  */
35 +        __fsetlocking (ptzf, FSETLOCKING_BYCALLER);
36 +        if (fgets_unlocked(tzbuf, st.st_size, ptzf) != NULL) {
37 +          tz = tzbuf;
38 +        }
39 +        fclose(ptzf);
40 +      }
41 +    }
42 +  }
43 +          
44    if (tz == NULL && !explicit)
45      /* Use the site-wide default.  This is a file name which means we
46         would not see changes to the file if we compare only the file
47 @@ -192,12 +217,12 @@
48    if (old_tz != NULL)
49      free (old_tz);
50    old_tz = tz ? __strdup (tz) : NULL;
51 -
52 +#if 0
53    /* Try to read a data file.  */
54    __tzfile_read (tz, 0, NULL);
55    if (__use_tzfile)
56      return;
57 -
58 +#endif
59    /* No data file found.  Default to UTC if nothing specified.  */
60  
61    if (tz == NULL || *tz == '\0'