clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name getdate.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/gnu/usr.bin/cvs/obj/lib -resource-dir /usr/local/lib/clang/13.0.0 -D HAVE_CONFIG_H -I . -I /usr/src/gnu/usr.bin/cvs/lib -I .. -I ../src -I /usr/src/gnu/usr.bin/cvs/src -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/gnu/usr.bin/cvs/obj/lib -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c getdate.c
| 1 | #include <stdlib.h> |
| 2 | #include <string.h> |
| 3 | #define YYBYACC 1 |
| 4 | #define YYMAJOR 1 |
| 5 | #define YYMINOR 9 |
| 6 | #define YYLEX yylex() |
| 7 | #define YYEMPTY -1 |
| 8 | #define yyclearin (yychar=(YYEMPTY)) |
| 9 | #define yyerrok (yyerrflag=0) |
| 10 | #define YYRECOVERING() (yyerrflag!=0) |
| 11 | #define YYPREFIX "yy" |
| 12 | #line 2 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | #ifdef HAVE_CONFIG_H |
| 27 | #if defined (emacs) || defined (CONFIG_BROKETS) |
| 28 | #include <config.h> |
| 29 | #else |
| 30 | #include "config.h" |
| 31 | #endif |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | #ifdef emacs |
| 41 | #undef static |
| 42 | #endif |
| 43 | |
| 44 | #include <stdio.h> |
| 45 | #include <ctype.h> |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | #if defined(vms) |
| 53 | # include <types.h> |
| 54 | #else /* defined(vms) */ |
| 55 | # include <sys/types.h> |
| 56 | # include "xtime.h" |
| 57 | #endif /* !defined(vms) */ |
| 58 | |
| 59 | #if defined (STDC_HEADERS) || defined (USG) |
| 60 | #include <string.h> |
| 61 | #endif |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | #if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy) |
| 67 | #define bcopy(from, to, len) memcpy ((to), (from), (len)) |
| 68 | #endif |
| 69 | |
| 70 | #if defined (STDC_HEADERS) |
| 71 | #include <stdlib.h> |
| 72 | #endif |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | extern struct tm *gmtime(); |
| 88 | extern struct tm *localtime(); |
| 89 | |
| 90 | #define yyparse getdate_yyparse |
| 91 | #define yylex getdate_yylex |
| 92 | #define yyerror getdate_yyerror |
| 93 | |
| 94 | static int yyparse (); |
| 95 | static int yylex (); |
| 96 | static int yyerror (); |
| 97 | |
| 98 | #define EPOCH 1970 |
| 99 | #define HOUR(x) ((time_t)(x) * 60) |
| 100 | #define SECSPERDAY (24L * 60L * 60L) |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | typedef struct _TABLE { |
| 107 | char *name; |
| 108 | int type; |
| 109 | time_t value; |
| 110 | } TABLE; |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | typedef enum _DSTMODE { |
| 117 | DSTon, DSToff, DSTmaybe |
| 118 | } DSTMODE; |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | typedef enum _MERIDIAN { |
| 124 | MERam, MERpm, MER24 |
| 125 | } MERIDIAN; |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | static char *yyInput; |
| 135 | static DSTMODE yyDSTmode; |
| 136 | static time_t yyDayOrdinal; |
| 137 | static time_t yyDayNumber; |
| 138 | static int yyHaveDate; |
| 139 | static int yyHaveDay; |
| 140 | static int yyHaveRel; |
| 141 | static int yyHaveTime; |
| 142 | static int yyHaveZone; |
| 143 | static time_t yyTimezone; |
| 144 | static time_t yyDay; |
| 145 | static time_t yyHour; |
| 146 | static time_t yyMinutes; |
| 147 | static time_t yyMonth; |
| 148 | static time_t yySeconds; |
| 149 | static time_t yyYear; |
| 150 | static MERIDIAN yyMeridian; |
| 151 | static time_t yyRelMonth; |
| 152 | static time_t yyRelSeconds; |
| 153 | |
| 154 | #line 145 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 155 | #ifndef YYSTYPE_DEFINED |
| 156 | #define YYSTYPE_DEFINED |
| 157 | typedef union { |
| 158 | time_t Number; |
| 159 | enum _MERIDIAN Meridian; |
| 160 | } YYSTYPE; |
| 161 | #endif /* YYSTYPE_DEFINED */ |
| 162 | #line 163 "y.tab.c" |
| 163 | #define tAGO 257 |
| 164 | #define tDAY 258 |
| 165 | #define tDAYZONE 259 |
| 166 | #define tID 260 |
| 167 | #define tMERIDIAN 261 |
| 168 | #define tMINUTE_UNIT 262 |
| 169 | #define tMONTH 263 |
| 170 | #define tMONTH_UNIT 264 |
| 171 | #define tSEC_UNIT 265 |
| 172 | #define tSNUMBER 266 |
| 173 | #define tUNUMBER 267 |
| 174 | #define tZONE 268 |
| 175 | #define tDST 269 |
| 176 | #define YYERRCODE 256 |
| 177 | const short yylhs[] = |
| 178 | { -1, |
| 179 | 0, 0, 2, 2, 2, 2, 2, 2, 3, 3, |
| 180 | 3, 3, 3, 4, 4, 4, 6, 6, 6, 5, |
| 181 | 5, 5, 5, 5, 5, 5, 5, 7, 7, 9, |
| 182 | 9, 9, 9, 9, 9, 9, 9, 9, 8, 1, |
| 183 | 1, |
| 184 | }; |
| 185 | const short yylen[] = |
| 186 | { 2, |
| 187 | 0, 2, 1, 1, 1, 1, 1, 1, 2, 4, |
| 188 | 4, 6, 6, 1, 1, 2, 1, 2, 2, 3, |
| 189 | 5, 3, 3, 2, 4, 2, 3, 2, 1, 2, |
| 190 | 2, 1, 2, 2, 1, 2, 2, 1, 1, 0, |
| 191 | 1, |
| 192 | }; |
| 193 | const short yydefred[] = |
| 194 | { 1, |
| 195 | 0, 0, 15, 32, 0, 38, 35, 0, 0, 0, |
| 196 | 2, 3, 4, 5, 6, 7, 8, 0, 18, 0, |
| 197 | 31, 36, 33, 19, 9, 30, 0, 37, 34, 0, |
| 198 | 0, 0, 16, 28, 0, 23, 27, 22, 0, 0, |
| 199 | 25, 41, 11, 0, 10, 0, 0, 21, 13, 12, |
| 200 | }; |
| 201 | const short yydgoto[] = |
| 202 | { 1, |
| 203 | 45, 11, 12, 13, 14, 15, 16, 17, 18, |
| 204 | }; |
| 205 | const short yysindex[] = |
| 206 | { 0, |
| 207 | -249, -38, 0, 0, -260, 0, 0, -240, -47, -248, |
| 208 | 0, 0, 0, 0, 0, 0, 0, -237, 0, -18, |
| 209 | 0, 0, 0, 0, 0, 0, -262, 0, 0, -239, |
| 210 | -238, -236, 0, 0, -235, 0, 0, 0, -56, -19, |
| 211 | 0, 0, 0, -234, 0, -232, -258, 0, 0, 0,}; |
| 212 | const short yyrindex[] = |
| 213 | { 0, |
| 214 | 0, 1, 0, 0, 0, 0, 0, 0, 69, 12, |
| 215 | 0, 0, 0, 0, 0, 0, 0, 23, 0, 34, |
| 216 | 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, |
| 217 | 0, 0, 0, 0, 0, 0, 0, 0, 56, 45, |
| 218 | 0, 0, 0, 0, 0, 0, 56, 0, 0, 0,}; |
| 219 | const short yygindex[] = |
| 220 | { 0, |
| 221 | -17, 0, 0, 0, 0, 0, 0, 0, 0, |
| 222 | }; |
| 223 | #define YYTABLESIZE 337 |
| 224 | const short yytable[] = |
| 225 | { 32, |
| 226 | 17, 44, 42, 36, 37, 19, 20, 49, 2, 3, |
| 227 | 31, 14, 4, 5, 6, 7, 8, 9, 10, 34, |
| 228 | 33, 21, 29, 22, 23, 35, 38, 46, 39, 50, |
| 229 | 40, 41, 47, 24, 48, 0, 0, 0, 0, 0, |
| 230 | 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, |
| 231 | 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, |
| 232 | 0, 0, 0, 0, 0, 0, 26, 0, 39, 0, |
| 233 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 234 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 235 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 236 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 237 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 238 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 239 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 240 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 241 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 242 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 243 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 244 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 245 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 246 | 0, 0, 0, 0, 42, 0, 0, 0, 0, 43, |
| 247 | 24, 0, 0, 25, 26, 27, 28, 29, 30, 0, |
| 248 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 249 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 250 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 251 | 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, |
| 252 | 0, 0, 17, 17, 17, 17, 17, 17, 17, 14, |
| 253 | 14, 0, 0, 14, 14, 14, 14, 14, 14, 14, |
| 254 | 29, 29, 0, 0, 29, 29, 29, 29, 29, 29, |
| 255 | 29, 24, 24, 0, 0, 24, 24, 24, 24, 24, |
| 256 | 24, 24, 20, 20, 0, 0, 20, 20, 20, 20, |
| 257 | 20, 20, 20, 40, 40, 0, 0, 40, 40, 40, |
| 258 | 40, 0, 40, 40, 26, 26, 0, 39, 26, 26, |
| 259 | 26, 26, 0, 0, 26, 39, 39, |
| 260 | }; |
| 261 | const short yycheck[] = |
| 262 | { 47, |
| 263 | 0, 58, 261, 266, 267, 44, 267, 266, 258, 259, |
| 264 | 58, 0, 262, 263, 264, 265, 266, 267, 268, 257, |
| 265 | 269, 262, 0, 264, 265, 44, 266, 47, 267, 47, |
| 266 | 267, 267, 267, 0, 267, -1, -1, -1, -1, -1, |
| 267 | -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, |
| 268 | -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, |
| 269 | -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, |
| 270 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 271 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 272 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 273 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 274 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 275 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 276 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 277 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 278 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 279 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 280 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 281 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 282 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 283 | -1, -1, -1, -1, 261, -1, -1, -1, -1, 266, |
| 284 | 258, -1, -1, 261, 262, 263, 264, 265, 266, -1, |
| 285 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 286 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 287 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 288 | -1, -1, -1, -1, -1, -1, -1, -1, 258, 259, |
| 289 | -1, -1, 262, 263, 264, 265, 266, 267, 268, 258, |
| 290 | 259, -1, -1, 262, 263, 264, 265, 266, 267, 268, |
| 291 | 258, 259, -1, -1, 262, 263, 264, 265, 266, 267, |
| 292 | 268, 258, 259, -1, -1, 262, 263, 264, 265, 266, |
| 293 | 267, 268, 258, 259, -1, -1, 262, 263, 264, 265, |
| 294 | 266, 267, 268, 258, 259, -1, -1, 262, 263, 264, |
| 295 | 265, -1, 267, 268, 258, 259, -1, 259, 262, 263, |
| 296 | 264, 265, -1, -1, 268, 267, 268, |
| 297 | }; |
| 298 | #define YYFINAL 1 |
| 299 | #ifndef YYDEBUG |
| 300 | #define YYDEBUG 0 |
| 301 | #endif |
| 302 | #define YYMAXTOKEN 269 |
| 303 | #if YYDEBUG |
| 304 | const char * const yyname[] = |
| 305 | { |
| 306 | "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, |
| 307 | 0,0,0,0,0,0,0,0,0,0,"','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,0,0, |
| 308 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 309 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 310 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 311 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
| 312 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"tAGO","tDAY", |
| 313 | "tDAYZONE","tID","tMERIDIAN","tMINUTE_UNIT","tMONTH","tMONTH_UNIT","tSEC_UNIT", |
| 314 | "tSNUMBER","tUNUMBER","tZONE","tDST", |
| 315 | }; |
| 316 | const char * const yyrule[] = |
| 317 | {"$accept : spec", |
| 318 | "spec :", |
| 319 | "spec : spec item", |
| 320 | "item : time", |
| 321 | "item : zone", |
| 322 | "item : date", |
| 323 | "item : day", |
| 324 | "item : rel", |
| 325 | "item : number", |
| 326 | "time : tUNUMBER tMERIDIAN", |
| 327 | "time : tUNUMBER ':' tUNUMBER o_merid", |
| 328 | "time : tUNUMBER ':' tUNUMBER tSNUMBER", |
| 329 | "time : tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid", |
| 330 | "time : tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER", |
| 331 | "zone : tZONE", |
| 332 | "zone : tDAYZONE", |
| 333 | "zone : tZONE tDST", |
| 334 | "day : tDAY", |
| 335 | "day : tDAY ','", |
| 336 | "day : tUNUMBER tDAY", |
| 337 | "date : tUNUMBER '/' tUNUMBER", |
| 338 | "date : tUNUMBER '/' tUNUMBER '/' tUNUMBER", |
| 339 | "date : tUNUMBER tSNUMBER tSNUMBER", |
| 340 | "date : tUNUMBER tMONTH tSNUMBER", |
| 341 | "date : tMONTH tUNUMBER", |
| 342 | "date : tMONTH tUNUMBER ',' tUNUMBER", |
| 343 | "date : tUNUMBER tMONTH", |
| 344 | "date : tUNUMBER tMONTH tUNUMBER", |
| 345 | "rel : relunit tAGO", |
| 346 | "rel : relunit", |
| 347 | "relunit : tUNUMBER tMINUTE_UNIT", |
| 348 | "relunit : tSNUMBER tMINUTE_UNIT", |
| 349 | "relunit : tMINUTE_UNIT", |
| 350 | "relunit : tSNUMBER tSEC_UNIT", |
| 351 | "relunit : tUNUMBER tSEC_UNIT", |
| 352 | "relunit : tSEC_UNIT", |
| 353 | "relunit : tSNUMBER tMONTH_UNIT", |
| 354 | "relunit : tUNUMBER tMONTH_UNIT", |
| 355 | "relunit : tMONTH_UNIT", |
| 356 | "number : tUNUMBER", |
| 357 | "o_merid :", |
| 358 | "o_merid : tMERIDIAN", |
| 359 | }; |
| 360 | #endif |
| 361 | #ifdef YYSTACKSIZE |
| 362 | #undef YYMAXDEPTH |
| 363 | #define YYMAXDEPTH YYSTACKSIZE |
| 364 | #else |
| 365 | #ifdef YYMAXDEPTH |
| 366 | #define YYSTACKSIZE YYMAXDEPTH |
| 367 | #else |
| 368 | #define YYSTACKSIZE 10000 |
| 369 | #define YYMAXDEPTH 10000 |
| 370 | #endif |
| 371 | #endif |
| 372 | #define YYINITSTACKSIZE 200 |
| 373 | |
| 374 | int yydebug; |
| 375 | int yynerrs; |
| 376 | int yyerrflag; |
| 377 | int yychar; |
| 378 | short *yyssp; |
| 379 | YYSTYPE *yyvsp; |
| 380 | YYSTYPE yyval; |
| 381 | YYSTYPE yylval; |
| 382 | short *yyss; |
| 383 | short *yysslim; |
| 384 | YYSTYPE *yyvs; |
| 385 | unsigned int yystacksize; |
| 386 | int yyparse(void); |
| 387 | #line 364 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 388 | |
| 389 | |
| 390 | static TABLE const MonthDayTable[] = { |
| 391 | { "january", tMONTH, 1 }, |
| 392 | { "february", tMONTH, 2 }, |
| 393 | { "march", tMONTH, 3 }, |
| 394 | { "april", tMONTH, 4 }, |
| 395 | { "may", tMONTH, 5 }, |
| 396 | { "june", tMONTH, 6 }, |
| 397 | { "july", tMONTH, 7 }, |
| 398 | { "august", tMONTH, 8 }, |
| 399 | { "september", tMONTH, 9 }, |
| 400 | { "sept", tMONTH, 9 }, |
| 401 | { "october", tMONTH, 10 }, |
| 402 | { "november", tMONTH, 11 }, |
| 403 | { "december", tMONTH, 12 }, |
| 404 | { "sunday", tDAY, 0 }, |
| 405 | { "monday", tDAY, 1 }, |
| 406 | { "tuesday", tDAY, 2 }, |
| 407 | { "tues", tDAY, 2 }, |
| 408 | { "wednesday", tDAY, 3 }, |
| 409 | { "wednes", tDAY, 3 }, |
| 410 | { "thursday", tDAY, 4 }, |
| 411 | { "thur", tDAY, 4 }, |
| 412 | { "thurs", tDAY, 4 }, |
| 413 | { "friday", tDAY, 5 }, |
| 414 | { "saturday", tDAY, 6 }, |
| 415 | { NULL } |
| 416 | }; |
| 417 | |
| 418 | |
| 419 | static TABLE const UnitsTable[] = { |
| 420 | { "year", tMONTH_UNIT, 12 }, |
| 421 | { "month", tMONTH_UNIT, 1 }, |
| 422 | { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, |
| 423 | { "week", tMINUTE_UNIT, 7 * 24 * 60 }, |
| 424 | { "day", tMINUTE_UNIT, 1 * 24 * 60 }, |
| 425 | { "hour", tMINUTE_UNIT, 60 }, |
| 426 | { "minute", tMINUTE_UNIT, 1 }, |
| 427 | { "min", tMINUTE_UNIT, 1 }, |
| 428 | { "second", tSEC_UNIT, 1 }, |
| 429 | { "sec", tSEC_UNIT, 1 }, |
| 430 | { NULL } |
| 431 | }; |
| 432 | |
| 433 | |
| 434 | static TABLE const OtherTable[] = { |
| 435 | { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, |
| 436 | { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, |
| 437 | { "today", tMINUTE_UNIT, 0 }, |
| 438 | { "now", tMINUTE_UNIT, 0 }, |
| 439 | { "last", tUNUMBER, -1 }, |
| 440 | { "this", tMINUTE_UNIT, 0 }, |
| 441 | { "next", tUNUMBER, 2 }, |
| 442 | { "first", tUNUMBER, 1 }, |
| 443 | |
| 444 | { "third", tUNUMBER, 3 }, |
| 445 | { "fourth", tUNUMBER, 4 }, |
| 446 | { "fifth", tUNUMBER, 5 }, |
| 447 | { "sixth", tUNUMBER, 6 }, |
| 448 | { "seventh", tUNUMBER, 7 }, |
| 449 | { "eighth", tUNUMBER, 8 }, |
| 450 | { "ninth", tUNUMBER, 9 }, |
| 451 | { "tenth", tUNUMBER, 10 }, |
| 452 | { "eleventh", tUNUMBER, 11 }, |
| 453 | { "twelfth", tUNUMBER, 12 }, |
| 454 | { "ago", tAGO, 1 }, |
| 455 | { NULL } |
| 456 | }; |
| 457 | |
| 458 | |
| 459 | |
| 460 | static TABLE const TimezoneTable[] = { |
| 461 | { "gmt", tZONE, HOUR( 0) }, |
| 462 | { "ut", tZONE, HOUR( 0) }, |
| 463 | { "utc", tZONE, HOUR( 0) }, |
| 464 | { "wet", tZONE, HOUR( 0) }, |
| 465 | { "bst", tDAYZONE, HOUR( 0) }, |
| 466 | { "wat", tZONE, HOUR( 1) }, |
| 467 | { "at", tZONE, HOUR( 2) }, |
| 468 | #if 0 |
| 469 | |
| 470 | |
| 471 | { "bst", tZONE, HOUR( 3) }, |
| 472 | { "gst", tZONE, HOUR( 3) }, |
| 473 | #endif |
| 474 | #if 0 |
| 475 | { "nft", tZONE, HOUR(3.5) }, |
| 476 | { "nst", tZONE, HOUR(3.5) }, |
| 477 | { "ndt", tDAYZONE, HOUR(3.5) }, |
| 478 | #endif |
| 479 | { "ast", tZONE, HOUR( 4) }, |
| 480 | { "adt", tDAYZONE, HOUR( 4) }, |
| 481 | { "est", tZONE, HOUR( 5) }, |
| 482 | { "edt", tDAYZONE, HOUR( 5) }, |
| 483 | { "cst", tZONE, HOUR( 6) }, |
| 484 | { "cdt", tDAYZONE, HOUR( 6) }, |
| 485 | { "mst", tZONE, HOUR( 7) }, |
| 486 | { "mdt", tDAYZONE, HOUR( 7) }, |
| 487 | { "pst", tZONE, HOUR( 8) }, |
| 488 | { "pdt", tDAYZONE, HOUR( 8) }, |
| 489 | { "yst", tZONE, HOUR( 9) }, |
| 490 | { "ydt", tDAYZONE, HOUR( 9) }, |
| 491 | { "hst", tZONE, HOUR(10) }, |
| 492 | { "hdt", tDAYZONE, HOUR(10) }, |
| 493 | { "cat", tZONE, HOUR(10) }, |
| 494 | { "ahst", tZONE, HOUR(10) }, |
| 495 | { "nt", tZONE, HOUR(11) }, |
| 496 | { "idlw", tZONE, HOUR(12) }, |
| 497 | { "cet", tZONE, -HOUR(1) }, |
| 498 | { "met", tZONE, -HOUR(1) }, |
| 499 | { "mewt", tZONE, -HOUR(1) }, |
| 500 | { "mest", tDAYZONE, -HOUR(1) }, |
| 501 | { "swt", tZONE, -HOUR(1) }, |
| 502 | { "sst", tDAYZONE, -HOUR(1) }, |
| 503 | { "fwt", tZONE, -HOUR(1) }, |
| 504 | { "fst", tDAYZONE, -HOUR(1) }, |
| 505 | { "eet", tZONE, -HOUR(2) }, |
| 506 | { "bt", tZONE, -HOUR(3) }, |
| 507 | #if 0 |
| 508 | { "it", tZONE, -HOUR(3.5) }, |
| 509 | #endif |
| 510 | { "zp4", tZONE, -HOUR(4) }, |
| 511 | { "zp5", tZONE, -HOUR(5) }, |
| 512 | #if 0 |
| 513 | { "ist", tZONE, -HOUR(5.5) }, |
| 514 | #endif |
| 515 | { "zp6", tZONE, -HOUR(6) }, |
| 516 | #if 0 |
| 517 | |
| 518 | |
| 519 | { "nst", tZONE, -HOUR(6.5) }, |
| 520 | { "sst", tZONE, -HOUR(7) }, |
| 521 | #endif /* 0 */ |
| 522 | { "wast", tZONE, -HOUR(7) }, |
| 523 | { "wadt", tDAYZONE, -HOUR(7) }, |
| 524 | #if 0 |
| 525 | { "jt", tZONE, -HOUR(7.5) }, |
| 526 | #endif |
| 527 | { "cct", tZONE, -HOUR(8) }, |
| 528 | { "jst", tZONE, -HOUR(9) }, |
| 529 | #if 0 |
| 530 | { "cast", tZONE, -HOUR(9.5) }, |
| 531 | { "cadt", tDAYZONE, -HOUR(9.5) }, |
| 532 | #endif |
| 533 | { "east", tZONE, -HOUR(10) }, |
| 534 | { "eadt", tDAYZONE, -HOUR(10) }, |
| 535 | { "gst", tZONE, -HOUR(10) }, |
| 536 | { "nzt", tZONE, -HOUR(12) }, |
| 537 | { "nzst", tZONE, -HOUR(12) }, |
| 538 | { "nzdt", tDAYZONE, -HOUR(12) }, |
| 539 | { "idle", tZONE, -HOUR(12) }, |
| 540 | { NULL } |
| 541 | }; |
| 542 | |
| 543 | |
| 544 | static TABLE const MilitaryTable[] = { |
| 545 | { "a", tZONE, HOUR( 1) }, |
| 546 | { "b", tZONE, HOUR( 2) }, |
| 547 | { "c", tZONE, HOUR( 3) }, |
| 548 | { "d", tZONE, HOUR( 4) }, |
| 549 | { "e", tZONE, HOUR( 5) }, |
| 550 | { "f", tZONE, HOUR( 6) }, |
| 551 | { "g", tZONE, HOUR( 7) }, |
| 552 | { "h", tZONE, HOUR( 8) }, |
| 553 | { "i", tZONE, HOUR( 9) }, |
| 554 | { "k", tZONE, HOUR( 10) }, |
| 555 | { "l", tZONE, HOUR( 11) }, |
| 556 | { "m", tZONE, HOUR( 12) }, |
| 557 | { "n", tZONE, HOUR(- 1) }, |
| 558 | { "o", tZONE, HOUR(- 2) }, |
| 559 | { "p", tZONE, HOUR(- 3) }, |
| 560 | { "q", tZONE, HOUR(- 4) }, |
| 561 | { "r", tZONE, HOUR(- 5) }, |
| 562 | { "s", tZONE, HOUR(- 6) }, |
| 563 | { "t", tZONE, HOUR(- 7) }, |
| 564 | { "u", tZONE, HOUR(- 8) }, |
| 565 | { "v", tZONE, HOUR(- 9) }, |
| 566 | { "w", tZONE, HOUR(-10) }, |
| 567 | { "x", tZONE, HOUR(-11) }, |
| 568 | { "y", tZONE, HOUR(-12) }, |
| 569 | { "z", tZONE, HOUR( 0) }, |
| 570 | { NULL } |
| 571 | }; |
| 572 | |
| 573 |
|
| 574 | |
| 575 | |
| 576 | |
| 577 | static int |
| 578 | yyerror(s) |
| 579 | char *s; |
| 580 | { |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | |
| 585 | static time_t |
| 586 | ToSeconds(Hours, Minutes, Seconds, Meridian) |
| 587 | time_t Hours; |
| 588 | time_t Minutes; |
| 589 | time_t Seconds; |
| 590 | MERIDIAN Meridian; |
| 591 | { |
| 592 | if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) |
| 593 | return -1; |
| 594 | switch (Meridian) { |
| 595 | case MER24: |
| 596 | if (Hours < 0 || Hours > 23) |
| 597 | return -1; |
| 598 | return (Hours * 60L + Minutes) * 60L + Seconds; |
| 599 | case MERam: |
| 600 | if (Hours < 1 || Hours > 12) |
| 601 | return -1; |
| 602 | if (Hours == 12) |
| 603 | Hours = 0; |
| 604 | return (Hours * 60L + Minutes) * 60L + Seconds; |
| 605 | case MERpm: |
| 606 | if (Hours < 1 || Hours > 12) |
| 607 | return -1; |
| 608 | if (Hours == 12) |
| 609 | Hours = 0; |
| 610 | return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; |
| 611 | default: |
| 612 | abort (); |
| 613 | } |
| 614 | |
| 615 | } |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | static time_t |
| 623 | Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) |
| 624 | time_t Month; |
| 625 | time_t Day; |
| 626 | time_t Year; |
| 627 | time_t Hours; |
| 628 | time_t Minutes; |
| 629 | time_t Seconds; |
| 630 | MERIDIAN Meridian; |
| 631 | DSTMODE DSTmode; |
| 632 | { |
| 633 | static int DaysInMonth[12] = { |
| 634 | 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
| 635 | }; |
| 636 | time_t tod; |
| 637 | time_t Julian; |
| 638 | int i; |
| 639 | |
| 640 | if (Year < 0) |
| 641 | Year = -Year; |
| 642 | if (Year < 69) |
| 643 | Year += 2000; |
| 644 | else if (Year < 100) { |
| 645 | Year += 1900; |
| 646 | if (Year < EPOCH) |
| 647 | Year += 100; |
| 648 | } |
| 649 | DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) |
| 650 | ? 29 : 28; |
| 651 | |
| 652 | if (Year < EPOCH |
| 653 | || (sizeof(time_t) == sizeof(int) && Year > 2038) |
| 654 | || Month < 1 || Month > 12 |
| 655 | |
| 656 | || Day < 1 || Day > DaysInMonth[(int)--Month]) |
| 657 | return -1; |
| 658 | |
| 659 | for (Julian = Day - 1, i = 0; i < Month; i++) |
| 660 | Julian += DaysInMonth[i]; |
| 661 | for (i = EPOCH; i < Year; i++) |
| 662 | Julian += 365 + (i % 4 == 0); |
| 663 | Julian *= SECSPERDAY; |
| 664 | Julian += yyTimezone * 60L; |
| 665 | if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) |
| 666 | return -1; |
| 667 | Julian += tod; |
| 668 | if (DSTmode == DSTon |
| 669 | || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) |
| 670 | Julian -= 60 * 60; |
| 671 | return Julian; |
| 672 | } |
| 673 | |
| 674 | |
| 675 | static time_t |
| 676 | DSTcorrect(Start, Future) |
| 677 | time_t Start; |
| 678 | time_t Future; |
| 679 | { |
| 680 | time_t StartDay; |
| 681 | time_t FutureDay; |
| 682 | |
| 683 | StartDay = (localtime(&Start)->tm_hour + 1) % 24; |
| 684 | FutureDay = (localtime(&Future)->tm_hour + 1) % 24; |
| 685 | return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; |
| 686 | } |
| 687 | |
| 688 | |
| 689 | static time_t |
| 690 | RelativeDate(Start, DayOrdinal, DayNumber) |
| 691 | time_t Start; |
| 692 | time_t DayOrdinal; |
| 693 | time_t DayNumber; |
| 694 | { |
| 695 | struct tm *tm; |
| 696 | time_t now; |
| 697 | |
| 698 | now = Start; |
| 699 | tm = localtime(&now); |
| 700 | now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); |
| 701 | now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); |
| 702 | return DSTcorrect(Start, now); |
| 703 | } |
| 704 | |
| 705 | |
| 706 | static time_t |
| 707 | RelativeMonth(Start, RelMonth) |
| 708 | time_t Start; |
| 709 | time_t RelMonth; |
| 710 | { |
| 711 | struct tm *tm; |
| 712 | time_t Month; |
| 713 | time_t Year; |
| 714 | |
| 715 | if (RelMonth == 0) |
| 716 | return 0; |
| 717 | tm = localtime(&Start); |
| 718 | Month = 12 * (tm->tm_year + 1900) + tm->tm_mon + RelMonth; |
| 719 | Year = Month / 12; |
| 720 | Month = Month % 12 + 1; |
| 721 | return DSTcorrect(Start, |
| 722 | Convert(Month, (time_t)tm->tm_mday, Year, |
| 723 | (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, |
| 724 | MER24, DSTmaybe)); |
| 725 | } |
| 726 | |
| 727 | |
| 728 | static int |
| 729 | LookupWord(buff) |
| 730 | char *buff; |
| 731 | { |
| 732 | register char *p; |
| 733 | register char *q; |
| 734 | register const TABLE *tp; |
| 735 | int i; |
| 736 | int abbrev; |
| 737 | |
| 738 | |
| 739 | for (p = buff; *p; p++) |
| 740 | if (isupper(*p)) |
| 741 | *p = tolower(*p); |
| 742 | |
| 743 | if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { |
| 744 | yylval.Meridian = MERam; |
| 745 | return tMERIDIAN; |
| 746 | } |
| 747 | if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { |
| 748 | yylval.Meridian = MERpm; |
| 749 | return tMERIDIAN; |
| 750 | } |
| 751 | |
| 752 | |
| 753 | if (strlen(buff) == 3) |
| 754 | abbrev = 1; |
| 755 | else if (strlen(buff) == 4 && buff[3] == '.') { |
| 756 | abbrev = 1; |
| 757 | buff[3] = '\0'; |
| 758 | } |
| 759 | else |
| 760 | abbrev = 0; |
| 761 | |
| 762 | for (tp = MonthDayTable; tp->name; tp++) { |
| 763 | if (abbrev) { |
| 764 | if (strncmp(buff, tp->name, 3) == 0) { |
| 765 | yylval.Number = tp->value; |
| 766 | return tp->type; |
| 767 | } |
| 768 | } |
| 769 | else if (strcmp(buff, tp->name) == 0) { |
| 770 | yylval.Number = tp->value; |
| 771 | return tp->type; |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | for (tp = TimezoneTable; tp->name; tp++) |
| 776 | if (strcmp(buff, tp->name) == 0) { |
| 777 | yylval.Number = tp->value; |
| 778 | return tp->type; |
| 779 | } |
| 780 | |
| 781 | if (strcmp(buff, "dst") == 0) |
| 782 | return tDST; |
| 783 | |
| 784 | for (tp = UnitsTable; tp->name; tp++) |
| 785 | if (strcmp(buff, tp->name) == 0) { |
| 786 | yylval.Number = tp->value; |
| 787 | return tp->type; |
| 788 | } |
| 789 | |
| 790 | |
| 791 | i = strlen(buff) - 1; |
| 792 | if (buff[i] == 's') { |
| 793 | buff[i] = '\0'; |
| 794 | for (tp = UnitsTable; tp->name; tp++) |
| 795 | if (strcmp(buff, tp->name) == 0) { |
| 796 | yylval.Number = tp->value; |
| 797 | return tp->type; |
| 798 | } |
| 799 | buff[i] = 's'; |
| 800 | } |
| 801 | |
| 802 | for (tp = OtherTable; tp->name; tp++) |
| 803 | if (strcmp(buff, tp->name) == 0) { |
| 804 | yylval.Number = tp->value; |
| 805 | return tp->type; |
| 806 | } |
| 807 | |
| 808 | |
| 809 | if (buff[1] == '\0' && isalpha(*buff)) { |
| 810 | for (tp = MilitaryTable; tp->name; tp++) |
| 811 | if (strcmp(buff, tp->name) == 0) { |
| 812 | yylval.Number = tp->value; |
| 813 | return tp->type; |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | |
| 818 | for (i = 0, p = q = buff; *q; q++) |
| 819 | if (*q != '.') |
| 820 | *p++ = *q; |
| 821 | else |
| 822 | i++; |
| 823 | *p = '\0'; |
| 824 | if (i) |
| 825 | for (tp = TimezoneTable; tp->name; tp++) |
| 826 | if (strcmp(buff, tp->name) == 0) { |
| 827 | yylval.Number = tp->value; |
| 828 | return tp->type; |
| 829 | } |
| 830 | |
| 831 | return tID; |
| 832 | } |
| 833 | |
| 834 | |
| 835 | static int |
| 836 | yylex() |
| 837 | { |
| 838 | register char c; |
| 839 | register char *p; |
| 840 | char buff[20]; |
| 841 | int Count; |
| 842 | int sign; |
| 843 | |
| 844 | for ( ; ; ) { |
| 845 | while (isspace(*yyInput)) |
| 846 | yyInput++; |
| 847 | |
| 848 | if (isdigit(c = *yyInput) || c == '-' || c == '+') { |
| 849 | if (c == '-' || c == '+') { |
| 850 | sign = c == '-' ? -1 : 1; |
| 851 | if (!isdigit(*++yyInput)) |
| 852 | |
| 853 | continue; |
| 854 | } |
| 855 | else |
| 856 | sign = 0; |
| 857 | for (yylval.Number = 0; isdigit(c = *yyInput++); ) |
| 858 | yylval.Number = 10 * yylval.Number + c - '0'; |
| 859 | yyInput--; |
| 860 | if (sign < 0) |
| 861 | yylval.Number = -yylval.Number; |
| 862 | return sign ? tSNUMBER : tUNUMBER; |
| 863 | } |
| 864 | if (isalpha(c)) { |
| 865 | for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) |
| 866 | if (p < &buff[sizeof buff - 1]) |
| 867 | *p++ = c; |
| 868 | *p = '\0'; |
| 869 | yyInput--; |
| 870 | return LookupWord(buff); |
| 871 | } |
| 872 | if (c != '(') |
| 873 | return *yyInput++; |
| 874 | Count = 0; |
| 875 | do { |
| 876 | c = *yyInput++; |
| 877 | if (c == '\0') |
| 878 | return c; |
| 879 | if (c == '(') |
| 880 | Count++; |
| 881 | else if (c == ')') |
| 882 | Count--; |
| 883 | } while (Count > 0); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | #define TM_YEAR_ORIGIN 1900 |
| 888 | |
| 889 | |
| 890 | static long |
| 891 | difftm (a, b) |
| 892 | struct tm *a, *b; |
| 893 | { |
| 894 | int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); |
| 895 | int by = b->tm_year + (TM_YEAR_ORIGIN - 1); |
| 896 | int days = ( |
| 897 | |
| 898 | a->tm_yday - b->tm_yday |
| 899 | |
| 900 | + ((ay >> 2) - (by >> 2)) |
| 901 | - (ay/100 - by/100) |
| 902 | + ((ay/100 >> 2) - (by/100 >> 2)) |
| 903 | |
| 904 | + (long)(ay-by) * 365 |
| 905 | ); |
| 906 | return (60*(60*(24*days + (a->tm_hour - b->tm_hour)) |
| 907 | + (a->tm_min - b->tm_min)) |
| 908 | + (a->tm_sec - b->tm_sec)); |
| 909 | } |
| 910 | |
| 911 | time_t |
| 912 | get_date(p) |
| 913 | char *p; |
| 914 | { |
| 915 | struct tm *tm, *gmt, gmtbuf; |
| 916 | time_t Start; |
| 917 | time_t tod; |
| 918 | time_t now; |
| 919 | time_t timezone; |
| 920 | |
| 921 | yyInput = p; |
| 922 | (void)time (&now); |
| 923 | |
| 924 | gmt = gmtime (&now); |
| 925 | if (gmt != NULL) |
| 926 | { |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | gmtbuf = *gmt; |
| 932 | gmt = &gmtbuf; |
| 933 | } |
| 934 | |
| 935 | if (! (tm = localtime (&now))) |
| 936 | return -1; |
| 937 | |
| 938 | if (gmt != NULL) |
| 939 | timezone = difftm (gmt, tm) / 60; |
| 940 | else |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | timezone = 0; |
| 947 | |
| 948 | if(tm->tm_isdst) |
| 949 | timezone += 60; |
| 950 | |
| 951 | tm = localtime(&now); |
| 952 | yyYear = tm->tm_year + 1900; |
| 953 | yyMonth = tm->tm_mon + 1; |
| 954 | yyDay = tm->tm_mday; |
| 955 | yyTimezone = timezone; |
| 956 | yyDSTmode = DSTmaybe; |
| 957 | yyHour = 0; |
| 958 | yyMinutes = 0; |
| 959 | yySeconds = 0; |
| 960 | yyMeridian = MER24; |
| 961 | yyRelSeconds = 0; |
| 962 | yyRelMonth = 0; |
| 963 | yyHaveDate = 0; |
| 964 | yyHaveDay = 0; |
| 965 | yyHaveRel = 0; |
| 966 | yyHaveTime = 0; |
| 967 | yyHaveZone = 0; |
| 968 | |
| 969 | if (yyparse() |
| 970 | || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) |
| 971 | return -1; |
| 972 | |
| 973 | if (yyHaveDate || yyHaveTime || yyHaveDay) { |
| 974 | Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, |
| 975 | yyMeridian, yyDSTmode); |
| 976 | if (Start < 0) |
| 977 | return -1; |
| 978 | } |
| 979 | else { |
| 980 | Start = now; |
| 981 | if (!yyHaveRel) |
| 982 | Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec; |
| 983 | } |
| 984 | |
| 985 | Start += yyRelSeconds; |
| 986 | Start += RelativeMonth(Start, yyRelMonth); |
| 987 | |
| 988 | if (yyHaveDay && !yyHaveDate) { |
| 989 | tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); |
| 990 | Start += tod; |
| 991 | } |
| 992 | |
| 993 | |
| 994 | |
| 995 | return Start == -1 ? 0 : Start; |
| 996 | } |
| 997 | |
| 998 | |
| 999 | #if defined(TEST) |
| 1000 | |
| 1001 | |
| 1002 | int |
| 1003 | main(ac, av) |
| 1004 | int ac; |
| 1005 | char *av[]; |
| 1006 | { |
| 1007 | char buff[128]; |
| 1008 | time_t d; |
| 1009 | |
| 1010 | (void)printf("Enter date, or blank line to exit.\n\t> "); |
| 1011 | (void)fflush(stdout); |
| 1012 | while (gets(buff) && buff[0]) { |
| 1013 | d = get_date(buff); |
| 1014 | if (d == -1) |
| 1015 | (void)printf("Bad format - couldn't convert.\n"); |
| 1016 | else |
| 1017 | (void)printf("%s", ctime(&d)); |
| 1018 | (void)printf("\t> "); |
| 1019 | (void)fflush(stdout); |
| 1020 | } |
| 1021 | exit(0); |
| 1022 | |
| 1023 | } |
| 1024 | #endif /* defined(TEST) */ |
| 1025 | #line 1018 "y.tab.c" |
| 1026 | |
| 1027 | static int yygrowstack(void) |
| 1028 | { |
| 1029 | unsigned int newsize; |
| 1030 | long sslen; |
| 1031 | short *newss; |
| 1032 | YYSTYPE *newvs; |
| 1033 | |
| 1034 | if ((newsize = yystacksize) == 0) |
| 17 | | Assuming the condition is false | |
|
| |
| 1035 | newsize = YYINITSTACKSIZE; |
| 1036 | else if (newsize >= YYMAXDEPTH) |
| 19 | | Assuming 'newsize' is < YYMAXDEPTH | |
|
| |
| 1037 | return -1; |
| 1038 | else if ((newsize *= 2) > YYMAXDEPTH) |
| 21 | | Assuming the condition is false | |
|
| |
| 1039 | newsize = YYMAXDEPTH; |
| 1040 | sslen = yyssp - yyss; |
| 1041 | #ifdef SIZE_MAX |
| 1042 | #define YY_SIZE_MAX SIZE_MAX |
| 1043 | #else |
| 1044 | #define YY_SIZE_MAX 0xffffffffU |
| 1045 | #endif |
| 1046 | if (newsize && YY_SIZE_MAX / newsize < sizeof *newss) |
| 23 | | Assuming 'newsize' is 0 | |
|
| 1047 | goto bail; |
| 1048 | newss = (short *)realloc(yyss, newsize * sizeof *newss); |
| |
| 1049 | if (newss == NULL) |
| 25 | | Assuming 'newss' is equal to NULL | |
|
| |
| 1050 | goto bail; |
| 27 | | Control jumps to line 1064 | |
|
| 1051 | yyss = newss; |
| 1052 | yyssp = newss + sslen; |
| 1053 | if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs) |
| 1054 | goto bail; |
| 1055 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); |
| 1056 | if (newvs == NULL) |
| 1057 | goto bail; |
| 1058 | yyvs = newvs; |
| 1059 | yyvsp = newvs + sslen; |
| 1060 | yystacksize = newsize; |
| 1061 | yysslim = yyss + newsize - 1; |
| 1062 | return 0; |
| 1063 | bail: |
| 1064 | if (yyss) |
| |
| 1065 | free(yyss); |
| 29 | | Attempt to free released memory |
|
| 1066 | if (yyvs) |
| 1067 | free(yyvs); |
| 1068 | yyss = yyssp = NULL; |
| 1069 | yyvs = yyvsp = NULL; |
| 1070 | yystacksize = 0; |
| 1071 | return -1; |
| 1072 | } |
| 1073 | |
| 1074 | #define YYABORT goto yyabort |
| 1075 | #define YYREJECT goto yyabort |
| 1076 | #define YYACCEPT goto yyaccept |
| 1077 | #define YYERROR goto yyerrlab |
| 1078 | int |
| 1079 | yyparse(void) |
| 1080 | { |
| 1081 | int yym, yyn, yystate; |
| 1082 | #if YYDEBUG |
| 1083 | const char *yys; |
| 1084 | |
| 1085 | if ((yys = getenv("YYDEBUG"))) |
| 1086 | { |
| 1087 | yyn = *yys; |
| 1088 | if (yyn >= '0' && yyn <= '9') |
| 1089 | yydebug = yyn - '0'; |
| 1090 | } |
| 1091 | #endif /* YYDEBUG */ |
| 1092 | |
| 1093 | yynerrs = 0; |
| 1094 | yyerrflag = 0; |
| 1095 | yychar = (-1); |
| 1096 | |
| 1097 | if (yyss == NULL && yygrowstack()) goto yyoverflow; |
| 1 | Assuming 'yyss' is not equal to NULL | |
|
| 1098 | yyssp = yyss; |
| 1099 | yyvsp = yyvs; |
| 1100 | *yyssp = yystate = 0; |
| 1101 | |
| 1102 | yyloop: |
| 1103 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; |
| |
| 3 | | Control jumps to line 1210 | |
|
| |
| 1104 | if (yychar < 0) |
| |
| 1105 | { |
| 1106 | if ((yychar = yylex()) < 0) yychar = 0; |
| 1107 | #if YYDEBUG |
| 1108 | if (yydebug) |
| 1109 | { |
| 1110 | yys = 0; |
| 1111 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
| 1112 | if (!yys) yys = "illegal-symbol"; |
| 1113 | printf("%sdebug: state %d, reading %d (%s)\n", |
| 1114 | YYPREFIX, yystate, yychar, yys); |
| 1115 | } |
| 1116 | #endif |
| 1117 | } |
| 1118 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && |
| 13 | | Assuming 'yyn' is not equal to 0 | |
|
| |
| 1119 | yyn <= YYTABLESIZE && yycheck[yyn] == yychar) |
| 1120 | { |
| 1121 | #if YYDEBUG |
| 1122 | if (yydebug) |
| 1123 | printf("%sdebug: state %d, shifting to state %d\n", |
| 1124 | YYPREFIX, yystate, yytable[yyn]); |
| 1125 | #endif |
| 1126 | if (yyssp >= yysslim && yygrowstack()) |
| 15 | | Assuming 'yyssp' is >= 'yysslim' | |
|
| |
| 1127 | { |
| 1128 | goto yyoverflow; |
| 1129 | } |
| 1130 | *++yyssp = yystate = yytable[yyn]; |
| 1131 | *++yyvsp = yylval; |
| 1132 | yychar = (-1); |
| 1133 | if (yyerrflag > 0) --yyerrflag; |
| 1134 | goto yyloop; |
| 1135 | } |
| 1136 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && |
| 1137 | yyn <= YYTABLESIZE && yycheck[yyn] == yychar) |
| 1138 | { |
| 1139 | yyn = yytable[yyn]; |
| 1140 | goto yyreduce; |
| 1141 | } |
| 1142 | if (yyerrflag) goto yyinrecovery; |
| 1143 | #if defined(__GNUC__) |
| 1144 | goto yynewerror; |
| 1145 | #endif |
| 1146 | yynewerror: |
| 1147 | yyerror("syntax error"); |
| 1148 | #if defined(__GNUC__) |
| 1149 | goto yyerrlab; |
| 1150 | #endif |
| 1151 | yyerrlab: |
| 1152 | ++yynerrs; |
| 1153 | yyinrecovery: |
| 1154 | if (yyerrflag < 3) |
| 1155 | { |
| 1156 | yyerrflag = 3; |
| 1157 | for (;;) |
| 1158 | { |
| 1159 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && |
| 1160 | yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) |
| 1161 | { |
| 1162 | #if YYDEBUG |
| 1163 | if (yydebug) |
| 1164 | printf("%sdebug: state %d, error recovery shifting\ |
| 1165 | to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); |
| 1166 | #endif |
| 1167 | if (yyssp >= yysslim && yygrowstack()) |
| 1168 | { |
| 1169 | goto yyoverflow; |
| 1170 | } |
| 1171 | *++yyssp = yystate = yytable[yyn]; |
| 1172 | *++yyvsp = yylval; |
| 1173 | goto yyloop; |
| 1174 | } |
| 1175 | else |
| 1176 | { |
| 1177 | #if YYDEBUG |
| 1178 | if (yydebug) |
| 1179 | printf("%sdebug: error recovery discarding state %d\n", |
| 1180 | YYPREFIX, *yyssp); |
| 1181 | #endif |
| 1182 | if (yyssp <= yyss) goto yyabort; |
| 1183 | --yyssp; |
| 1184 | --yyvsp; |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | else |
| 1189 | { |
| 1190 | if (yychar == 0) goto yyabort; |
| 1191 | #if YYDEBUG |
| 1192 | if (yydebug) |
| 1193 | { |
| 1194 | yys = 0; |
| 1195 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
| 1196 | if (!yys) yys = "illegal-symbol"; |
| 1197 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", |
| 1198 | YYPREFIX, yystate, yychar, yys); |
| 1199 | } |
| 1200 | #endif |
| 1201 | yychar = (-1); |
| 1202 | goto yyloop; |
| 1203 | } |
| 1204 | yyreduce: |
| 1205 | #if YYDEBUG |
| 1206 | if (yydebug) |
| 1207 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", |
| 1208 | YYPREFIX, yystate, yyn, yyrule[yyn]); |
| 1209 | #endif |
| 1210 | yym = yylen[yyn]; |
| 1211 | if (yym) |
| |
| 1212 | yyval = yyvsp[1-yym]; |
| 1213 | else |
| 1214 | memset(&yyval, 0, sizeof yyval); |
| 1215 | switch (yyn) |
| 5 | | 'Default' branch taken. Execution continues on line 1509 | |
|
| 1216 | { |
| 1217 | case 3: |
| 1218 | #line 163 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1219 | { |
| 1220 | yyHaveTime++; |
| 1221 | } |
| 1222 | break; |
| 1223 | case 4: |
| 1224 | #line 166 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1225 | { |
| 1226 | yyHaveZone++; |
| 1227 | } |
| 1228 | break; |
| 1229 | case 5: |
| 1230 | #line 169 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1231 | { |
| 1232 | yyHaveDate++; |
| 1233 | } |
| 1234 | break; |
| 1235 | case 6: |
| 1236 | #line 172 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1237 | { |
| 1238 | yyHaveDay++; |
| 1239 | } |
| 1240 | break; |
| 1241 | case 7: |
| 1242 | #line 175 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1243 | { |
| 1244 | yyHaveRel++; |
| 1245 | } |
| 1246 | break; |
| 1247 | case 9: |
| 1248 | #line 181 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1249 | { |
| 1250 | yyHour = yyvsp[-1].Number; |
| 1251 | yyMinutes = 0; |
| 1252 | yySeconds = 0; |
| 1253 | yyMeridian = yyvsp[0].Meridian; |
| 1254 | } |
| 1255 | break; |
| 1256 | case 10: |
| 1257 | #line 187 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1258 | { |
| 1259 | yyHour = yyvsp[-3].Number; |
| 1260 | yyMinutes = yyvsp[-1].Number; |
| 1261 | yySeconds = 0; |
| 1262 | yyMeridian = yyvsp[0].Meridian; |
| 1263 | } |
| 1264 | break; |
| 1265 | case 11: |
| 1266 | #line 193 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1267 | { |
| 1268 | yyHour = yyvsp[-3].Number; |
| 1269 | yyMinutes = yyvsp[-1].Number; |
| 1270 | yyMeridian = MER24; |
| 1271 | yyDSTmode = DSToff; |
| 1272 | yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60); |
| 1273 | } |
| 1274 | break; |
| 1275 | case 12: |
| 1276 | #line 200 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1277 | { |
| 1278 | yyHour = yyvsp[-5].Number; |
| 1279 | yyMinutes = yyvsp[-3].Number; |
| 1280 | yySeconds = yyvsp[-1].Number; |
| 1281 | yyMeridian = yyvsp[0].Meridian; |
| 1282 | } |
| 1283 | break; |
| 1284 | case 13: |
| 1285 | #line 206 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1286 | { |
| 1287 | yyHour = yyvsp[-5].Number; |
| 1288 | yyMinutes = yyvsp[-3].Number; |
| 1289 | yySeconds = yyvsp[-1].Number; |
| 1290 | yyMeridian = MER24; |
| 1291 | yyDSTmode = DSToff; |
| 1292 | yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60); |
| 1293 | } |
| 1294 | break; |
| 1295 | case 14: |
| 1296 | #line 216 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1297 | { |
| 1298 | yyTimezone = yyvsp[0].Number; |
| 1299 | yyDSTmode = DSToff; |
| 1300 | } |
| 1301 | break; |
| 1302 | case 15: |
| 1303 | #line 220 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1304 | { |
| 1305 | yyTimezone = yyvsp[0].Number; |
| 1306 | yyDSTmode = DSTon; |
| 1307 | } |
| 1308 | break; |
| 1309 | case 16: |
| 1310 | #line 225 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1311 | { |
| 1312 | yyTimezone = yyvsp[-1].Number; |
| 1313 | yyDSTmode = DSTon; |
| 1314 | } |
| 1315 | break; |
| 1316 | case 17: |
| 1317 | #line 231 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1318 | { |
| 1319 | yyDayOrdinal = 1; |
| 1320 | yyDayNumber = yyvsp[0].Number; |
| 1321 | } |
| 1322 | break; |
| 1323 | case 18: |
| 1324 | #line 235 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1325 | { |
| 1326 | yyDayOrdinal = 1; |
| 1327 | yyDayNumber = yyvsp[-1].Number; |
| 1328 | } |
| 1329 | break; |
| 1330 | case 19: |
| 1331 | #line 239 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1332 | { |
| 1333 | yyDayOrdinal = yyvsp[-1].Number; |
| 1334 | yyDayNumber = yyvsp[0].Number; |
| 1335 | } |
| 1336 | break; |
| 1337 | case 20: |
| 1338 | #line 245 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1339 | { |
| 1340 | yyMonth = yyvsp[-2].Number; |
| 1341 | yyDay = yyvsp[0].Number; |
| 1342 | } |
| 1343 | break; |
| 1344 | case 21: |
| 1345 | #line 249 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1346 | { |
| 1347 | if (yyvsp[-4].Number >= 100) { |
| 1348 | yyYear = yyvsp[-4].Number; |
| 1349 | yyMonth = yyvsp[-2].Number; |
| 1350 | yyDay = yyvsp[0].Number; |
| 1351 | } else { |
| 1352 | yyMonth = yyvsp[-4].Number; |
| 1353 | yyDay = yyvsp[-2].Number; |
| 1354 | yyYear = yyvsp[0].Number; |
| 1355 | } |
| 1356 | } |
| 1357 | break; |
| 1358 | case 22: |
| 1359 | #line 260 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1360 | { |
| 1361 | |
| 1362 | yyYear = yyvsp[-2].Number; |
| 1363 | yyMonth = -yyvsp[-1].Number; |
| 1364 | yyDay = -yyvsp[0].Number; |
| 1365 | } |
| 1366 | break; |
| 1367 | case 23: |
| 1368 | #line 266 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1369 | { |
| 1370 | |
| 1371 | yyDay = yyvsp[-2].Number; |
| 1372 | yyMonth = yyvsp[-1].Number; |
| 1373 | yyYear = -yyvsp[0].Number; |
| 1374 | } |
| 1375 | break; |
| 1376 | case 24: |
| 1377 | #line 272 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1378 | { |
| 1379 | yyMonth = yyvsp[-1].Number; |
| 1380 | yyDay = yyvsp[0].Number; |
| 1381 | } |
| 1382 | break; |
| 1383 | case 25: |
| 1384 | #line 276 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1385 | { |
| 1386 | yyMonth = yyvsp[-3].Number; |
| 1387 | yyDay = yyvsp[-2].Number; |
| 1388 | yyYear = yyvsp[0].Number; |
| 1389 | } |
| 1390 | break; |
| 1391 | case 26: |
| 1392 | #line 281 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1393 | { |
| 1394 | yyMonth = yyvsp[0].Number; |
| 1395 | yyDay = yyvsp[-1].Number; |
| 1396 | } |
| 1397 | break; |
| 1398 | case 27: |
| 1399 | #line 285 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1400 | { |
| 1401 | yyMonth = yyvsp[-1].Number; |
| 1402 | yyDay = yyvsp[-2].Number; |
| 1403 | yyYear = yyvsp[0].Number; |
| 1404 | } |
| 1405 | break; |
| 1406 | case 28: |
| 1407 | #line 292 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1408 | { |
| 1409 | yyRelSeconds = -yyRelSeconds; |
| 1410 | yyRelMonth = -yyRelMonth; |
| 1411 | } |
| 1412 | break; |
| 1413 | case 30: |
| 1414 | #line 299 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1415 | { |
| 1416 | yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L; |
| 1417 | } |
| 1418 | break; |
| 1419 | case 31: |
| 1420 | #line 302 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1421 | { |
| 1422 | yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L; |
| 1423 | } |
| 1424 | break; |
| 1425 | case 32: |
| 1426 | #line 305 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1427 | { |
| 1428 | yyRelSeconds += yyvsp[0].Number * 60L; |
| 1429 | } |
| 1430 | break; |
| 1431 | case 33: |
| 1432 | #line 308 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1433 | { |
| 1434 | yyRelSeconds += yyvsp[-1].Number; |
| 1435 | } |
| 1436 | break; |
| 1437 | case 34: |
| 1438 | #line 311 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1439 | { |
| 1440 | yyRelSeconds += yyvsp[-1].Number; |
| 1441 | } |
| 1442 | break; |
| 1443 | case 35: |
| 1444 | #line 314 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1445 | { |
| 1446 | yyRelSeconds++; |
| 1447 | } |
| 1448 | break; |
| 1449 | case 36: |
| 1450 | #line 317 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1451 | { |
| 1452 | yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; |
| 1453 | } |
| 1454 | break; |
| 1455 | case 37: |
| 1456 | #line 320 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1457 | { |
| 1458 | yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; |
| 1459 | } |
| 1460 | break; |
| 1461 | case 38: |
| 1462 | #line 323 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1463 | { |
| 1464 | yyRelMonth += yyvsp[0].Number; |
| 1465 | } |
| 1466 | break; |
| 1467 | case 39: |
| 1468 | #line 328 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1469 | { |
| 1470 | if (yyHaveTime && yyHaveDate && !yyHaveRel) |
| 1471 | yyYear = yyvsp[0].Number; |
| 1472 | else { |
| 1473 | if(yyvsp[0].Number>10000) { |
| 1474 | yyHaveDate++; |
| 1475 | yyDay= (yyvsp[0].Number)%100; |
| 1476 | yyMonth= (yyvsp[0].Number/100)%100; |
| 1477 | yyYear = yyvsp[0].Number/10000; |
| 1478 | } |
| 1479 | else { |
| 1480 | yyHaveTime++; |
| 1481 | if (yyvsp[0].Number < 100) { |
| 1482 | yyHour = yyvsp[0].Number; |
| 1483 | yyMinutes = 0; |
| 1484 | } |
| 1485 | else { |
| 1486 | yyHour = yyvsp[0].Number / 100; |
| 1487 | yyMinutes = yyvsp[0].Number % 100; |
| 1488 | } |
| 1489 | yySeconds = 0; |
| 1490 | yyMeridian = MER24; |
| 1491 | } |
| 1492 | } |
| 1493 | } |
| 1494 | break; |
| 1495 | case 40: |
| 1496 | #line 355 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1497 | { |
| 1498 | yyval.Meridian = MER24; |
| 1499 | } |
| 1500 | break; |
| 1501 | case 41: |
| 1502 | #line 358 "/usr/src/gnu/usr.bin/cvs/lib/getdate.y" |
| 1503 | { |
| 1504 | yyval.Meridian = yyvsp[0].Meridian; |
| 1505 | } |
| 1506 | break; |
| 1507 | #line 1500 "y.tab.c" |
| 1508 | } |
| 1509 | yyssp -= yym; |
| 1510 | yystate = *yyssp; |
| 1511 | yyvsp -= yym; |
| 1512 | yym = yylhs[yyn]; |
| 1513 | if (yystate == 0 && yym == 0) |
| |
| 1514 | { |
| 1515 | #if YYDEBUG |
| 1516 | if (yydebug) |
| 1517 | printf("%sdebug: after reduction, shifting from state 0 to\ |
| 1518 | state %d\n", YYPREFIX, YYFINAL); |
| 1519 | #endif |
| 1520 | yystate = YYFINAL; |
| 1521 | *++yyssp = YYFINAL; |
| 1522 | *++yyvsp = yyval; |
| 1523 | if (yychar < 0) |
| |
| 1524 | { |
| 1525 | if ((yychar = yylex()) < 0) yychar = 0; |
| |
| 1526 | #if YYDEBUG |
| 1527 | if (yydebug) |
| 1528 | { |
| 1529 | yys = 0; |
| 1530 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
| 1531 | if (!yys) yys = "illegal-symbol"; |
| 1532 | printf("%sdebug: state %d, reading %d (%s)\n", |
| 1533 | YYPREFIX, YYFINAL, yychar, yys); |
| 1534 | } |
| 1535 | #endif |
| 1536 | } |
| 1537 | if (yychar == 0) goto yyaccept; |
| |
| 1538 | goto yyloop; |
| 10 | | Control jumps to line 1103 | |
|
| 1539 | } |
| 1540 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && |
| 1541 | yyn <= YYTABLESIZE && yycheck[yyn] == yystate) |
| 1542 | yystate = yytable[yyn]; |
| 1543 | else |
| 1544 | yystate = yydgoto[yym]; |
| 1545 | #if YYDEBUG |
| 1546 | if (yydebug) |
| 1547 | printf("%sdebug: after reduction, shifting from state %d \ |
| 1548 | to state %d\n", YYPREFIX, *yyssp, yystate); |
| 1549 | #endif |
| 1550 | if (yyssp >= yysslim && yygrowstack()) |
| 1551 | { |
| 1552 | goto yyoverflow; |
| 1553 | } |
| 1554 | *++yyssp = yystate; |
| 1555 | *++yyvsp = yyval; |
| 1556 | goto yyloop; |
| 1557 | yyoverflow: |
| 1558 | yyerror("yacc stack overflow"); |
| 1559 | yyabort: |
| 1560 | if (yyss) |
| 1561 | free(yyss); |
| 1562 | if (yyvs) |
| 1563 | free(yyvs); |
| 1564 | yyss = yyssp = NULL; |
| 1565 | yyvs = yyvsp = NULL; |
| 1566 | yystacksize = 0; |
| 1567 | return (1); |
| 1568 | yyaccept: |
| 1569 | if (yyss) |
| 1570 | free(yyss); |
| 1571 | if (yyvs) |
| 1572 | free(yyvs); |
| 1573 | yyss = yyssp = NULL; |
| 1574 | yyvs = yyvsp = NULL; |
| 1575 | yystacksize = 0; |
| 1576 | return (0); |
| 1577 | } |