rh

Check-in [7d55a1618f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:y2k. TBD if those time_t calculations are still correct!
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:7d55a1618f83c6b4825e7362a6223f18299f561c46a01be6964ca7d88b384e42
User & Date: ajv-899-334-8894@vsta.org 2013-03-14 22:40:31
Context
2014-07-31
21:58
Fix up f*cked up time treatment; use system one check-in: c584edc078 user: ajv-899-334-8894@vsta.org tags: master, trunk
2013-03-14
22:40
y2k. TBD if those time_t calculations are still correct! check-in: 7d55a1618f user: ajv-899-334-8894@vsta.org tags: master, trunk
2012-01-10
00:03
Remove register decls. Use malloc space, not stack, for some temp bufs. Apply POSIX stat field size globally, so it's uniform across sources. check-in: 3fb96447e1 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to getdate.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18


19
20
21
22


23



24



25



26



27



28


29
30
31



32
33
34


35



36



37



38



39



40



41



42



43



44

45



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
81
82
83
84
85
86
87
88





























89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
...
207
208
209
210
211
212
213
214

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
253
254
255
256
257
258
259

260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
279
280
281
282
283
284
285









286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317

318

319
320
321
322
323
324
325
...
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
...
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
...
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
...
752
753
754
755
756
757
758
759








760
761
762

763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782

783
784
785
786
787
788
789
790

791
792
793
794
795











796
797
798
799

800
801

802
803
804
805
806
807
808
...
811
812
813
814
815
816
817

818




819
820
821


822

823
824
825
826
827
828
829
830
831
832
833
834
835
...
841
842
843
844
845
846
847
848
849
850
851
852

853
854
855
856
857
858
859
860
...
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893

894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
...
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
....
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166

1167
1168
1169

1170
1171
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
#endif

#include <stdlib.h>
#include <string.h>

#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYPATCH 20070509

#define YYEMPTY (-1)
#define yyclearin    (yychar = YYEMPTY)
#define yyerrok      (yyerrflag = 0)
#define YYRECOVERING (yyerrflag != 0)


extern int yyparse(void);



static int yygrowstack(void);
#define yyparse gd_parse
#define yylex gd_lex


#define yyerror gd_error



#define yychar gd_char



#define yyval gd_val



#define yylval gd_lval



#define yydebug gd_debug



#define yynerrs gd_nerrs


#define yyerrflag gd_errflag
#define yyss gd_ss
#define yyssp gd_ssp



#define yyvs gd_vs
#define yyvsp gd_vsp
#define yylhs gd_lhs


#define yylen gd_len



#define yydefred gd_defred



#define yydgoto gd_dgoto



#define yysindex gd_sindex



#define yyrindex gd_rindex



#define yygindex gd_gindex



#define yytable gd_table



#define yycheck gd_check



#define yyname gd_name



#define yyrule gd_rule

#define YYPREFIX "gd_"



#line 3 "getdate.y"
	/* getdate.y						*/
	/*							*/
	/* 	Steven M. Bellovin (unc!smb)			*/
	/*	Dept. of Computer Science			*/
	/*	University of North Carolina at Chapel Hill	*/
	/*	@(#)getdate.y	2.13	9/16/86			*/

#if !defined(lint)
static char rcsid[] = "$Id: getdate.c,v 1.1 2008/12/27 00:56:03 vandys Exp vandys $";
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
................................................................................
#define DAYLIGHT 1
#define STANDARD 2
#define MAYBE    3

static int gd_lex(), lookup();
static time_t timeconv(), daylcorr(), dateconv(), daylcorr();

#line 89 "y.tab.c"





























#define ID 257
#define MONTH 258
#define DAY 259
#define MERIDIAN 260
#define NUMBER 261
#define UNIT 262
#define MUNIT 263
#define SUNIT 264
#define ZONE 265
#define DAYZONE 266
#define AGO 267
#define YYERRCODE 256
short gd_lhs[] = {                                        -1,
    0,    0,    1,    1,    1,    1,    1,    1,    7,    2,
    2,    2,    2,    2,    2,    2,    3,    3,    5,    5,
    5,    4,    4,    4,    4,    4,    4,    6,    6,    6,
    6,    6,    6,    6,
};
short gd_len[] = {                                         2,
    0,    2,    1,    1,    1,    1,    1,    1,    1,    2,
    3,    4,    4,    5,    6,    6,    1,    1,    1,    2,
    2,    3,    5,    2,    4,    2,    3,    2,    2,    2,
    1,    1,    1,    2,
};
short gd_defred[] = {                                      1,
    0,    0,    0,    0,   31,   32,   33,   17,   18,    2,
    3,    4,    5,    6,    0,    8,    0,   20,    0,   21,
   10,   28,   29,   30,    0,    0,   34,    0,   27,    0,
    0,   25,   12,   13,    0,    0,    0,   23,   15,   16,
};
short gd_dgoto[] = {                                       1,
   10,   11,   12,   13,   14,   15,   16,
};
short gd_sindex[] = {                                      0,
 -241, -256,  -38,  -47,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0, -260,    0,  -36,    0, -252,    0,
    0,    0,    0,    0, -249, -248,    0, -247,    0,  -56,
  -32,    0,    0,    0, -245, -235, -257,    0,    0,    0,
};
short gd_rindex[] = {                                      0,
    0,    0,    1,   61,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,   10,    0,   19,    0,   37,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   46,
   28,    0,    0,    0,    0,    0,   55,    0,    0,    0,
};
short gd_gindex[] = {                                      0,
    0,    0,    0,    0,    0,    0,    0,
};
#define YYTABLESIZE 327
short gd_table[] = {                                      26,
   19,   35,   39,   40,   17,   18,   27,   28,   29,    7,
   25,   30,   31,   32,   36,   37,    2,    3,   24,    4,
    5,    6,    7,    8,    9,   38,    0,   22,    0,    0,
    0,    0,    0,    0,    0,    0,   26,    0,    0,    0,
    0,    0,    0,    0,    0,   11,    0,    0,    0,    0,
    0,    0,    0,    0,   14,    0,    0,    0,    0,    0,
    9,    0,    0,    0,    0,    0,    0,    0,    0,    0,
................................................................................
    7,    7,    7,    7,    7,    7,   24,   24,    0,   24,
   24,   24,   24,   24,   24,   22,   22,    0,   22,   22,
   22,   22,   22,   22,   26,   26,    0,    0,   26,   26,
   26,   26,   26,   11,   11,    0,    0,   11,   11,   11,
   11,   11,   14,   14,    0,    0,   14,   14,   14,   14,
   14,    9,    0,    0,    0,    9,    9,
};
short gd_check[] = {                                      47,
    0,   58,  260,  261,  261,   44,  267,   44,  261,    0,
   58,  261,  261,  261,   47,  261,  258,  259,    0,  261,
  262,  263,  264,  265,  266,  261,   -1,    0,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,
    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
................................................................................
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 1
#endif
#define YYMAXTOKEN 267
#if YYDEBUG
char *gd_name[] = {

"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,"','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"ID","MONTH","DAY",
"MERIDIAN","NUMBER","UNIT","MUNIT","SUNIT","ZONE","DAYZONE","AGO",
};
char *gd_rule[] = {
"$accept : timedate",
"timedate :",
"timedate : timedate item",
"item : tspec",
"item : zone",
"item : dtspec",
"item : dyspec",
................................................................................
"rspec : NUMBER UNIT",
"rspec : NUMBER MUNIT",
"rspec : NUMBER SUNIT",
"rspec : UNIT",
"rspec : MUNIT",
"rspec : SUNIT",
"rspec : rspec AGO",

};
#endif
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
#if YYDEBUG
#include <stdio.h>
#endif

/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH  YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
................................................................................
#endif
#endif

#define YYINITSTACKSIZE 500

int      yydebug;
int      yynerrs;









int      yyerrflag;
int      yychar;
short   *yyssp;
YYSTYPE *yyvsp;
YYSTYPE  yyval;
YYSTYPE  yylval;

/* variables for the parser stack */
static short   *yyss;
static short   *yysslim;
static YYSTYPE *yyvs;
static int      yystacksize;
#line 138 "getdate.y"

static int mdays[12] =
	{31, 0, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31};
#define epoch 1970

extern struct tm *localtime();

static time_t
dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
int mm, dd, yy, h, m, s, mer, zone, dayflag;
{
	time_t tod, jdate;
	int i;

	if (yy < 0) yy = -yy;
	if (yy < 100) yy += 1900;
	mdays[1] =
	    28 + ((yy % 4 == 0 && (yy % 100 != 0 || yy % 400 == 0)) ? 1 : 0);
	if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 ||

		dd < 1 || dd > mdays[--mm]) return (-1);

	jdate = dd-1;
        for (i=0; i<mm; i++) jdate += mdays[i];
	for (i = epoch; i < yy; i++) {
	    jdate += 365 + ((i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) ? 1 : 0);
	}
	jdate *= daysec;
	jdate += zone * 60L;
................................................................................
	return (jdate);
}

static time_t
dayconv(ord, day, now)
int ord, day; time_t now;
{
	struct tm *loctime;
	time_t tod;

	tod = now;
	loctime = localtime(&tod);
	tod += daysec * ((day - loctime->tm_wday + 7) % 7);
	tod += 7 * daysec * ((ord <= 0) ? ord : (ord - 1));
	return daylcorr(tod, now);
}

static time_t
timeconv(hh, mm, ss, mer)
int hh, mm, ss, mer;
{
	if (mm < 0 || mm > 59 || ss < 0 || ss > 59) return (-1);
	switch (mer) {
		case AM: if (hh < 1 || hh > 12) return(-1);
			 return (60L * ((hh%12)*60L + mm)+ss);
		case PM: if (hh < 1 || hh > 12) return(-1);
			 return (60L * ((hh%12 +12)*60L + mm)+ss);
................................................................................

static char *lptr;

static int gd_lex()
{
	extern int gd_lval;
	int sign;
	char c;
	char *p;
	char idbuf[20];
	int pcnt;

	for (;;) {
		while (isspace(*lptr)) lptr++;

		if (isdigit(c = *lptr) || c == '-' || c == '+') {
................................................................................
static int lookup(id)
char *id;
{
#define gotit (gd_lval = i->value , i->type)
#define getid for(j = idvar, k = id; (*j++ = *k++) != '\0'; /* void */)

	char idvar[20];
	char *j, *k;
	struct table *i;
	int abbrev;

	getid;
	if (strlen(idvar) == 3) {
	    abbrev = 1;
	}
	else if (strlen(idvar) == 4 && idvar[3] == '.') {
................................................................................
}

/*ARGSUSED*/
void gd_error(char *s)
{
    return;
}
#line 760 "y.tab.c"








/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(void)
{

    int newsize, i;
    short *newss;
    YYSTYPE *newvs;

    if ((newsize = yystacksize) == 0)
        newsize = YYINITSTACKSIZE;
    else if (newsize >= YYMAXDEPTH)
        return -1;
    else if ((newsize *= 2) > YYMAXDEPTH)
        newsize = YYMAXDEPTH;

    i = yyssp - yyss;
    newss = (yyss != 0)
          ? (short *)realloc(yyss, newsize * sizeof(*newss))
          : (short *)malloc(newsize * sizeof(*newss));
    if (newss == 0)
        return -1;

    yyss  = newss;
    yyssp = newss + i;

    newvs = (yyvs != 0)
          ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs))
          : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
    if (newvs == 0)
        return -1;

    yyvs = newvs;
    yyvsp = newvs + i;

    yystacksize = newsize;
    yysslim = yyss + newsize - 1;
    return 0;
}












#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab

int
yyparse(void)

{
    int yym, yyn, yystate;
#if YYDEBUG
    const char *yys;

    if ((yys = getenv("YYDEBUG")) != 0)
    {
................................................................................
            yydebug = yyn - '0';
    }
#endif

    yynerrs = 0;
    yyerrflag = 0;
    yychar = YYEMPTY;






    if (yyss == NULL && yygrowstack()) goto yyoverflow;
    yyssp = yyss;
    yyvsp = yyvs;


    *yyssp = yystate = 0;


yyloop:
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    if (yychar < 0)
    {
        if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
        if (yydebug)
        {
            yys = 0;
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
            if (!yys) yys = "illegal-symbol";
            printf("%sdebug: state %d, reading %d (%s)\n",
................................................................................
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: state %d, shifting to state %d\n",
                    YYPREFIX, yystate, yytable[yyn]);
#endif
        if (yyssp >= yysslim && yygrowstack())
        {
            goto yyoverflow;
        }
        *++yyssp = yystate = yytable[yyn];

        *++yyvsp = yylval;
        yychar = YYEMPTY;
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
................................................................................
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag) goto yyinrecovery;

    yyerror("syntax error");

#ifdef lint
    goto yyerrlab;
#endif

yyerrlab:
    ++yynerrs;

yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: state %d, error recovery shifting\
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
#endif
                if (yyssp >= yysslim && yygrowstack())
                {
                    goto yyoverflow;
                }
                *++yyssp = yystate = yytable[yyn];

                *++yyvsp = yylval;
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: error recovery discarding state %d\n",
                            YYPREFIX, *yyssp);
#endif
                if (yyssp <= yyss) goto yyabort;
                --yyssp;
                --yyvsp;
            }
        }
    }
    else
    {
        if (yychar == 0) goto yyabort;
#if YYDEBUG
................................................................................
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
                YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
    yym = yylen[yyn];
    if (yym)
        yyval = yyvsp[1-yym];
    else
        memset(&yyval, 0, sizeof yyval);
    switch (yyn)
    {
case 3:
#line 50 "getdate.y"

................................................................................
#line 58 "getdate.y"

		{relflag++;}
break;
case 9:
#line 62 "getdate.y"

		{if (timeflag && dateflag && !relflag) year = yyvsp[0];
		else {timeflag++;hh = yyvsp[0]/100;mm = yyvsp[0]%100;ss = 0;merid = 24;}}
break;
case 10:
#line 66 "getdate.y"

		{hh = yyvsp[-1]; mm = 0; ss = 0; merid = yyvsp[0];}
break;
case 11:
#line 68 "getdate.y"

		{hh = yyvsp[-2]; mm = yyvsp[0]; merid = 24;}
break;
case 12:
#line 70 "getdate.y"

		{hh = yyvsp[-3]; mm = yyvsp[-1]; merid = yyvsp[0];}
break;
case 13:
#line 72 "getdate.y"

		{hh = yyvsp[-3]; mm = yyvsp[-1]; merid = 24;
		dylight = STANDARD; ourzone = yyvsp[0]%100 + 60*yyvsp[0]/100;}
break;
case 14:
#line 75 "getdate.y"

		{hh = yyvsp[-4]; mm = yyvsp[-2]; ss = yyvsp[0]; merid = 24;}
break;
case 15:
#line 77 "getdate.y"

		{hh = yyvsp[-5]; mm = yyvsp[-3]; ss = yyvsp[-1]; merid = yyvsp[0];}
break;
case 16:
#line 79 "getdate.y"

		{hh = yyvsp[-5]; mm = yyvsp[-3]; ss = yyvsp[-1]; merid = 24;
		dylight = STANDARD; ourzone = yyvsp[0]%100 + 60*yyvsp[0]/100;}
break;
case 17:
#line 83 "getdate.y"

		{ourzone = yyvsp[0]; dylight = STANDARD;}
break;
case 18:
#line 85 "getdate.y"

		{ourzone = yyvsp[0]; dylight = DAYLIGHT;}
break;
case 19:
#line 88 "getdate.y"

		{dayord = 1; dayreq = yyvsp[0];}
break;
case 20:
#line 90 "getdate.y"

		{dayord = 1; dayreq = yyvsp[-1];}
break;
case 21:
#line 92 "getdate.y"

		{dayord = yyvsp[-1]; dayreq = yyvsp[0];}
break;
case 22:
#line 95 "getdate.y"

		{month = yyvsp[-2]; day = yyvsp[0];}
break;
case 23:
#line 97 "getdate.y"

		{
		    /*
		     * HACK ALERT!!!!
		     * The 1000 is a magic number to attempt to force
		     * use of 4 digit years if year/month/day can be
		     * parsed. This was only done for backwards
		     * compatibility in rh.
		     */
		    if (yyvsp[-4] > 1000) {
			year = yyvsp[-4]; month = yyvsp[-2]; day = yyvsp[0];
		    }
		    else {
			month = yyvsp[-4]; day = yyvsp[-2]; year = yyvsp[0];
		    }
		}
break;
case 24:
#line 113 "getdate.y"

		{month = yyvsp[-1]; day = yyvsp[0];}
break;
case 25:
#line 115 "getdate.y"

		{month = yyvsp[-3]; day = yyvsp[-2]; year = yyvsp[0];}
break;
case 26:
#line 117 "getdate.y"

		{month = yyvsp[0]; day = yyvsp[-1];}
break;
case 27:
#line 119 "getdate.y"

		{month = yyvsp[-1]; day = yyvsp[-2]; year = yyvsp[0];}
break;
case 28:
#line 123 "getdate.y"

		{relsec +=  60L * yyvsp[-1] * yyvsp[0];}
break;
case 29:
#line 125 "getdate.y"

		{relmonth += yyvsp[-1] * yyvsp[0];}
break;
case 30:
#line 127 "getdate.y"

		{relsec += yyvsp[-1];}
break;
case 31:
#line 129 "getdate.y"

		{relsec +=  60L * yyvsp[0];}
break;
case 32:
#line 131 "getdate.y"

		{relmonth += yyvsp[0];}
break;
case 33:
#line 133 "getdate.y"

		{relsec++;}
break;
case 34:
#line 135 "getdate.y"

		{relsec = -relsec; relmonth = -relmonth;}
break;
#line 1113 "y.tab.c"
    }
    yyssp -= yym;
    yystate = *yyssp;
    yyvsp -= yym;
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: after reduction, shifting from state 0 to\
 state %d\n", YYPREFIX, YYFINAL);
#endif
        yystate = YYFINAL;
        *++yyssp = YYFINAL;
        *++yyvsp = yyval;
        if (yychar < 0)
        {
            if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
            if (yydebug)
            {
                yys = 0;
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
                if (!yys) yys = "illegal-symbol";
                printf("%sdebug: state %d, reading %d (%s)\n",
................................................................................
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate);
#endif
    if (yyssp >= yysslim && yygrowstack())
    {
        goto yyoverflow;
    }
    *++yyssp = yystate;
    *++yyvsp = yyval;
    goto yyloop;

yyoverflow:
    yyerror("yacc stack overflow");

yyabort:

    return (1);

yyaccept:

    return (0);
}




<
<
<



|

|
|
|
|

>
|
>
>

|
|
|
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
|
|
<
>
>
>
|
<
|
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>

>
>
>









|







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>












|





|





|





|


|





|





|



|







 







|







 







|
>









|







 







>


<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>


<
<




<
<
|
<













|


|


|
>
|
>







 







|











|







 







|
|







 







|
|







 







|
>
>
>
>
>
>
>
>

|

>
|



|






|
|
|




|
|
>
|
|




|
|
>
|
|



>
>
>
>
>
>
>
>
>
>
>
|


|
>

<
>







 







>

>
>
>
>
|
<
<
>
>
|
>





|







 







|



|
>
|







 







<

<










|





|

|



|
>
|







|

|
|
|







 







|







 







|
|




|




|




|




|
|




|




|




|
|




|




|




|




|




|




|












|
|


|






|




|




|




|




|




|




|




|




|











|

|
|
|









|
|


|







 







|

|



|
|






>



>


1
2
3
4



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

50
51
52
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
...
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
336
337
338
339
340
341
342
343
344
345







346
347
348
349
350
351
352
...
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373


374
375
376
377


378

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
...
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
...
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
...
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906

907
908
909
910
911
912
913
914
...
917
918
919
920
921
922
923
924
925
926
927
928
929
930


931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
...
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
...
974
975
976
977
978
979
980

981

982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
....
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
....
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
....
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
#endif




#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYPATCH 20100610

#define YYEMPTY        (-1)
#define yyclearin      (yychar = YYEMPTY)
#define yyerrok        (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)


#ifndef yyparse
#define yyparse    gd_parse
#endif /* yyparse */

#ifndef yylex
#define yylex      gd_lex
#endif /* yylex */

#ifndef yyerror
#define yyerror    gd_error
#endif /* yyerror */

#ifndef yychar
#define yychar     gd_char
#endif /* yychar */

#ifndef yyval
#define yyval      gd_val
#endif /* yyval */

#ifndef yylval
#define yylval     gd_lval
#endif /* yylval */

#ifndef yydebug
#define yydebug    gd_debug
#endif /* yydebug */

#ifndef yynerrs
#define yynerrs    gd_nerrs
#endif /* yynerrs */

#ifndef yyerrflag
#define yyerrflag  gd_errflag

#endif /* yyerrflag */

#ifndef yylhs
#define yylhs      gd_lhs

#endif /* yylhs */

#ifndef yylen
#define yylen      gd_len
#endif /* yylen */

#ifndef yydefred
#define yydefred   gd_defred
#endif /* yydefred */

#ifndef yydgoto
#define yydgoto    gd_dgoto
#endif /* yydgoto */

#ifndef yysindex
#define yysindex   gd_sindex
#endif /* yysindex */

#ifndef yyrindex
#define yyrindex   gd_rindex
#endif /* yyrindex */

#ifndef yygindex
#define yygindex   gd_gindex
#endif /* yygindex */

#ifndef yytable
#define yytable    gd_table
#endif /* yytable */

#ifndef yycheck
#define yycheck    gd_check
#endif /* yycheck */

#ifndef yyname
#define yyname     gd_name
#endif /* yyname */

#ifndef yyrule
#define yyrule     gd_rule
#endif /* yyrule */
#define YYPREFIX "gd_"

#define YYPURE 0

#line 3 "getdate.y"
	/* getdate.y						*/
	/*							*/
	/* 	Steven M. Bellovin (unc!smb)			*/
	/*	Dept. of Computer Science			*/
	/*	University of North Carolina at Chapel Hill	*/
	/*	@(#)getdate.y	2.13	9/16/86			*/

#if !defined(lint)
static char rcsid[] = "$Id: getdate.y,v 1.1 2008/12/27 00:56:03 vandys Exp vandys $";
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
................................................................................
#define DAYLIGHT 1
#define STANDARD 2
#define MAYBE    3

static int gd_lex(), lookup();
static time_t timeconv(), daylcorr(), dateconv(), daylcorr();

#line 141 "y.tab.c"

#ifndef YYSTYPE
typedef int YYSTYPE;
#endif

/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif

/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif

extern int YYPARSE_DECL();
extern int YYLEX_DECL();

#define ID 257
#define MONTH 258
#define DAY 259
#define MERIDIAN 260
#define NUMBER 261
#define UNIT 262
#define MUNIT 263
#define SUNIT 264
#define ZONE 265
#define DAYZONE 266
#define AGO 267
#define YYERRCODE 256
static const short gd_lhs[] = {                          -1,
    0,    0,    1,    1,    1,    1,    1,    1,    7,    2,
    2,    2,    2,    2,    2,    2,    3,    3,    5,    5,
    5,    4,    4,    4,    4,    4,    4,    6,    6,    6,
    6,    6,    6,    6,
};
static const short gd_len[] = {                           2,
    0,    2,    1,    1,    1,    1,    1,    1,    1,    2,
    3,    4,    4,    5,    6,    6,    1,    1,    1,    2,
    2,    3,    5,    2,    4,    2,    3,    2,    2,    2,
    1,    1,    1,    2,
};
static const short gd_defred[] = {                        1,
    0,    0,    0,    0,   31,   32,   33,   17,   18,    2,
    3,    4,    5,    6,    0,    8,    0,   20,    0,   21,
   10,   28,   29,   30,    0,    0,   34,    0,   27,    0,
    0,   25,   12,   13,    0,    0,    0,   23,   15,   16,
};
static const short gd_dgoto[] = {                         1,
   10,   11,   12,   13,   14,   15,   16,
};
static const short gd_sindex[] = {                        0,
 -241, -256,  -38,  -47,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0, -260,    0,  -36,    0, -252,    0,
    0,    0,    0,    0, -249, -248,    0, -247,    0,  -56,
  -32,    0,    0,    0, -245, -235, -257,    0,    0,    0,
};
static const short gd_rindex[] = {                        0,
    0,    0,    1,   61,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,   10,    0,   19,    0,   37,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   46,
   28,    0,    0,    0,    0,    0,   55,    0,    0,    0,
};
static const short gd_gindex[] = {                        0,
    0,    0,    0,    0,    0,    0,    0,
};
#define YYTABLESIZE 327
static const short gd_table[] = {                        26,
   19,   35,   39,   40,   17,   18,   27,   28,   29,    7,
   25,   30,   31,   32,   36,   37,    2,    3,   24,    4,
    5,    6,    7,    8,    9,   38,    0,   22,    0,    0,
    0,    0,    0,    0,    0,    0,   26,    0,    0,    0,
    0,    0,    0,    0,    0,   11,    0,    0,    0,    0,
    0,    0,    0,    0,   14,    0,    0,    0,    0,    0,
    9,    0,    0,    0,    0,    0,    0,    0,    0,    0,
................................................................................
    7,    7,    7,    7,    7,    7,   24,   24,    0,   24,
   24,   24,   24,   24,   24,   22,   22,    0,   22,   22,
   22,   22,   22,   22,   26,   26,    0,    0,   26,   26,
   26,   26,   26,   11,   11,    0,    0,   11,   11,   11,
   11,   11,   14,   14,    0,    0,   14,   14,   14,   14,
   14,    9,    0,    0,    0,    9,    9,
};
static const short gd_check[] = {                        47,
    0,   58,  260,  261,  261,   44,  267,   44,  261,    0,
   58,  261,  261,  261,   47,  261,  258,  259,    0,  261,
  262,  263,  264,  265,  266,  261,   -1,    0,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,
    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
................................................................................
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 1
#endif
#define YYMAXTOKEN 267
#if YYDEBUG
static const char *yyname[] = {

"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,"','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"ID","MONTH","DAY",
"MERIDIAN","NUMBER","UNIT","MUNIT","SUNIT","ZONE","DAYZONE","AGO",
};
static const char *yyrule[] = {
"$accept : timedate",
"timedate :",
"timedate : timedate item",
"item : tspec",
"item : zone",
"item : dtspec",
"item : dyspec",
................................................................................
"rspec : NUMBER UNIT",
"rspec : NUMBER MUNIT",
"rspec : NUMBER SUNIT",
"rspec : UNIT",
"rspec : MUNIT",
"rspec : SUNIT",
"rspec : rspec AGO",

};
#endif







/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH  YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
................................................................................
#endif
#endif

#define YYINITSTACKSIZE 500

int      yydebug;
int      yynerrs;

typedef struct {
    unsigned stacksize;
    short    *s_base;
    short    *s_mark;
    short    *s_last;
    YYSTYPE  *l_base;
    YYSTYPE  *l_mark;
} YYSTACKDATA;
int      yyerrflag;
int      yychar;


YYSTYPE  yyval;
YYSTYPE  yylval;

/* variables for the parser stack */


static YYSTACKDATA yystack;

#line 138 "getdate.y"

static int mdays[12] =
	{31, 0, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31};
#define epoch 1970

extern struct tm *localtime();

static time_t
dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
int mm, dd, yy, h, m, s, mer, zone, dayflag;
{
	time_t tod, jdate;
	register int i;

	if (yy < 0) yy = -yy;
	if (yy < 200) yy += 1900;
	mdays[1] =
	    28 + ((yy % 4 == 0 && (yy % 100 != 0 || yy % 400 == 0)) ? 1 : 0);
	if ((yy < epoch) || (yy > 2099) || (mm < 1) || (mm > 12) ||
		(dd < 1) || (dd > mdays[--mm])) {
	    return (-1);
	}
	jdate = dd-1;
        for (i=0; i<mm; i++) jdate += mdays[i];
	for (i = epoch; i < yy; i++) {
	    jdate += 365 + ((i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) ? 1 : 0);
	}
	jdate *= daysec;
	jdate += zone * 60L;
................................................................................
	return (jdate);
}

static time_t
dayconv(ord, day, now)
int ord, day; time_t now;
{
	register struct tm *loctime;
	time_t tod;

	tod = now;
	loctime = localtime(&tod);
	tod += daysec * ((day - loctime->tm_wday + 7) % 7);
	tod += 7 * daysec * ((ord <= 0) ? ord : (ord - 1));
	return daylcorr(tod, now);
}

static time_t
timeconv(hh, mm, ss, mer)
register int hh, mm, ss, mer;
{
	if (mm < 0 || mm > 59 || ss < 0 || ss > 59) return (-1);
	switch (mer) {
		case AM: if (hh < 1 || hh > 12) return(-1);
			 return (60L * ((hh%12)*60L + mm)+ss);
		case PM: if (hh < 1 || hh > 12) return(-1);
			 return (60L * ((hh%12 +12)*60L + mm)+ss);
................................................................................

static char *lptr;

static int gd_lex()
{
	extern int gd_lval;
	int sign;
	register char c;
	register char *p;
	char idbuf[20];
	int pcnt;

	for (;;) {
		while (isspace(*lptr)) lptr++;

		if (isdigit(c = *lptr) || c == '-' || c == '+') {
................................................................................
static int lookup(id)
char *id;
{
#define gotit (gd_lval = i->value , i->type)
#define getid for(j = idvar, k = id; (*j++ = *k++) != '\0'; /* void */)

	char idvar[20];
	register char *j, *k;
	register struct table *i;
	int abbrev;

	getid;
	if (strlen(idvar) == 3) {
	    abbrev = 1;
	}
	else if (strlen(idvar) == 4 && idvar[3] == '.') {
................................................................................
}

/*ARGSUSED*/
void gd_error(char *s)
{
    return;
}
#line 842 "y.tab.c"

#if YYDEBUG
#include <stdio.h>		/* needed for printf */
#endif

#include <stdlib.h>	/* needed for malloc, etc */
#include <string.h>	/* needed for memset */

/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
    int i;
    unsigned newsize;
    short *newss;
    YYSTYPE *newvs;

    if ((newsize = data->stacksize) == 0)
        newsize = YYINITSTACKSIZE;
    else if (newsize >= YYMAXDEPTH)
        return -1;
    else if ((newsize *= 2) > YYMAXDEPTH)
        newsize = YYMAXDEPTH;

    i = data->s_mark - data->s_base;
    newss = (data->s_base != 0)
          ? (short *)realloc(data->s_base, newsize * sizeof(*newss))
          : (short *)malloc(newsize * sizeof(*newss));
    if (newss == 0)
        return -1;

    data->s_base = newss;
    data->s_mark = newss + i;

    newvs = (data->l_base != 0)
          ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs))
          : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
    if (newvs == 0)
        return -1;

    data->l_base = newvs;
    data->l_mark = newvs + i;

    data->stacksize = newsize;
    data->s_last = data->s_base + newsize - 1;
    return 0;
}

#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
    free(data->s_base);
    free(data->l_base);
    memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif

#define YYABORT  goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR  goto yyerrlab

int

YYPARSE_DECL()
{
    int yym, yyn, yystate;
#if YYDEBUG
    const char *yys;

    if ((yys = getenv("YYDEBUG")) != 0)
    {
................................................................................
            yydebug = yyn - '0';
    }
#endif

    yynerrs = 0;
    yyerrflag = 0;
    yychar = YYEMPTY;
    yystate = 0;

#if YYPURE
    memset(&yystack, 0, sizeof(yystack));
#endif

    if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;


    yystack.s_mark = yystack.s_base;
    yystack.l_mark = yystack.l_base;
    yystate = 0;
    *yystack.s_mark = 0;

yyloop:
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    if (yychar < 0)
    {
        if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
        if (yydebug)
        {
            yys = 0;
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
            if (!yys) yys = "illegal-symbol";
            printf("%sdebug: state %d, reading %d (%s)\n",
................................................................................
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: state %d, shifting to state %d\n",
                    YYPREFIX, yystate, yytable[yyn]);
#endif
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
        {
            goto yyoverflow;
        }
        yystate = yytable[yyn];
        *++yystack.s_mark = yytable[yyn];
        *++yystack.l_mark = yylval;
        yychar = YYEMPTY;
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
................................................................................
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag) goto yyinrecovery;

    yyerror("syntax error");


    goto yyerrlab;


yyerrlab:
    ++yynerrs;

yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: state %d, error recovery shifting\
 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
                {
                    goto yyoverflow;
                }
                yystate = yytable[yyn];
                *++yystack.s_mark = yytable[yyn];
                *++yystack.l_mark = yylval;
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: error recovery discarding state %d\n",
                            YYPREFIX, *yystack.s_mark);
#endif
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
                --yystack.s_mark;
                --yystack.l_mark;
            }
        }
    }
    else
    {
        if (yychar == 0) goto yyabort;
#if YYDEBUG
................................................................................
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
                YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
    yym = yylen[yyn];
    if (yym)
        yyval = yystack.l_mark[1-yym];
    else
        memset(&yyval, 0, sizeof yyval);
    switch (yyn)
    {
case 3:
#line 50 "getdate.y"

................................................................................
#line 58 "getdate.y"

		{relflag++;}
break;
case 9:
#line 62 "getdate.y"

		{if (timeflag && dateflag && !relflag) year = yystack.l_mark[0];
		else {timeflag++;hh = yystack.l_mark[0]/100;mm = yystack.l_mark[0]%100;ss = 0;merid = 24;}}
break;
case 10:
#line 66 "getdate.y"

		{hh = yystack.l_mark[-1]; mm = 0; ss = 0; merid = yystack.l_mark[0];}
break;
case 11:
#line 68 "getdate.y"

		{hh = yystack.l_mark[-2]; mm = yystack.l_mark[0]; merid = 24;}
break;
case 12:
#line 70 "getdate.y"

		{hh = yystack.l_mark[-3]; mm = yystack.l_mark[-1]; merid = yystack.l_mark[0];}
break;
case 13:
#line 72 "getdate.y"

		{hh = yystack.l_mark[-3]; mm = yystack.l_mark[-1]; merid = 24;
		dylight = STANDARD; ourzone = yystack.l_mark[0]%100 + 60*yystack.l_mark[0]/100;}
break;
case 14:
#line 75 "getdate.y"

		{hh = yystack.l_mark[-4]; mm = yystack.l_mark[-2]; ss = yystack.l_mark[0]; merid = 24;}
break;
case 15:
#line 77 "getdate.y"

		{hh = yystack.l_mark[-5]; mm = yystack.l_mark[-3]; ss = yystack.l_mark[-1]; merid = yystack.l_mark[0];}
break;
case 16:
#line 79 "getdate.y"

		{hh = yystack.l_mark[-5]; mm = yystack.l_mark[-3]; ss = yystack.l_mark[-1]; merid = 24;
		dylight = STANDARD; ourzone = yystack.l_mark[0]%100 + 60*yystack.l_mark[0]/100;}
break;
case 17:
#line 83 "getdate.y"

		{ourzone = yystack.l_mark[0]; dylight = STANDARD;}
break;
case 18:
#line 85 "getdate.y"

		{ourzone = yystack.l_mark[0]; dylight = DAYLIGHT;}
break;
case 19:
#line 88 "getdate.y"

		{dayord = 1; dayreq = yystack.l_mark[0];}
break;
case 20:
#line 90 "getdate.y"

		{dayord = 1; dayreq = yystack.l_mark[-1];}
break;
case 21:
#line 92 "getdate.y"

		{dayord = yystack.l_mark[-1]; dayreq = yystack.l_mark[0];}
break;
case 22:
#line 95 "getdate.y"

		{month = yystack.l_mark[-2]; day = yystack.l_mark[0];}
break;
case 23:
#line 97 "getdate.y"

		{
		    /*
		     * HACK ALERT!!!!
		     * The 1000 is a magic number to attempt to force
		     * use of 4 digit years if year/month/day can be
		     * parsed. This was only done for backwards
		     * compatibility in rh.
		     */
		    if (yystack.l_mark[-4] > 1000) {
			year = yystack.l_mark[-4]; month = yystack.l_mark[-2]; day = yystack.l_mark[0];
		    }
		    else {
			month = yystack.l_mark[-4]; day = yystack.l_mark[-2]; year = yystack.l_mark[0];
		    }
		}
break;
case 24:
#line 113 "getdate.y"

		{month = yystack.l_mark[-1]; day = yystack.l_mark[0];}
break;
case 25:
#line 115 "getdate.y"

		{month = yystack.l_mark[-3]; day = yystack.l_mark[-2]; year = yystack.l_mark[0];}
break;
case 26:
#line 117 "getdate.y"

		{month = yystack.l_mark[0]; day = yystack.l_mark[-1];}
break;
case 27:
#line 119 "getdate.y"

		{month = yystack.l_mark[-1]; day = yystack.l_mark[-2]; year = yystack.l_mark[0];}
break;
case 28:
#line 123 "getdate.y"

		{relsec +=  60L * yystack.l_mark[-1] * yystack.l_mark[0];}
break;
case 29:
#line 125 "getdate.y"

		{relmonth += yystack.l_mark[-1] * yystack.l_mark[0];}
break;
case 30:
#line 127 "getdate.y"

		{relsec += yystack.l_mark[-1];}
break;
case 31:
#line 129 "getdate.y"

		{relsec +=  60L * yystack.l_mark[0];}
break;
case 32:
#line 131 "getdate.y"

		{relmonth += yystack.l_mark[0];}
break;
case 33:
#line 133 "getdate.y"

		{relsec++;}
break;
case 34:
#line 135 "getdate.y"

		{relsec = -relsec; relmonth = -relmonth;}
break;
#line 1224 "y.tab.c"
    }
    yystack.s_mark -= yym;
    yystate = *yystack.s_mark;
    yystack.l_mark -= yym;
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: after reduction, shifting from state 0 to\
 state %d\n", YYPREFIX, YYFINAL);
#endif
        yystate = YYFINAL;
        *++yystack.s_mark = YYFINAL;
        *++yystack.l_mark = yyval;
        if (yychar < 0)
        {
            if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
            if (yydebug)
            {
                yys = 0;
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
                if (!yys) yys = "illegal-symbol";
                printf("%sdebug: state %d, reading %d (%s)\n",
................................................................................
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
    {
        goto yyoverflow;
    }
    *++yystack.s_mark = (short) yystate;
    *++yystack.l_mark = yyval;
    goto yyloop;

yyoverflow:
    yyerror("yacc stack overflow");

yyabort:
    yyfreestack(&yystack);
    return (1);

yyaccept:
    yyfreestack(&yystack);
    return (0);
}

Changes to getdate.y.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
146
147
148
149
150
151
152
153
154
155
156

157

158
159
160
161
162
163
164
	/*							*/
	/* 	Steven M. Bellovin (unc!smb)			*/
	/*	Dept. of Computer Science			*/
	/*	University of North Carolina at Chapel Hill	*/
	/*	@(#)getdate.y	2.13	9/16/86			*/

#if !defined(lint)
static char rcsid[] = "$Id: getdate.y,v 1.1 1994/01/12 19:35:54 rick Exp $";
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
................................................................................
dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
int mm, dd, yy, h, m, s, mer, zone, dayflag;
{
	time_t tod, jdate;
	register int i;

	if (yy < 0) yy = -yy;
	if (yy < 100) yy += 1900;
	mdays[1] =
	    28 + ((yy % 4 == 0 && (yy % 100 != 0 || yy % 400 == 0)) ? 1 : 0);
	if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 ||

		dd < 1 || dd > mdays[--mm]) return (-1);

	jdate = dd-1;
        for (i=0; i<mm; i++) jdate += mdays[i];
	for (i = epoch; i < yy; i++) {
	    jdate += 365 + ((i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) ? 1 : 0);
	}
	jdate *= daysec;
	jdate += zone * 60L;







|







 







|


|
>
|
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
	/*							*/
	/* 	Steven M. Bellovin (unc!smb)			*/
	/*	Dept. of Computer Science			*/
	/*	University of North Carolina at Chapel Hill	*/
	/*	@(#)getdate.y	2.13	9/16/86			*/

#if !defined(lint)
static char rcsid[] = "$Id: getdate.y,v 1.1 2008/12/27 00:56:03 vandys Exp vandys $";
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
................................................................................
dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
int mm, dd, yy, h, m, s, mer, zone, dayflag;
{
	time_t tod, jdate;
	register int i;

	if (yy < 0) yy = -yy;
	if (yy < 200) yy += 1900;
	mdays[1] =
	    28 + ((yy % 4 == 0 && (yy % 100 != 0 || yy % 400 == 0)) ? 1 : 0);
	if ((yy < epoch) || (yy > 2099) || (mm < 1) || (mm > 12) ||
		(dd < 1) || (dd > mdays[--mm])) {
	    return (-1);
	}
	jdate = dd-1;
        for (i=0; i<mm; i++) jdate += mdays[i];
	for (i = epoch; i < yy; i++) {
	    jdate += 365 + ((i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) ? 1 : 0);
	}
	jdate *= daysec;
	jdate += zone * 60L;