Skip to content

Commit e3cbafd

Browse files
author
Sam Ruby
committed
-kludges -warning +reentrancy(more) +compiles(Unix)
1 parent 091c58f commit e3cbafd

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

ext/standard/parsedate.y

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252

5353
#if WIN32||WINNT
5454
# include <time.h>
55-
# include "php.h"
56-
# undef YYSTYPE
5755
# include "php_reentrancy.h"
5856
#else
5957
# if !defined(HAVE_TM_ZONE) && !defined(_TIMEZONE)
@@ -62,8 +60,6 @@ extern time_t timezone;
6260
#endif
6361

6462

65-
66-
6763
#define yylhs date_yylhs
6864
#define yylen date_yylen
6965
#define yydefred date_yydefred
@@ -157,10 +153,6 @@ static time_t yyRelMonth;
157153
static time_t yyRelSeconds;
158154

159155

160-
extern struct tm *localtime(const time_t *timep);
161-
162-
/* YYSTYPE is not yet defined at this point */
163-
static int date_lex(void *yylval);
164156

165157
static void date_error(char *s);
166158

@@ -174,6 +166,10 @@ static void date_error(char *s);
174166
enum _MERIDIAN Meridian;
175167
}
176168

169+
%{
170+
static int date_lex(YYSTYPE *yylval);
171+
%}
172+
177173
%token tDAY tDAYZONE tMERIDIAN tMONTH tMONTH_UNIT tSEC_UNIT tSNUMBER
178174
%token tUNUMBER tZONE
179175

@@ -642,6 +638,7 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, tim
642638
time_t Julian;
643639
int i;
644640
time_t tod;
641+
struct tm tmbuf;
645642

646643
/* Year should not be passed as a relative value, but absolute one.
647644
so this should not happen, but just ensure it */
@@ -674,7 +671,7 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, tim
674671
return -1;
675672
Julian += tod;
676673
tod = Julian;
677-
if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
674+
if (dst == DSTon || (dst == DSTmaybe && localtime_r(&tod,&tmbuf)->tm_isdst))
678675
Julian -= DST_OFFSET * 60 * 60;
679676
return Julian;
680677
}
@@ -685,9 +682,10 @@ DSTcorrect(time_t Start, time_t Future)
685682
{
686683
time_t StartDay;
687684
time_t FutureDay;
685+
struct tm tmbuf;
688686

689-
StartDay = (localtime(&Start)->tm_hour + 1) % 24;
690-
FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
687+
StartDay = (localtime_r(&Start,&tmbuf)->tm_hour + 1) % 24;
688+
FutureDay = (localtime_r(&Future,&tmbuf)->tm_hour + 1) % 24;
691689
return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60 * 60;
692690
}
693691

@@ -864,7 +862,6 @@ static int date_lex(YYSTYPE *yylval)
864862

865863
time_t parsedate(char *p, TIMEINFO *now)
866864
{
867-
extern int date_parse(void);
868865
struct tm *tm, tmbuf;
869866
TIMEINFO ti;
870867
time_t Start;
@@ -895,7 +892,7 @@ time_t parsedate(char *p, TIMEINFO *now)
895892
yyHaveRel = 0;
896893
yyHaveTime = 0;
897894

898-
if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
895+
if (date_parse(YYPARSE_PARAM_ARG) || yyHaveTime > 1 || yyHaveDate > 1)
899896
return -1;
900897

901898
if (yyHaveDate || yyHaveTime) {

0 commit comments

Comments
 (0)