cvs: /php4/ext/dbase dbf_misc.c /php4/ext/standard parsedate.y
| From: | Jouni Ahto | Date: | Sat, 27 Nov 1999 20:51:18 +0000 |
| Subject: | cvs: /php4/ext/dbase dbf_misc.c /php4/ext/standard parsedate.y | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-6970@lists.php.net to get a copy of this message | ||
jah Sat Nov 27 15:51:18 1999 EDT
Modified files:
/php4/ext/dbase dbf_misc.c
/php4/ext/standard parsedate.y
Log:
Use thread-safe versions of localtime and gmtime
Index: php4/ext/dbase/dbf_misc.c
diff -u php4/ext/dbase/dbf_misc.c:1.1 php4/ext/dbase/dbf_misc.c:1.2
--- php4/ext/dbase/dbf_misc.c:1.1 Mon Apr 19 09:56:50 1999
+++ php4/ext/dbase/dbf_misc.c Sat Nov 27 15:51:16 1999
@@ -151,11 +151,11 @@
char *db_cur_date(char *cp)
{
- struct tm *ctm;
+ struct tm *ctm, tmbuf;
time_t c_time;
c_time = time((time_t *)NULL);
- ctm = localtime(&c_time);
+ ctm = localtime_r(&c_time, &tmbuf);
if (cp == NULL)
cp = (char *)malloc(9);
Index: php4/ext/standard/parsedate.y
diff -u php4/ext/standard/parsedate.y:1.3 php4/ext/standard/parsedate.y:1.4
--- php4/ext/standard/parsedate.y:1.3 Fri Sep 24 11:34:30 1999
+++ php4/ext/standard/parsedate.y Sat Nov 27 15:51:17 1999
@@ -1,5 +1,5 @@
%{
-/* $Revision: 1.3 $
+/* $Revision: 1.4 $
**
** Originally written by Steven M. Bellovin <smb@research.att.com> while
** at the University of North Carolina at Chapel Hill. Later tweaked by
@@ -533,13 +533,13 @@
{
static time_t NextHour;
static long LastTzone;
- struct tm *tm;
+ struct tm *tm, tmbuf;
int secondsUntilNextHour;
#if defined(HAVE_GETTIMEOFDAY)
struct timeval tv;
#endif /* defined(HAVE_GETTIMEOFDAY) */
#if !defined(HAVE_TM_GMTOFF)
- struct tm local;
+ struct tm local, tmbuf;
struct tm gmt;
#endif /* !defined(HAVE_TM_GMTOFF) */
@@ -557,13 +557,13 @@
/* Now get the timezone if the last time < HH:00:00 <= now for some HH. */
if (NextHour <= Now->time) {
- if ((tm = localtime(&Now->time)) == NULL)
+ if ((tm = localtime_r(&Now->time, &tmbuf)) == NULL)
return -1;
secondsUntilNextHour = 60 * (60 - tm->tm_min) - tm->tm_sec;
#if !defined(HAVE_TM_GMTOFF)
/* To get the timezone, compare localtime with GMT. */
local = *tm;
- if ((tm = gmtime(&Now->time)) == NULL)
+ if ((tm = gmtime_r(&Now->time, &tmbuf)) == NULL)
return -1;
gmt = *tm;
@@ -698,11 +698,11 @@
time_t Start;
time_t RelMonth;
{
- struct tm *tm;
+ struct tm *tm, tmbuf;
time_t Month;
time_t Year;
- tm = localtime(&Start);
+ tm = localtime_r(&Start, &tmbuf);
Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
Year = Month / 12;
Year += 1900;
@@ -868,7 +868,7 @@
time_t parsedate(char *p, TIMEINFO *now)
{
extern int date_parse();
- struct tm *tm;
+ struct tm *tm, tmbuf;
TIMEINFO ti;
time_t Start;
@@ -878,7 +878,7 @@
(void)GetTimeInfo(&ti);
}
- tm = localtime(&now->time);
+ tm = localtime_r(&now->time, &tmbuf);
yyYear = tm->tm_year + 1900;
yyMonth = tm->tm_mon + 1;
yyDay = tm->tm_mday;