1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

newly generated

This commit is contained in:
Daniel Stenberg 2002-01-28 18:39:55 +00:00
parent ae8375516b
commit 5d3dd7911e

View File

@ -197,38 +197,40 @@ typedef enum _MERIDIAN {
MERam, MERpm, MER24 MERam, MERpm, MER24
} MERIDIAN; } MERIDIAN;
/* parse results and input string */
typedef struct _CONTEXT {
const char *yyInput;
int yyDayOrdinal;
int yyDayNumber;
int yyHaveDate;
int yyHaveDay;
int yyHaveRel;
int yyHaveTime;
int yyHaveZone;
int yyTimezone;
int yyDay;
int yyHour;
int yyMinutes;
int yyMonth;
int yySeconds;
int yyYear;
MERIDIAN yyMeridian;
int yyRelDay;
int yyRelHour;
int yyRelMinutes;
int yyRelMonth;
int yyRelSeconds;
int yyRelYear;
} CONTEXT;
/* /* enable use of extra argument to yyparse and yylex which can be used to pass
** Global variables. We could get rid of most of these by using a good ** in a user defined value (CONTEXT struct in our case)
** union as the yacc stack. (This routine was originally written before
** yacc had the %union construct.) Maybe someday; right now we only use
** the %union very rarely.
*/ */
static const char *yyInput; #define YYPARSE_PARAM cookie
static int yyDayOrdinal; #define YYLEX_PARAM cookie
static int yyDayNumber; #define context ((CONTEXT *) cookie)
static int yyHaveDate;
static int yyHaveDay;
static int yyHaveRel;
static int yyHaveTime;
static int yyHaveZone;
static int yyTimezone;
static int yyDay;
static int yyHour;
static int yyMinutes;
static int yyMonth;
static int yySeconds;
static int yyYear;
static MERIDIAN yyMeridian;
static int yyRelDay;
static int yyRelHour;
static int yyRelMinutes;
static int yyRelMonth;
static int yyRelSeconds;
static int yyRelYear;
#line 218 "getdate.y"
#line 211 "getdate.y"
typedef union { typedef union {
int Number; int Number;
enum _MERIDIAN Meridian; enum _MERIDIAN Meridian;
@ -311,11 +313,11 @@ static const short yyrhs[] = { -1,
#if YYDEBUG != 0 #if YYDEBUG != 0
static const short yyrline[] = { 0, static const short yyrline[] = { 0,
227, 228, 231, 234, 237, 240, 243, 246, 249, 255, 234, 235, 238, 241, 244, 247, 250, 253, 256, 262,
261, 270, 276, 288, 291, 294, 300, 304, 308, 314, 268, 277, 283, 295, 298, 301, 307, 311, 315, 321,
318, 336, 342, 348, 352, 357, 361, 368, 376, 379, 325, 343, 349, 355, 359, 364, 368, 375, 383, 386,
382, 385, 388, 391, 394, 397, 400, 403, 406, 409, 389, 392, 395, 398, 401, 404, 407, 410, 413, 416,
412, 415, 418, 421, 424, 427, 430, 435, 468, 472 419, 422, 425, 428, 431, 434, 437, 442, 476, 480
}; };
#endif #endif
@ -395,6 +397,8 @@ static const short yycheck[] = { 0,
11, 15, 13, 14, 16, 19, 17, 16, 21, 0, 11, 15, 13, 14, 16, 19, 17, 16, 21, 0,
56 56
}; };
#define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/local/share/bison.simple" #line 3 "/usr/local/share/bison.simple"
/* This file comes from bison-1.28. */ /* This file comes from bison-1.28. */
@ -939,135 +943,135 @@ yyreduce:
switch (yyn) { switch (yyn) {
case 3: case 3:
#line 231 "getdate.y" #line 238 "getdate.y"
{ {
yyHaveTime++; context->yyHaveTime++;
; ;
break;} break;}
case 4: case 4:
#line 234 "getdate.y" #line 241 "getdate.y"
{ {
yyHaveZone++; context->yyHaveZone++;
; ;
break;} break;}
case 5: case 5:
#line 237 "getdate.y" #line 244 "getdate.y"
{ {
yyHaveDate++; context->yyHaveDate++;
; ;
break;} break;}
case 6: case 6:
#line 240 "getdate.y" #line 247 "getdate.y"
{ {
yyHaveDay++; context->yyHaveDay++;
; ;
break;} break;}
case 7: case 7:
#line 243 "getdate.y" #line 250 "getdate.y"
{ {
yyHaveRel++; context->yyHaveRel++;
; ;
break;} break;}
case 9: case 9:
#line 249 "getdate.y" #line 256 "getdate.y"
{ {
yyHour = yyvsp[-1].Number; context->yyHour = yyvsp[-1].Number;
yyMinutes = 0; context->yyMinutes = 0;
yySeconds = 0; context->yySeconds = 0;
yyMeridian = yyvsp[0].Meridian; context->yyMeridian = yyvsp[0].Meridian;
; ;
break;} break;}
case 10: case 10:
#line 255 "getdate.y" #line 262 "getdate.y"
{ {
yyHour = yyvsp[-3].Number; context->yyHour = yyvsp[-3].Number;
yyMinutes = yyvsp[-1].Number; context->yyMinutes = yyvsp[-1].Number;
yySeconds = 0; context->yySeconds = 0;
yyMeridian = yyvsp[0].Meridian; context->yyMeridian = yyvsp[0].Meridian;
; ;
break;} break;}
case 11: case 11:
#line 261 "getdate.y" #line 268 "getdate.y"
{ {
yyHour = yyvsp[-3].Number; context->yyHour = yyvsp[-3].Number;
yyMinutes = yyvsp[-1].Number; context->yyMinutes = yyvsp[-1].Number;
yyMeridian = MER24; context->yyMeridian = MER24;
yyHaveZone++; context->yyHaveZone++;
yyTimezone = (yyvsp[0].Number < 0 context->yyTimezone = (yyvsp[0].Number < 0
? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60 ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
: - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60)); : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
; ;
break;} break;}
case 12: case 12:
#line 270 "getdate.y" #line 277 "getdate.y"
{ {
yyHour = yyvsp[-5].Number; context->yyHour = yyvsp[-5].Number;
yyMinutes = yyvsp[-3].Number; context->yyMinutes = yyvsp[-3].Number;
yySeconds = yyvsp[-1].Number; context->yySeconds = yyvsp[-1].Number;
yyMeridian = yyvsp[0].Meridian; context->yyMeridian = yyvsp[0].Meridian;
; ;
break;} break;}
case 13: case 13:
#line 276 "getdate.y" #line 283 "getdate.y"
{ {
yyHour = yyvsp[-5].Number; context->yyHour = yyvsp[-5].Number;
yyMinutes = yyvsp[-3].Number; context->yyMinutes = yyvsp[-3].Number;
yySeconds = yyvsp[-1].Number; context->yySeconds = yyvsp[-1].Number;
yyMeridian = MER24; context->yyMeridian = MER24;
yyHaveZone++; context->yyHaveZone++;
yyTimezone = (yyvsp[0].Number < 0 context->yyTimezone = (yyvsp[0].Number < 0
? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60 ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
: - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60)); : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
; ;
break;} break;}
case 14: case 14:
#line 288 "getdate.y" #line 295 "getdate.y"
{ {
yyTimezone = yyvsp[0].Number; context->yyTimezone = yyvsp[0].Number;
; ;
break;} break;}
case 15: case 15:
#line 291 "getdate.y" #line 298 "getdate.y"
{ {
yyTimezone = yyvsp[0].Number - 60; context->yyTimezone = yyvsp[0].Number - 60;
; ;
break;} break;}
case 16: case 16:
#line 295 "getdate.y" #line 302 "getdate.y"
{ {
yyTimezone = yyvsp[-1].Number - 60; context->yyTimezone = yyvsp[-1].Number - 60;
; ;
break;} break;}
case 17: case 17:
#line 300 "getdate.y" #line 307 "getdate.y"
{ {
yyDayOrdinal = 1; context->yyDayOrdinal = 1;
yyDayNumber = yyvsp[0].Number; context->yyDayNumber = yyvsp[0].Number;
; ;
break;} break;}
case 18: case 18:
#line 304 "getdate.y" #line 311 "getdate.y"
{ {
yyDayOrdinal = 1; context->yyDayOrdinal = 1;
yyDayNumber = yyvsp[-1].Number; context->yyDayNumber = yyvsp[-1].Number;
; ;
break;} break;}
case 19: case 19:
#line 308 "getdate.y" #line 315 "getdate.y"
{ {
yyDayOrdinal = yyvsp[-1].Number; context->yyDayOrdinal = yyvsp[-1].Number;
yyDayNumber = yyvsp[0].Number; context->yyDayNumber = yyvsp[0].Number;
; ;
break;} break;}
case 20: case 20:
#line 314 "getdate.y" #line 321 "getdate.y"
{ {
yyMonth = yyvsp[-2].Number; context->yyMonth = yyvsp[-2].Number;
yyDay = yyvsp[0].Number; context->yyDay = yyvsp[0].Number;
; ;
break;} break;}
case 21: case 21:
#line 318 "getdate.y" #line 325 "getdate.y"
{ {
/* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY. /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
The goal in recognizing YYYY/MM/DD is solely to support legacy The goal in recognizing YYYY/MM/DD is solely to support legacy
@ -1075,226 +1079,227 @@ case 21:
you want portability, use the ISO 8601 format. */ you want portability, use the ISO 8601 format. */
if (yyvsp[-4].Number >= 1000) if (yyvsp[-4].Number >= 1000)
{ {
yyYear = yyvsp[-4].Number; context->yyYear = yyvsp[-4].Number;
yyMonth = yyvsp[-2].Number; context->yyMonth = yyvsp[-2].Number;
yyDay = yyvsp[0].Number; context->yyDay = yyvsp[0].Number;
} }
else else
{ {
yyMonth = yyvsp[-4].Number; context->yyMonth = yyvsp[-4].Number;
yyDay = yyvsp[-2].Number; context->yyDay = yyvsp[-2].Number;
yyYear = yyvsp[0].Number; context->yyYear = yyvsp[0].Number;
} }
; ;
break;} break;}
case 22: case 22:
#line 336 "getdate.y" #line 343 "getdate.y"
{ {
/* ISO 8601 format. yyyy-mm-dd. */ /* ISO 8601 format. yyyy-mm-dd. */
yyYear = yyvsp[-2].Number; context->yyYear = yyvsp[-2].Number;
yyMonth = -yyvsp[-1].Number; context->yyMonth = -yyvsp[-1].Number;
yyDay = -yyvsp[0].Number; context->yyDay = -yyvsp[0].Number;
; ;
break;} break;}
case 23: case 23:
#line 342 "getdate.y" #line 349 "getdate.y"
{ {
/* e.g. 17-JUN-1992. */ /* e.g. 17-JUN-1992. */
yyDay = yyvsp[-2].Number; context->yyDay = yyvsp[-2].Number;
yyMonth = yyvsp[-1].Number; context->yyMonth = yyvsp[-1].Number;
yyYear = -yyvsp[0].Number; context->yyYear = -yyvsp[0].Number;
; ;
break;} break;}
case 24: case 24:
#line 348 "getdate.y" #line 355 "getdate.y"
{ {
yyMonth = yyvsp[-1].Number; context->yyMonth = yyvsp[-1].Number;
yyDay = yyvsp[0].Number; context->yyDay = yyvsp[0].Number;
; ;
break;} break;}
case 25: case 25:
#line 352 "getdate.y" #line 359 "getdate.y"
{ {
yyMonth = yyvsp[-3].Number; context->yyMonth = yyvsp[-3].Number;
yyDay = yyvsp[-2].Number; context->yyDay = yyvsp[-2].Number;
yyYear = yyvsp[0].Number; context->yyYear = yyvsp[0].Number;
; ;
break;} break;}
case 26: case 26:
#line 357 "getdate.y" #line 364 "getdate.y"
{ {
yyMonth = yyvsp[0].Number; context->yyMonth = yyvsp[0].Number;
yyDay = yyvsp[-1].Number; context->yyDay = yyvsp[-1].Number;
; ;
break;} break;}
case 27: case 27:
#line 361 "getdate.y" #line 368 "getdate.y"
{ {
yyMonth = yyvsp[-1].Number; context->yyMonth = yyvsp[-1].Number;
yyDay = yyvsp[-2].Number; context->yyDay = yyvsp[-2].Number;
yyYear = yyvsp[0].Number; context->yyYear = yyvsp[0].Number;
; ;
break;} break;}
case 28: case 28:
#line 368 "getdate.y" #line 375 "getdate.y"
{ {
yyRelSeconds = -yyRelSeconds; context->yyRelSeconds = -context->yyRelSeconds;
yyRelMinutes = -yyRelMinutes; context->yyRelMinutes = -context->yyRelMinutes;
yyRelHour = -yyRelHour; context->yyRelHour = -context->yyRelHour;
yyRelDay = -yyRelDay; context->yyRelDay = -context->yyRelDay;
yyRelMonth = -yyRelMonth; context->yyRelMonth = -context->yyRelMonth;
yyRelYear = -yyRelYear; context->yyRelYear = -context->yyRelYear;
; ;
break;} break;}
case 30: case 30:
#line 379 "getdate.y" #line 386 "getdate.y"
{ {
yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 31: case 31:
#line 382 "getdate.y" #line 389 "getdate.y"
{ {
yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 32: case 32:
#line 385 "getdate.y" #line 392 "getdate.y"
{ {
yyRelYear += yyvsp[0].Number; context->yyRelYear += yyvsp[0].Number;
; ;
break;} break;}
case 33: case 33:
#line 388 "getdate.y" #line 395 "getdate.y"
{ {
yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 34: case 34:
#line 391 "getdate.y" #line 398 "getdate.y"
{ {
yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 35: case 35:
#line 394 "getdate.y" #line 401 "getdate.y"
{ {
yyRelMonth += yyvsp[0].Number; context->yyRelMonth += yyvsp[0].Number;
; ;
break;} break;}
case 36: case 36:
#line 397 "getdate.y" #line 404 "getdate.y"
{ {
yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 37: case 37:
#line 400 "getdate.y" #line 407 "getdate.y"
{ {
yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 38: case 38:
#line 403 "getdate.y" #line 410 "getdate.y"
{ {
yyRelDay += yyvsp[0].Number; context->yyRelDay += yyvsp[0].Number;
; ;
break;} break;}
case 39: case 39:
#line 406 "getdate.y" #line 413 "getdate.y"
{ {
yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 40: case 40:
#line 409 "getdate.y" #line 416 "getdate.y"
{ {
yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 41: case 41:
#line 412 "getdate.y" #line 419 "getdate.y"
{ {
yyRelHour += yyvsp[0].Number; context->yyRelHour += yyvsp[0].Number;
; ;
break;} break;}
case 42: case 42:
#line 415 "getdate.y" #line 422 "getdate.y"
{ {
yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 43: case 43:
#line 418 "getdate.y" #line 425 "getdate.y"
{ {
yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 44: case 44:
#line 421 "getdate.y" #line 428 "getdate.y"
{ {
yyRelMinutes += yyvsp[0].Number; context->yyRelMinutes += yyvsp[0].Number;
; ;
break;} break;}
case 45: case 45:
#line 424 "getdate.y" #line 431 "getdate.y"
{ {
yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 46: case 46:
#line 427 "getdate.y" #line 434 "getdate.y"
{ {
yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
; ;
break;} break;}
case 47: case 47:
#line 430 "getdate.y" #line 437 "getdate.y"
{ {
yyRelSeconds += yyvsp[0].Number; context->yyRelSeconds += yyvsp[0].Number;
; ;
break;} break;}
case 48: case 48:
#line 436 "getdate.y" #line 443 "getdate.y"
{ {
if (yyHaveTime && yyHaveDate && !yyHaveRel) if (context->yyHaveTime && context->yyHaveDate &&
yyYear = yyvsp[0].Number; !context->yyHaveRel)
context->yyYear = yyvsp[0].Number;
else else
{ {
if (yyvsp[0].Number>10000) if (yyvsp[0].Number>10000)
{ {
yyHaveDate++; context->yyHaveDate++;
yyDay= (yyvsp[0].Number)%100; context->yyDay= (yyvsp[0].Number)%100;
yyMonth= (yyvsp[0].Number/100)%100; context->yyMonth= (yyvsp[0].Number/100)%100;
yyYear = yyvsp[0].Number/10000; context->yyYear = yyvsp[0].Number/10000;
} }
else else
{ {
yyHaveTime++; context->yyHaveTime++;
if (yyvsp[0].Number < 100) if (yyvsp[0].Number < 100)
{ {
yyHour = yyvsp[0].Number; context->yyHour = yyvsp[0].Number;
yyMinutes = 0; context->yyMinutes = 0;
} }
else else
{ {
yyHour = yyvsp[0].Number / 100; context->yyHour = yyvsp[0].Number / 100;
yyMinutes = yyvsp[0].Number % 100; context->yyMinutes = yyvsp[0].Number % 100;
} }
yySeconds = 0; context->yySeconds = 0;
yyMeridian = MER24; context->yyMeridian = MER24;
} }
} }
; ;
break;} break;}
case 49: case 49:
#line 469 "getdate.y" #line 477 "getdate.y"
{ {
yyval.Meridian = MER24; yyval.Meridian = MER24;
; ;
break;} break;}
case 50: case 50:
#line 473 "getdate.y" #line 481 "getdate.y"
{ {
yyval.Meridian = yyvsp[0].Meridian; yyval.Meridian = yyvsp[0].Meridian;
; ;
@ -1521,7 +1526,7 @@ yyerrhandle:
} }
return 1; return 1;
} }
#line 478 "getdate.y" #line 486 "getdate.y"
/* Include this file down here because bison inserts code above which /* Include this file down here because bison inserts code above which
@ -1777,7 +1782,8 @@ ToYear (Year)
} }
static int static int
LookupWord (buff) LookupWord (yylval, buff)
YYSTYPE *yylval;
char *buff; char *buff;
{ {
register char *p; register char *p;
@ -1793,12 +1799,12 @@ LookupWord (buff)
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0) if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
{ {
yylval.Meridian = MERam; yylval->Meridian = MERam;
return tMERIDIAN; return tMERIDIAN;
} }
if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0) if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
{ {
yylval.Meridian = MERpm; yylval->Meridian = MERpm;
return tMERIDIAN; return tMERIDIAN;
} }
@ -1819,13 +1825,13 @@ LookupWord (buff)
{ {
if (strncmp (buff, tp->name, 3) == 0) if (strncmp (buff, tp->name, 3) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
} }
else if (strcmp (buff, tp->name) == 0) else if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
} }
@ -1833,7 +1839,7 @@ LookupWord (buff)
for (tp = TimezoneTable; tp->name; tp++) for (tp = TimezoneTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
@ -1843,7 +1849,7 @@ LookupWord (buff)
for (tp = UnitsTable; tp->name; tp++) for (tp = UnitsTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
@ -1855,7 +1861,7 @@ LookupWord (buff)
for (tp = UnitsTable; tp->name; tp++) for (tp = UnitsTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
buff[i] = 's'; /* Put back for "this" in OtherTable. */ buff[i] = 's'; /* Put back for "this" in OtherTable. */
@ -1864,7 +1870,7 @@ LookupWord (buff)
for (tp = OtherTable; tp->name; tp++) for (tp = OtherTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
@ -1874,7 +1880,7 @@ LookupWord (buff)
for (tp = MilitaryTable; tp->name; tp++) for (tp = MilitaryTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
} }
@ -1890,7 +1896,7 @@ LookupWord (buff)
for (tp = TimezoneTable; tp->name; tp++) for (tp = TimezoneTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (strcmp (buff, tp->name) == 0)
{ {
yylval.Number = tp->value; yylval->Number = tp->value;
return tp->type; return tp->type;
} }
@ -1898,7 +1904,9 @@ LookupWord (buff)
} }
static int static int
yylex () yylex (yylval, cookie)
YYSTYPE *yylval;
void *cookie;
{ {
register unsigned char c; register unsigned char c;
register char *p; register char *p;
@ -1908,42 +1916,42 @@ yylex ()
for (;;) for (;;)
{ {
while (ISSPACE ((unsigned char) *yyInput)) while (ISSPACE ((unsigned char) *context->yyInput))
yyInput++; context->yyInput++;
if (ISDIGIT (c = *yyInput) || c == '-' || c == '+') if (ISDIGIT (c = *context->yyInput) || c == '-' || c == '+')
{ {
if (c == '-' || c == '+') if (c == '-' || c == '+')
{ {
sign = c == '-' ? -1 : 1; sign = c == '-' ? -1 : 1;
if (!ISDIGIT (*++yyInput)) if (!ISDIGIT (*++context->yyInput))
/* skip the '-' sign */ /* skip the '-' sign */
continue; continue;
} }
else else
sign = 0; sign = 0;
for (yylval.Number = 0; ISDIGIT (c = *yyInput++);) for (yylval->Number = 0; ISDIGIT (c = *context->yyInput++);)
yylval.Number = 10 * yylval.Number + c - '0'; yylval->Number = 10 * yylval->Number + c - '0';
yyInput--; context->yyInput--;
if (sign < 0) if (sign < 0)
yylval.Number = -yylval.Number; yylval->Number = -yylval->Number;
return sign ? tSNUMBER : tUNUMBER; return sign ? tSNUMBER : tUNUMBER;
} }
if (ISALPHA (c)) if (ISALPHA (c))
{ {
for (p = buff; (c = *yyInput++, ISALPHA (c)) || c == '.';) for (p = buff; (c = *context->yyInput++, ISALPHA (c)) || c == '.';)
if (p < &buff[sizeof buff - 1]) if (p < &buff[sizeof buff - 1])
*p++ = c; *p++ = c;
*p = '\0'; *p = '\0';
yyInput--; context->yyInput--;
return LookupWord (buff); return LookupWord (yylval, buff);
} }
if (c != '(') if (c != '(')
return *yyInput++; return *context->yyInput++;
Count = 0; Count = 0;
do do
{ {
c = *yyInput++; c = *context->yyInput++;
if (c == '\0') if (c == '\0')
return c; return c;
if (c == '(') if (c == '(')
@ -1983,10 +1991,11 @@ curl_getdate (const char *p, const time_t *now)
{ {
struct tm tm, tm0, *tmp; struct tm tm, tm0, *tmp;
time_t Start; time_t Start;
CONTEXT cookie;
#ifdef HAVE_LOCALTIME_R #ifdef HAVE_LOCALTIME_R
struct tm keeptime; struct tm keeptime;
#endif #endif
yyInput = p; cookie.yyInput = p;
Start = now ? *now : time ((time_t *) NULL); Start = now ? *now : time ((time_t *) NULL);
#ifdef HAVE_LOCALTIME_R #ifdef HAVE_LOCALTIME_R
tmp = (struct tm *)localtime_r(&Start, &keeptime); tmp = (struct tm *)localtime_r(&Start, &keeptime);
@ -1995,52 +2004,55 @@ curl_getdate (const char *p, const time_t *now)
#endif #endif
if (!tmp) if (!tmp)
return -1; return -1;
yyYear = tmp->tm_year + TM_YEAR_ORIGIN; cookie.yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
yyMonth = tmp->tm_mon + 1; cookie.yyMonth = tmp->tm_mon + 1;
yyDay = tmp->tm_mday; cookie.yyDay = tmp->tm_mday;
yyHour = tmp->tm_hour; cookie.yyHour = tmp->tm_hour;
yyMinutes = tmp->tm_min; cookie.yyMinutes = tmp->tm_min;
yySeconds = tmp->tm_sec; cookie.yySeconds = tmp->tm_sec;
tm.tm_isdst = tmp->tm_isdst; tm.tm_isdst = tmp->tm_isdst;
yyMeridian = MER24; cookie.yyMeridian = MER24;
yyRelSeconds = 0; cookie.yyRelSeconds = 0;
yyRelMinutes = 0; cookie.yyRelMinutes = 0;
yyRelHour = 0; cookie.yyRelHour = 0;
yyRelDay = 0; cookie.yyRelDay = 0;
yyRelMonth = 0; cookie.yyRelMonth = 0;
yyRelYear = 0; cookie.yyRelYear = 0;
yyHaveDate = 0; cookie.yyHaveDate = 0;
yyHaveDay = 0; cookie.yyHaveDay = 0;
yyHaveRel = 0; cookie.yyHaveRel = 0;
yyHaveTime = 0; cookie.yyHaveTime = 0;
yyHaveZone = 0; cookie.yyHaveZone = 0;
if (yyparse () if (yyparse (&cookie)
|| yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) || cookie.yyHaveTime > 1 || cookie.yyHaveZone > 1 ||
cookie.yyHaveDate > 1 || cookie.yyHaveDay > 1)
return -1; return -1;
tm.tm_year = ToYear (yyYear) - TM_YEAR_ORIGIN + yyRelYear; tm.tm_year = ToYear (cookie.yyYear) - TM_YEAR_ORIGIN + cookie.yyRelYear;
tm.tm_mon = yyMonth - 1 + yyRelMonth; tm.tm_mon = cookie.yyMonth - 1 + cookie.yyRelMonth;
tm.tm_mday = yyDay + yyRelDay; tm.tm_mday = cookie.yyDay + cookie.yyRelDay;
if (yyHaveTime || (yyHaveRel && !yyHaveDate && !yyHaveDay)) if (cookie.yyHaveTime ||
(cookie.yyHaveRel && !cookie.yyHaveDate && !cookie.yyHaveDay))
{ {
tm.tm_hour = ToHour (yyHour, yyMeridian); tm.tm_hour = ToHour (cookie.yyHour, cookie.yyMeridian);
if (tm.tm_hour < 0) if (tm.tm_hour < 0)
return -1; return -1;
tm.tm_min = yyMinutes; tm.tm_min = cookie.yyMinutes;
tm.tm_sec = yySeconds; tm.tm_sec = cookie.yySeconds;
} }
else else
{ {
tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
} }
tm.tm_hour += yyRelHour; tm.tm_hour += cookie.yyRelHour;
tm.tm_min += yyRelMinutes; tm.tm_min += cookie.yyRelMinutes;
tm.tm_sec += yyRelSeconds; tm.tm_sec += cookie.yyRelSeconds;
/* Let mktime deduce tm_isdst if we have an absolute timestamp, /* Let mktime deduce tm_isdst if we have an absolute timestamp,
or if the relative timestamp mentions days, months, or years. */ or if the relative timestamp mentions days, months, or years. */
if (yyHaveDate | yyHaveDay | yyHaveTime | yyRelDay | yyRelMonth | yyRelYear) if (cookie.yyHaveDate | cookie.yyHaveDay | cookie.yyHaveTime |
cookie.yyRelDay | cookie.yyRelMonth | cookie.yyRelYear)
tm.tm_isdst = -1; tm.tm_isdst = -1;
tm0 = tm; tm0 = tm;
@ -2058,18 +2070,18 @@ curl_getdate (const char *p, const time_t *now)
we apply mktime to 1970-01-02 08:00:00 instead and adjust the time we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
zone by 24 hours to compensate. This algorithm assumes that zone by 24 hours to compensate. This algorithm assumes that
there is no DST transition within a day of the time_t boundaries. */ there is no DST transition within a day of the time_t boundaries. */
if (yyHaveZone) if (cookie.yyHaveZone)
{ {
tm = tm0; tm = tm0;
if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN) if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
{ {
tm.tm_mday++; tm.tm_mday++;
yyTimezone -= 24 * 60; cookie.yyTimezone -= 24 * 60;
} }
else else
{ {
tm.tm_mday--; tm.tm_mday--;
yyTimezone += 24 * 60; cookie.yyTimezone += 24 * 60;
} }
Start = mktime (&tm); Start = mktime (&tm);
} }
@ -2078,22 +2090,22 @@ curl_getdate (const char *p, const time_t *now)
return Start; return Start;
} }
if (yyHaveDay && !yyHaveDate) if (cookie.yyHaveDay && !cookie.yyHaveDate)
{ {
tm.tm_mday += ((yyDayNumber - tm.tm_wday + 7) % 7 tm.tm_mday += ((cookie.yyDayNumber - tm.tm_wday + 7) % 7
+ 7 * (yyDayOrdinal - (0 < yyDayOrdinal))); + 7 * (cookie.yyDayOrdinal - (0 < cookie.yyDayOrdinal)));
Start = mktime (&tm); Start = mktime (&tm);
if (Start == (time_t) -1) if (Start == (time_t) -1)
return Start; return Start;
} }
if (yyHaveZone) if (cookie.yyHaveZone)
{ {
long delta; long delta;
struct tm *gmt = gmtime (&Start); struct tm *gmt = gmtime (&Start);
if (!gmt) if (!gmt)
return -1; return -1;
delta = yyTimezone * 60L + difftm (&tm, gmt); delta = cookie.yyTimezone * 60L + difftm (&tm, gmt);
if ((Start + delta < Start) != (delta < 0)) if ((Start + delta < Start) != (delta < 0))
return -1; /* time_t overflow */ return -1; /* time_t overflow */
Start += delta; Start += delta;