📄 getdate.c
字号:
machine-generated dates like those in an RCS log listing. If you want portability, use the ISO 8601 format. */ if (yyvsp[-4].Number >= 1000) { context->yyYear = yyvsp[-4].Number; context->yyMonth = yyvsp[-2].Number; context->yyDay = yyvsp[0].Number; } else { context->yyMonth = yyvsp[-4].Number; context->yyDay = yyvsp[-2].Number; context->yyYear = yyvsp[0].Number; } ; break;}case 22:#line 344 "getdate.y"{ /* ISO 8601 format. yyyy-mm-dd. */ context->yyYear = yyvsp[-2].Number; context->yyMonth = -yyvsp[-1].Number; context->yyDay = -yyvsp[0].Number; ; break;}case 23:#line 350 "getdate.y"{ /* e.g. 17-JUN-1992. */ context->yyDay = yyvsp[-2].Number; context->yyMonth = yyvsp[-1].Number; context->yyYear = -yyvsp[0].Number; ; break;}case 24:#line 356 "getdate.y"{ context->yyMonth = yyvsp[-1].Number; context->yyDay = yyvsp[0].Number; ; break;}case 25:#line 360 "getdate.y"{ context->yyMonth = yyvsp[-3].Number; context->yyDay = yyvsp[-2].Number; context->yyYear = yyvsp[0].Number; ; break;}case 26:#line 365 "getdate.y"{ context->yyMonth = yyvsp[0].Number; context->yyDay = yyvsp[-1].Number; ; break;}case 27:#line 369 "getdate.y"{ context->yyMonth = yyvsp[-1].Number; context->yyDay = yyvsp[-2].Number; context->yyYear = yyvsp[0].Number; ; break;}case 28:#line 376 "getdate.y"{ context->yyRelSeconds = -context->yyRelSeconds; context->yyRelMinutes = -context->yyRelMinutes; context->yyRelHour = -context->yyRelHour; context->yyRelDay = -context->yyRelDay; context->yyRelMonth = -context->yyRelMonth; context->yyRelYear = -context->yyRelYear; ; break;}case 30:#line 387 "getdate.y"{ context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 31:#line 390 "getdate.y"{ context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 32:#line 393 "getdate.y"{ context->yyRelYear += yyvsp[0].Number; ; break;}case 33:#line 396 "getdate.y"{ context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 34:#line 399 "getdate.y"{ context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 35:#line 402 "getdate.y"{ context->yyRelMonth += yyvsp[0].Number; ; break;}case 36:#line 405 "getdate.y"{ context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 37:#line 408 "getdate.y"{ context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 38:#line 411 "getdate.y"{ context->yyRelDay += yyvsp[0].Number; ; break;}case 39:#line 414 "getdate.y"{ context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 40:#line 417 "getdate.y"{ context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 41:#line 420 "getdate.y"{ context->yyRelHour += yyvsp[0].Number; ; break;}case 42:#line 423 "getdate.y"{ context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 43:#line 426 "getdate.y"{ context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 44:#line 429 "getdate.y"{ context->yyRelMinutes += yyvsp[0].Number; ; break;}case 45:#line 432 "getdate.y"{ context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 46:#line 435 "getdate.y"{ context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 47:#line 438 "getdate.y"{ context->yyRelSeconds += yyvsp[0].Number; ; break;}case 48:#line 444 "getdate.y"{ if (context->yyHaveTime && context->yyHaveDate && !context->yyHaveRel) context->yyYear = yyvsp[0].Number; else { if (yyvsp[0].Number>10000) { context->yyHaveDate++; context->yyDay= (yyvsp[0].Number)%100; context->yyMonth= (yyvsp[0].Number/100)%100; context->yyYear = yyvsp[0].Number/10000; } else { context->yyHaveTime++; if (yyvsp[0].Number < 100) { context->yyHour = yyvsp[0].Number; context->yyMinutes = 0; } else { context->yyHour = yyvsp[0].Number / 100; context->yyMinutes = yyvsp[0].Number % 100; } context->yySeconds = 0; context->yyMeridian = MER24; } } ; break;}case 49:#line 478 "getdate.y"{ yyval.Meridian = MER24; ; break;}case 50:#line 482 "getdate.y"{ yyval.Meridian = yyvsp[0].Meridian; ; break;}} /* the action file gets copied in in place of this dollarsign */#line 543 "/usr/lib/bison.simple" yyvsp -= yylen; yyssp -= yylen;#ifdef YYLSP_NEEDED yylsp -= yylen;#endif#if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); }#endif *++yyvsp = yyval;#ifdef YYLSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; }#endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate;yyerrlab: /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++yynerrs;#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; msg = (char *) malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); if (count < 5) { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; } } yyerror(msg); free(msg); } else yyerror ("parse error; also virtual memory exceeded"); } else#endif /* YYERROR_VERBOSE */ yyerror("parse error"); } goto yyerrlab1;yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT;#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);#endif yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle;yyerrdefault: /* current state does not do anything special for the error token. */#if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) goto yydefault;#endifyyerrpop: /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp;#ifdef YYLSP_NEEDED yylsp--;#endif#if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); }#endifyyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT;#if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting error token, ");#endif *++yyvsp = yylval;#ifdef YYLSP_NEEDED *++yylsp = yylloc;#endif yystate = yyn; goto yynewstate; yyacceptlab: /* YYACCEPT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs);#ifdef YYLSP_NEEDED free (yyls);#endif } return 0; yyabortlab: /* YYABORT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs);#ifdef YYLSP_NEEDED free (yyls);#endif } return 1;}#line 487 "getdate.y"/* Include this file down here because bison inserts code above which may define-away `const'. We want the prototype for get_date to have the same signature as the function definition does. */#include "getdate.h"#ifndef WIN32 /* the windows dudes don't need these, does anyone really? */extern struct tm *gmtime ();extern struct tm *localtime ();extern time_t mktime ();#endif/* Month and day table. */static TABLE const MonthDayTable[] = { { "january", tMONTH, 1 }, { "february", tMONTH, 2 }, { "march", tMONTH, 3 }, { "april", tMONTH, 4 }, { "may", tMONTH, 5 }, { "june", tMONTH, 6 }, { "july", tMONTH, 7 }, { "august", tMONTH, 8 }, { "september", tMONTH, 9 }, { "sept", tMONTH, 9 }, { "october", tMONTH, 10 }, { "november", tMONTH, 11 }, { "december", tMONTH, 12 }, { "sunday", tDAY, 0 }, { "monday", tDAY, 1 }, { "tuesday", tDAY, 2 }, { "tues", tDAY, 2 }, { "wednesday", tDAY, 3 }, { "wednes", tDAY, 3 }, { "thursday", tDAY, 4 }, { "thur", tDAY, 4 }, { "thurs", tDAY, 4 }, { "friday", tDAY, 5 }, { "saturday", tDAY, 6 }, { NULL, 0, 0 }};/* Time units table. */static TABLE const UnitsTable[] = { { "year", tYEAR_UNIT, 1 }, { "month", tMONTH_UNIT, 1 }, { "fortnight", tDAY_UNIT, 14 }, { "week", tDAY_UNIT, 7 }, { "day", tDAY_UNIT, 1 }, { "hour", tHOUR_UNIT, 1 }, { "minute", tMINUTE_UNIT, 1 }, { "min", tMINUTE_UNIT, 1 }, { "second", tSEC_UNIT, 1 }, { "sec", tSEC_UNIT, 1 }, { NULL, 0, 0 }};/* Assorted relative-time words. */static TABLE const OtherTable[] = { { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, { "today", tMINUTE_UNIT, 0 }, { "now", tMINUTE_UNIT, 0 }, { "last", tUNUMBER, -1 }, { "this", tMINUTE_UNIT, 0 }, { "next", tUNUMBER, 1 }, { "first", tUNUMBER, 1 },/* { "second", tUNUMBER, 2 }, */ { "third", tUNUMBER, 3 }, { "fourth", tUNUMBER, 4 }, { "fifth", tUNUMBER, 5 }, { "sixth", tUNUMBER, 6 }, { "seventh", tUNUMBER, 7 }, { "eighth", tUNUMBER, 8 }, { "ninth", tUNUMBER, 9 }, { "tenth", tUNUMBER, 10 }, { "eleventh", tUNUMBER, 11 }, { "twelfth", tUNUMBER, 12 }, { "ago", tAGO, 1 }, { NULL, 0, 0 }};/* The timezone table. */static TABLE const TimezoneTable[] = { { "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */ { "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ { "utc", tZONE, HOUR ( 0) },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -