📄 getdate.c
字号:
yyDay = yyvsp[0].Number; ; break;}case 21:#line 289 "getdate.y"{ /* 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 machine-generated dates like those in an RCS log listing. If you want portability, use the ISO 8601 format. */ if (yyvsp[-4].Number >= 1000) { yyYear = yyvsp[-4].Number; yyMonth = yyvsp[-2].Number; yyDay = yyvsp[0].Number; } else { yyMonth = yyvsp[-4].Number; yyDay = yyvsp[-2].Number; yyYear = yyvsp[0].Number; } ; break;}case 22:#line 307 "getdate.y"{ /* ISO 8601 format. yyyy-mm-dd. */ yyYear = yyvsp[-2].Number; yyMonth = -yyvsp[-1].Number; yyDay = -yyvsp[0].Number; ; break;}case 23:#line 313 "getdate.y"{ /* e.g. 17-JUN-1992. */ yyDay = yyvsp[-2].Number; yyMonth = yyvsp[-1].Number; yyYear = -yyvsp[0].Number; ; break;}case 24:#line 319 "getdate.y"{ yyMonth = yyvsp[-1].Number; yyDay = yyvsp[0].Number; ; break;}case 25:#line 323 "getdate.y"{ yyMonth = yyvsp[-3].Number; yyDay = yyvsp[-2].Number; yyYear = yyvsp[0].Number; ; break;}case 26:#line 328 "getdate.y"{ yyMonth = yyvsp[0].Number; yyDay = yyvsp[-1].Number; ; break;}case 27:#line 332 "getdate.y"{ yyMonth = yyvsp[-1].Number; yyDay = yyvsp[-2].Number; yyYear = yyvsp[0].Number; ; break;}case 28:#line 339 "getdate.y"{ yyRelSeconds = -yyRelSeconds; yyRelMinutes = -yyRelMinutes; yyRelHour = -yyRelHour; yyRelDay = -yyRelDay; yyRelMonth = -yyRelMonth; yyRelYear = -yyRelYear; ; break;}case 30:#line 350 "getdate.y"{ yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 31:#line 353 "getdate.y"{ yyRelYear += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 32:#line 356 "getdate.y"{ yyRelYear++; ; break;}case 33:#line 359 "getdate.y"{ yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 34:#line 362 "getdate.y"{ yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 35:#line 365 "getdate.y"{ yyRelMonth++; ; break;}case 36:#line 368 "getdate.y"{ yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 37:#line 371 "getdate.y"{ yyRelDay += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 38:#line 374 "getdate.y"{ yyRelDay++; ; break;}case 39:#line 377 "getdate.y"{ yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 40:#line 380 "getdate.y"{ yyRelHour += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 41:#line 383 "getdate.y"{ yyRelHour++; ; break;}case 42:#line 386 "getdate.y"{ yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 43:#line 389 "getdate.y"{ yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 44:#line 392 "getdate.y"{ yyRelMinutes++; ; break;}case 45:#line 395 "getdate.y"{ yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 46:#line 398 "getdate.y"{ yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; ; break;}case 47:#line 401 "getdate.y"{ yyRelSeconds++; ; break;}case 48:#line 407 "getdate.y"{ if (yyHaveTime && yyHaveDate && !yyHaveRel) yyYear = yyvsp[0].Number; else { if (yyvsp[0].Number>10000) { yyHaveDate++; yyDay= (yyvsp[0].Number)%100; yyMonth= (yyvsp[0].Number/100)%100; yyYear = yyvsp[0].Number/10000; } else { yyHaveTime++; if (yyvsp[0].Number < 100) { yyHour = yyvsp[0].Number; yyMinutes = 0; } else { yyHour = yyvsp[0].Number / 100; yyMinutes = yyvsp[0].Number % 100; } yySeconds = 0; yyMeridian = MER24; } } ; break;}case 49:#line 440 "getdate.y"{ yyval.Meridian = MER24; ; break;}case 50:#line 444 "getdate.y"{ yyval.Meridian = yyvsp[0].Meridian; ; break;}} /* the action file gets copied in in place of this dollarsign */#line 543 "/usr/share/misc/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 449 "getdate.y"/* 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 }};/* 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 }};/* 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, 2 }, { "first", tUNUMBER, 1 },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -