Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-shells/bash/files: autoconf-mktime-2.59.patch
Date: Tue, 06 May 2008 19:06:54
Message-Id: E1JtSUl-0006ye-H4@stork.gentoo.org
1 vapier 08/05/06 19:06:35
2
3 Added: autoconf-mktime-2.59.patch
4 Log:
5 Add patch for mktime issue #220040.
6 (Portage version: 2.2_pre5)
7
8 Revision Changes Path
9 1.1 app-shells/bash/files/autoconf-mktime-2.59.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-shells/bash/files/autoconf-mktime-2.59.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-shells/bash/files/autoconf-mktime-2.59.patch?rev=1.1&content-type=text/plain
13
14 Index: autoconf-mktime-2.59.patch
15 ===================================================================
16 http://bugs.gentoo.org/220040
17 --- configure
18 +++ configure
19 @@ -5299,26 +6059,25 @@
20 cat >>conftest.$ac_ext <<_ACEOF
21 /* end confdefs.h. */
22 /* Test program from Paul Eggert and Tony Leneis. */
23 -#if TIME_WITH_SYS_TIME
24 +#ifdef TIME_WITH_SYS_TIME
25 # include <sys/time.h>
26 # include <time.h>
27 #else
28 -# if HAVE_SYS_TIME_H
29 +# ifdef HAVE_SYS_TIME_H
30 # include <sys/time.h>
31 # else
32 # include <time.h>
33 # endif
34 #endif
35
36 -#if HAVE_STDLIB_H
37 -# include <stdlib.h>
38 -#endif
39 +#include <limits.h>
40 +#include <stdlib.h>
41
42 -#if HAVE_UNISTD_H
43 +#ifdef HAVE_UNISTD_H
44 # include <unistd.h>
45 #endif
46
47 -#if !HAVE_ALARM
48 +#ifndef HAVE_ALARM
49 # define alarm(X) /* empty */
50 #endif
51
52 @@ -5335,9 +6094,9 @@
53 };
54 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
55
56 -/* Fail if mktime fails to convert a date in the spring-forward gap.
57 +/* Return 0 if mktime fails to convert a date in the spring-forward gap.
58 Based on a problem report from Andreas Jaeger. */
59 -static void
60 +static int
61 spring_forward_gap ()
62 {
63 /* glibc (up to about 1998-10-07) failed this test. */
64 @@ -5356,29 +6115,27 @@
65 tm.tm_min = 0;
66 tm.tm_sec = 0;
67 tm.tm_isdst = -1;
68 - if (mktime (&tm) == (time_t)-1)
69 - exit (1);
70 + return mktime (&tm) != (time_t) -1;
71 }
72
73 -static void
74 +static int
75 mktime_test1 (now)
76 time_t now;
77 {
78 struct tm *lt;
79 - if ((lt = localtime (&now)) && mktime (lt) != now)
80 - exit (1);
81 + return ! (lt = localtime (&now)) || mktime (lt) == now;
82 }
83
84 -static void
85 +static int
86 mktime_test (now)
87 time_t now;
88 {
89 - mktime_test1 (now);
90 - mktime_test1 ((time_t) (time_t_max - now));
91 - mktime_test1 ((time_t) (time_t_min + now));
92 + return (mktime_test1 (now)
93 + && mktime_test1 ((time_t) (time_t_max - now))
94 + && mktime_test1 ((time_t) (time_t_min + now)));
95 }
96
97 -static void
98 +static int
99 irix_6_4_bug ()
100 {
101 /* Based on code from Ariel Faigon. */
102 @@ -5391,11 +6148,10 @@
103 tm.tm_sec = 0;
104 tm.tm_isdst = -1;
105 mktime (&tm);
106 - if (tm.tm_mon != 2 || tm.tm_mday != 31)
107 - exit (1);
108 + return tm.tm_mon == 2 && tm.tm_mday == 31;
109 }
110
111 -static void
112 +static int
113 bigtime_test (j)
114 int j;
115 {
116 @@ -5417,8 +6173,39 @@
117 && lt->tm_wday == tm.tm_wday
118 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
119 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
120 - exit (1);
121 + return 0;
122 }
123 + return 1;
124 +}
125 +
126 +static int
127 +year_2050_test ()
128 +{
129 + /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
130 + ignoring leap seconds. */
131 + unsigned long int answer = 2527315200UL;
132 +
133 + struct tm tm;
134 + time_t t;
135 + tm.tm_year = 2050 - 1900;
136 + tm.tm_mon = 2 - 1;
137 + tm.tm_mday = 1;
138 + tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
139 + tm.tm_isdst = -1;
140 +
141 + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
142 + instead of "TZ=America/Vancouver" in order to detect the bug even
143 + on systems that don't support the Olson extension, or don't have the
144 + full zoneinfo tables installed. */
145 + putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
146 +
147 + t = mktime (&tm);
148 +
149 + /* Check that the result is either a failure, or close enough
150 + to the correct answer that we can assume the discrepancy is
151 + due to leap seconds. */
152 + return (t == (time_t) -1
153 + || (0 < t && answer - 120 <= t && t <= answer + 120));
154 }
155
156 int
157 @@ -5432,12 +6219,15 @@
158 isn't worth using anyway. */
159 alarm (60);
160
161 - for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
162 - continue;
163 - time_t_max--;
164 - if ((time_t) -1 < 0)
165 - for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
166 - continue;
167 + for (;;)
168 + {
169 + t = (time_t_max << 1) + 1;
170 + if (t <= time_t_max)
171 + break;
172 + time_t_max = t;
173 + }
174 + time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
175 +
176 delta = time_t_max / 997; /* a suitable prime number */
177 for (i = 0; i < N_STRINGS; i++)
178 {
179 @@ -5445,18 +6235,22 @@
180 putenv (tz_strings[i]);
181
182 for (t = 0; t <= time_t_max - delta; t += delta)
183 - mktime_test (t);
184 - mktime_test ((time_t) 1);
185 - mktime_test ((time_t) (60 * 60));
186 - mktime_test ((time_t) (60 * 60 * 24));
187 -
188 - for (j = 1; 0 < j; j *= 2)
189 - bigtime_test (j);
190 - bigtime_test (j - 1);
191 + if (! mktime_test (t))
192 + return 1;
193 + if (! (mktime_test ((time_t) 1)
194 + && mktime_test ((time_t) (60 * 60))
195 + && mktime_test ((time_t) (60 * 60 * 24))))
196 + return 1;
197 +
198 + for (j = 1; ; j <<= 1)
199 + if (! bigtime_test (j))
200 + return 1;
201 + else if (INT_MAX / 2 < j)
202 + break;
203 + if (! bigtime_test (INT_MAX))
204 + return 1;
205 }
206 - irix_6_4_bug ();
207 - spring_forward_gap ();
208 - exit (0);
209 + return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
210 }
211 _ACEOF
212 rm -f conftest$ac_exeext
213
214
215
216 --
217 gentoo-commits@l.g.o mailing list