00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #define YYBISON 1
00038
00039
00040 #define YYSKELETON_NAME "yacc.c"
00041
00042
00043 #define YYPURE 1
00044
00045
00046 #define YYLSP_NEEDED 0
00047
00048
00049
00050
00051 #ifndef YYTOKENTYPE
00052 # define YYTOKENTYPE
00053
00054
00055 enum yytokentype {
00056 tAGO = 258,
00057 tDST = 259,
00058 tDAY = 260,
00059 tDAY_UNIT = 261,
00060 tDAYZONE = 262,
00061 tHOUR_UNIT = 263,
00062 tLOCAL_ZONE = 264,
00063 tMERIDIAN = 265,
00064 tMINUTE_UNIT = 266,
00065 tMONTH = 267,
00066 tMONTH_UNIT = 268,
00067 tSEC_UNIT = 269,
00068 tYEAR_UNIT = 270,
00069 tZONE = 271,
00070 tSNUMBER = 272,
00071 tUNUMBER = 273
00072 };
00073 #endif
00074 #define tAGO 258
00075 #define tDST 259
00076 #define tDAY 260
00077 #define tDAY_UNIT 261
00078 #define tDAYZONE 262
00079 #define tHOUR_UNIT 263
00080 #define tLOCAL_ZONE 264
00081 #define tMERIDIAN 265
00082 #define tMINUTE_UNIT 266
00083 #define tMONTH 267
00084 #define tMONTH_UNIT 268
00085 #define tSEC_UNIT 269
00086 #define tYEAR_UNIT 270
00087 #define tZONE 271
00088 #define tSNUMBER 272
00089 #define tUNUMBER 273
00090
00091
00092
00093
00094
00095 #line 1 "getdate.y"
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #ifdef HAVE_CONFIG_H
00124 # include <config.h>
00125 # ifdef HAVE_ALLOCA_H
00126 # include <alloca.h>
00127 # endif
00128 #endif
00129
00130
00131
00132
00133
00134
00135
00136 #ifdef emacs
00137 # undef static
00138 #endif
00139
00140 #include <ctype.h>
00141 #include <string.h>
00142
00143 #if HAVE_STDLIB_H
00144 # include <stdlib.h>
00145 #endif
00146
00147 #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
00148 # define IN_CTYPE_DOMAIN(c) 1
00149 #else
00150 # define IN_CTYPE_DOMAIN(c) isascii (c)
00151 #endif
00152
00153 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
00154 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
00155 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
00156 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
00157
00158
00159
00160
00161
00162
00163
00164
00165 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
00166
00167 #if STDC_HEADERS || HAVE_STRING_H
00168 # include <string.h>
00169 #endif
00170
00171 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
00172 # define __attribute__(x)
00173 #endif
00174
00175 #ifndef ATTRIBUTE_UNUSED
00176 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
00177 #endif
00178
00179 #define EPOCH_YEAR 1970
00180 #define TM_YEAR_BASE 1900
00181
00182 #define HOUR(x) ((x) * 60)
00183
00184
00185
00186 typedef struct
00187 {
00188 int value;
00189 int digits;
00190 } textint;
00191
00192
00193 typedef struct
00194 {
00195 char const *name;
00196 int type;
00197 int value;
00198 } table;
00199
00200
00201 enum { MERam, MERpm, MER24 };
00202
00203
00204 typedef struct
00205 {
00206
00207 const char *input;
00208
00209
00210 int day_ordinal;
00211
00212
00213 int day_number;
00214
00215
00216 int local_isdst;
00217
00218
00219 int time_zone;
00220
00221
00222 int meridian;
00223
00224
00225 textint year;
00226 int month;
00227 int day;
00228 int hour;
00229 int minutes;
00230 int seconds;
00231
00232
00233 int rel_year;
00234 int rel_month;
00235 int rel_day;
00236 int rel_hour;
00237 int rel_minutes;
00238 int rel_seconds;
00239
00240
00241 int dates_seen;
00242 int days_seen;
00243 int local_zones_seen;
00244 int rels_seen;
00245 int times_seen;
00246 int zones_seen;
00247
00248
00249 table local_time_zone_table[3];
00250 } parser_control;
00251
00252 #define PC (* (parser_control *) parm)
00253 #define YYLEX_PARAM parm
00254 #define YYPARSE_PARAM parm
00255
00256 static int yyerror ();
00257 static int yylex ();
00258
00259
00260
00261
00262 #ifndef YYDEBUG
00263 # define YYDEBUG 0
00264 #endif
00265
00266
00267 #ifdef YYERROR_VERBOSE
00268 # undef YYERROR_VERBOSE
00269 # define YYERROR_VERBOSE 1
00270 #else
00271 # define YYERROR_VERBOSE 0
00272 #endif
00273
00274 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
00275 #line 172 "getdate.y"
00276 typedef union YYSTYPE {
00277 int intval;
00278 textint textintval;
00279 } YYSTYPE;
00280
00281 #line 281 "getdate.c"
00282 # define yystype YYSTYPE
00283 # define YYSTYPE_IS_DECLARED 1
00284 # define YYSTYPE_IS_TRIVIAL 1
00285 #endif
00286
00287
00288
00289
00290
00291
00292
00293 #line 293 "getdate.c"
00294
00295 #if ! defined (yyoverflow) || YYERROR_VERBOSE
00296
00297
00298
00299 # if YYSTACK_USE_ALLOCA
00300 # define YYSTACK_ALLOC alloca
00301 # else
00302 # ifndef YYSTACK_USE_ALLOCA
00303 # if defined (alloca) || defined (_ALLOCA_H)
00304 # define YYSTACK_ALLOC alloca
00305 # else
00306 # ifdef __GNUC__
00307 # define YYSTACK_ALLOC __builtin_alloca
00308 # endif
00309 # endif
00310 # endif
00311 # endif
00312
00313 # ifdef YYSTACK_ALLOC
00314
00315 # define YYSTACK_FREE(Ptr) do { ; } while (0)
00316 # else
00317 # if defined (__STDC__) || defined (__cplusplus)
00318 # include <stdlib.h>
00319 # define YYSIZE_T size_t
00320 # endif
00321 # define YYSTACK_ALLOC malloc
00322 # define YYSTACK_FREE free
00323 # endif
00324 #endif
00325
00326
00327 #if (! defined (yyoverflow) \
00328 && (! defined (__cplusplus) \
00329 || (YYSTYPE_IS_TRIVIAL)))
00330
00331
00332 union yyalloc
00333 {
00334 short yyss;
00335 YYSTYPE yyvs;
00336 };
00337
00338
00339 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00340
00341
00342
00343 # define YYSTACK_BYTES(N) \
00344 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
00345 + YYSTACK_GAP_MAXIMUM)
00346
00347
00348
00349 # ifndef YYCOPY
00350 # if 1 < __GNUC__
00351 # define YYCOPY(To, From, Count) \
00352 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00353 # else
00354 # define YYCOPY(To, From, Count) \
00355 do \
00356 { \
00357 register YYSIZE_T yyi; \
00358 for (yyi = 0; yyi < (Count); yyi++) \
00359 (To)[yyi] = (From)[yyi]; \
00360 } \
00361 while (0)
00362 # endif
00363 # endif
00364
00365
00366
00367
00368
00369
00370 # define YYSTACK_RELOCATE(Stack) \
00371 do \
00372 { \
00373 YYSIZE_T yynewbytes; \
00374 YYCOPY (&yyptr->Stack, Stack, yysize); \
00375 Stack = &yyptr->Stack; \
00376 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00377 yyptr += yynewbytes / sizeof (*yyptr); \
00378 } \
00379 while (0)
00380
00381 #endif
00382
00383 #if defined (__STDC__) || defined (__cplusplus)
00384 typedef signed char yysigned_char;
00385 #else
00386 typedef short yysigned_char;
00387 #endif
00388
00389
00390 #define YYFINAL 2
00391
00392 #define YYLAST 52
00393
00394
00395 #define YYNTOKENS 22
00396
00397 #define YYNNTS 12
00398
00399 #define YYNRULES 54
00400
00401 #define YYNSTATES 64
00402
00403
00404 #define YYUNDEFTOK 2
00405 #define YYMAXUTOK 273
00406
00407 #define YYTRANSLATE(YYX) \
00408 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00409
00410
00411 static const unsigned char yytranslate[] =
00412 {
00413 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00417 2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
00418 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
00419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00438 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
00439 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
00440 15, 16, 17, 18
00441 };
00442
00443 #if YYDEBUG
00444
00445
00446 static const unsigned char yyprhs[] =
00447 {
00448 0, 0, 3, 4, 7, 9, 11, 13, 15, 17,
00449 19, 21, 24, 29, 34, 41, 48, 50, 53, 55,
00450 57, 60, 62, 65, 68, 72, 78, 82, 86, 89,
00451 94, 97, 101, 104, 106, 109, 112, 114, 117, 120,
00452 122, 125, 128, 130, 133, 136, 138, 141, 144, 146,
00453 149, 152, 154, 156, 157
00454 };
00455
00456
00457 static const yysigned_char yyrhs[] =
00458 {
00459 23, 0, -1, -1, 23, 24, -1, 25, -1, 26,
00460 -1, 27, -1, 29, -1, 28, -1, 30, -1, 32,
00461 -1, 18, 10, -1, 18, 19, 18, 33, -1, 18,
00462 19, 18, 17, -1, 18, 19, 18, 19, 18, 33,
00463 -1, 18, 19, 18, 19, 18, 17, -1, 9, -1,
00464 9, 4, -1, 16, -1, 7, -1, 16, 4, -1,
00465 5, -1, 5, 20, -1, 18, 5, -1, 18, 21,
00466 18, -1, 18, 21, 18, 21, 18, -1, 18, 17,
00467 17, -1, 18, 12, 17, -1, 12, 18, -1, 12,
00468 18, 20, 18, -1, 18, 12, -1, 18, 12, 18,
00469 -1, 31, 3, -1, 31, -1, 18, 15, -1, 17,
00470 15, -1, 15, -1, 18, 13, -1, 17, 13, -1,
00471 13, -1, 18, 6, -1, 17, 6, -1, 6, -1,
00472 18, 8, -1, 17, 8, -1, 8, -1, 18, 11,
00473 -1, 17, 11, -1, 11, -1, 18, 14, -1, 17,
00474 14, -1, 14, -1, 18, -1, -1, 10, -1
00475 };
00476
00477
00478 static const unsigned short yyrline[] =
00479 {
00480 0, 188, 188, 190, 194, 196, 198, 200, 202, 204,
00481 206, 210, 217, 224, 232, 239, 251, 253, 258, 260,
00482 262, 267, 272, 277, 285, 290, 310, 317, 325, 330,
00483 336, 341, 350, 359, 363, 365, 367, 369, 371, 373,
00484 375, 377, 379, 381, 383, 385, 387, 389, 391, 393,
00485 395, 397, 402, 439, 440
00486 };
00487 #endif
00488
00489 #if YYDEBUG || YYERROR_VERBOSE
00490
00491
00492 static const char *const yytname[] =
00493 {
00494 "$end", "error", "$undefined", "tAGO", "tDST", "tDAY", "tDAY_UNIT",
00495 "tDAYZONE", "tHOUR_UNIT", "tLOCAL_ZONE", "tMERIDIAN", "tMINUTE_UNIT",
00496 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tYEAR_UNIT", "tZONE", "tSNUMBER",
00497 "tUNUMBER", "':'", "','", "'/'", "$accept", "spec", "item", "time",
00498 "local_zone", "zone", "day", "date", "rel", "relunit", "number",
00499 "o_merid", 0
00500 };
00501 #endif
00502
00503 # ifdef YYPRINT
00504
00505
00506 static const unsigned short yytoknum[] =
00507 {
00508 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
00509 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
00510 44, 47
00511 };
00512 # endif
00513
00514
00515 static const unsigned char yyr1[] =
00516 {
00517 0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
00518 24, 25, 25, 25, 25, 25, 26, 26, 27, 27,
00519 27, 28, 28, 28, 29, 29, 29, 29, 29, 29,
00520 29, 29, 30, 30, 31, 31, 31, 31, 31, 31,
00521 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
00522 31, 31, 32, 33, 33
00523 };
00524
00525
00526 static const unsigned char yyr2[] =
00527 {
00528 0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
00529 1, 2, 4, 4, 6, 6, 1, 2, 1, 1,
00530 2, 1, 2, 2, 3, 5, 3, 3, 2, 4,
00531 2, 3, 2, 1, 2, 2, 1, 2, 2, 1,
00532 2, 2, 1, 2, 2, 1, 2, 2, 1, 2,
00533 2, 1, 1, 0, 1
00534 };
00535
00536
00537
00538
00539 static const unsigned char yydefact[] =
00540 {
00541 2, 0, 1, 21, 42, 19, 45, 16, 48, 0,
00542 39, 51, 36, 18, 0, 52, 3, 4, 5, 6,
00543 8, 7, 9, 33, 10, 22, 17, 28, 20, 41,
00544 44, 47, 38, 50, 35, 23, 40, 43, 11, 46,
00545 30, 37, 49, 34, 0, 0, 0, 32, 0, 27,
00546 31, 26, 53, 24, 29, 54, 13, 0, 12, 0,
00547 53, 25, 15, 14
00548 };
00549
00550
00551 static const yysigned_char yydefgoto[] =
00552 {
00553 -1, 1, 16, 17, 18, 19, 20, 21, 22, 23,
00554 24, 58
00555 };
00556
00557
00558
00559 #define YYPACT_NINF -17
00560 static const yysigned_char yypact[] =
00561 {
00562 -17, 0, -17, 1, -17, -17, -17, 19, -17, -14,
00563 -17, -17, -17, 32, 26, 14, -17, -17, -17, -17,
00564 -17, -17, -17, 27, -17, -17, -17, 22, -17, -17,
00565 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
00566 -16, -17, -17, -17, 29, 25, 30, -17, 31, -17,
00567 -17, -17, 28, 23, -17, -17, -17, 33, -17, 34,
00568 -7, -17, -17, -17
00569 };
00570
00571
00572 static const yysigned_char yypgoto[] =
00573 {
00574 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
00575 -17, -10
00576 };
00577
00578
00579
00580
00581
00582 #define YYTABLE_NINF -1
00583 static const unsigned char yytable[] =
00584 {
00585 2, 49, 50, 55, 27, 3, 4, 5, 6, 7,
00586 62, 8, 9, 10, 11, 12, 13, 14, 15, 35,
00587 36, 25, 37, 26, 38, 39, 40, 41, 42, 43,
00588 47, 44, 29, 45, 30, 46, 28, 31, 55, 32,
00589 33, 34, 48, 52, 59, 56, 51, 57, 53, 54,
00590 63, 60, 61
00591 };
00592
00593 static const unsigned char yycheck[] =
00594 {
00595 0, 17, 18, 10, 18, 5, 6, 7, 8, 9,
00596 17, 11, 12, 13, 14, 15, 16, 17, 18, 5,
00597 6, 20, 8, 4, 10, 11, 12, 13, 14, 15,
00598 3, 17, 6, 19, 8, 21, 4, 11, 10, 13,
00599 14, 15, 20, 18, 21, 17, 17, 19, 18, 18,
00600 60, 18, 18
00601 };
00602
00603
00604
00605 static const unsigned char yystos[] =
00606 {
00607 0, 23, 0, 5, 6, 7, 8, 9, 11, 12,
00608 13, 14, 15, 16, 17, 18, 24, 25, 26, 27,
00609 28, 29, 30, 31, 32, 20, 4, 18, 4, 6,
00610 8, 11, 13, 14, 15, 5, 6, 8, 10, 11,
00611 12, 13, 14, 15, 17, 19, 21, 3, 20, 17,
00612 18, 17, 18, 18, 18, 10, 17, 19, 33, 21,
00613 18, 18, 17, 33
00614 };
00615
00616 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
00617 # define YYSIZE_T __SIZE_TYPE__
00618 #endif
00619 #if ! defined (YYSIZE_T) && defined (size_t)
00620 # define YYSIZE_T size_t
00621 #endif
00622 #if ! defined (YYSIZE_T)
00623 # if defined (__STDC__) || defined (__cplusplus)
00624 # include <stddef.h>
00625 # define YYSIZE_T size_t
00626 # endif
00627 #endif
00628 #if ! defined (YYSIZE_T)
00629 # define YYSIZE_T unsigned int
00630 #endif
00631
00632 #define yyerrok (yyerrstatus = 0)
00633 #define yyclearin (yychar = YYEMPTY)
00634 #define YYEMPTY (-2)
00635 #define YYEOF 0
00636
00637 #define YYACCEPT goto yyacceptlab
00638 #define YYABORT goto yyabortlab
00639 #define YYERROR goto yyerrlab1
00640
00641
00642
00643
00644
00645
00646 #define YYFAIL goto yyerrlab
00647
00648 #define YYRECOVERING() (!!yyerrstatus)
00649
00650 #define YYBACKUP(Token, Value) \
00651 do \
00652 if (yychar == YYEMPTY && yylen == 1) \
00653 { \
00654 yychar = (Token); \
00655 yylval = (Value); \
00656 yytoken = YYTRANSLATE (yychar); \
00657 YYPOPSTACK; \
00658 goto yybackup; \
00659 } \
00660 else \
00661 { \
00662 yyerror ("syntax error: cannot back up");\
00663 YYERROR; \
00664 } \
00665 while (0)
00666
00667 #define YYTERROR 1
00668 #define YYERRCODE 256
00669
00670
00671
00672
00673 #ifndef YYLLOC_DEFAULT
00674 # define YYLLOC_DEFAULT(Current, Rhs, N) \
00675 Current.first_line = Rhs[1].first_line; \
00676 Current.first_column = Rhs[1].first_column; \
00677 Current.last_line = Rhs[N].last_line; \
00678 Current.last_column = Rhs[N].last_column;
00679 #endif
00680
00681
00682
00683 #ifdef YYLEX_PARAM
00684 # define YYLEX yylex (&yylval, YYLEX_PARAM)
00685 #else
00686 # define YYLEX yylex (&yylval)
00687 #endif
00688
00689
00690 #if YYDEBUG
00691
00692 # ifndef YYFPRINTF
00693 # include <stdio.h>
00694 # define YYFPRINTF fprintf
00695 # endif
00696
00697 # define YYDPRINTF(Args) \
00698 do { \
00699 if (yydebug) \
00700 YYFPRINTF Args; \
00701 } while (0)
00702
00703 # define YYDSYMPRINT(Args) \
00704 do { \
00705 if (yydebug) \
00706 yysymprint Args; \
00707 } while (0)
00708
00709 # define YYDSYMPRINTF(Title, Token, Value, Location) \
00710 do { \
00711 if (yydebug) \
00712 { \
00713 YYFPRINTF (stderr, "%s ", Title); \
00714 yysymprint (stderr, \
00715 Token, Value); \
00716 YYFPRINTF (stderr, "\n"); \
00717 } \
00718 } while (0)
00719
00720
00721
00722
00723
00724
00725 #if defined (__STDC__) || defined (__cplusplus)
00726 static void
00727 yy_stack_print (short *bottom, short *top)
00728 #else
00729 static void
00730 yy_stack_print (bottom, top)
00731 short *bottom;
00732 short *top;
00733 #endif
00734 {
00735 YYFPRINTF (stderr, "Stack now");
00736 for (; bottom <= top; ++bottom)
00737 YYFPRINTF (stderr, " %d", *bottom);
00738 YYFPRINTF (stderr, "\n");
00739 }
00740
00741 # define YY_STACK_PRINT(Bottom, Top) \
00742 do { \
00743 if (yydebug) \
00744 yy_stack_print ((Bottom), (Top)); \
00745 } while (0)
00746
00747
00748
00749
00750
00751
00752 #if defined (__STDC__) || defined (__cplusplus)
00753 static void
00754 yy_reduce_print (int yyrule)
00755 #else
00756 static void
00757 yy_reduce_print (yyrule)
00758 int yyrule;
00759 #endif
00760 {
00761 int yyi;
00762 unsigned int yylineno = yyrline[yyrule];
00763 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
00764 yyrule - 1, yylineno);
00765
00766 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
00767 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
00768 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
00769 }
00770
00771 # define YY_REDUCE_PRINT(Rule) \
00772 do { \
00773 if (yydebug) \
00774 yy_reduce_print (Rule); \
00775 } while (0)
00776
00777
00778
00779 int yydebug;
00780 #else
00781 # define YYDPRINTF(Args)
00782 # define YYDSYMPRINT(Args)
00783 # define YYDSYMPRINTF(Title, Token, Value, Location)
00784 # define YY_STACK_PRINT(Bottom, Top)
00785 # define YY_REDUCE_PRINT(Rule)
00786 #endif
00787
00788
00789
00790 #ifndef YYINITDEPTH
00791 # define YYINITDEPTH 200
00792 #endif
00793
00794
00795
00796
00797
00798
00799
00800
00801 #if YYMAXDEPTH == 0
00802 # undef YYMAXDEPTH
00803 #endif
00804
00805 #ifndef YYMAXDEPTH
00806 # define YYMAXDEPTH 10000
00807 #endif
00808
00809
00810
00811 #if YYERROR_VERBOSE
00812
00813 # ifndef yystrlen
00814 # if defined (__GLIBC__) && defined (_STRING_H)
00815 # define yystrlen strlen
00816 # else
00817
00818 static YYSIZE_T
00819 # if defined (__STDC__) || defined (__cplusplus)
00820 yystrlen (const char *yystr)
00821 # else
00822 yystrlen (yystr)
00823 const char *yystr;
00824 # endif
00825 {
00826 register const char *yys = yystr;
00827
00828 while (*yys++ != '\0')
00829 continue;
00830
00831 return yys - yystr - 1;
00832 }
00833 # endif
00834 # endif
00835
00836 # ifndef yystpcpy
00837 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
00838 # define yystpcpy stpcpy
00839 # else
00840
00841
00842 static char *
00843 # if defined (__STDC__) || defined (__cplusplus)
00844 yystpcpy (char *yydest, const char *yysrc)
00845 # else
00846 yystpcpy (yydest, yysrc)
00847 char *yydest;
00848 const char *yysrc;
00849 # endif
00850 {
00851 register char *yyd = yydest;
00852 register const char *yys = yysrc;
00853
00854 while ((*yyd++ = *yys++) != '\0')
00855 continue;
00856
00857 return yyd - 1;
00858 }
00859 # endif
00860 # endif
00861
00862 #endif
00863
00864
00865
00866 #if YYDEBUG
00867
00868
00869
00870
00871 #if defined (__STDC__) || defined (__cplusplus)
00872 static void
00873 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
00874 #else
00875 static void
00876 yysymprint (yyoutput, yytype, yyvaluep)
00877 FILE *yyoutput;
00878 int yytype;
00879 YYSTYPE *yyvaluep;
00880 #endif
00881 {
00882
00883 (void) yyvaluep;
00884
00885 if (yytype < YYNTOKENS)
00886 {
00887 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00888 # ifdef YYPRINT
00889 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00890 # endif
00891 }
00892 else
00893 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00894
00895 switch (yytype)
00896 {
00897 default:
00898 break;
00899 }
00900 YYFPRINTF (yyoutput, ")");
00901 }
00902
00903 #endif
00904
00905
00906
00907
00908 #if defined (__STDC__) || defined (__cplusplus)
00909 static void
00910 yydestruct (int yytype, YYSTYPE *yyvaluep)
00911 #else
00912 static void
00913 yydestruct (yytype, yyvaluep)
00914 int yytype;
00915 YYSTYPE *yyvaluep;
00916 #endif
00917 {
00918
00919 (void) yyvaluep;
00920
00921 switch (yytype)
00922 {
00923
00924 default:
00925 break;
00926 }
00927 }
00928
00929
00930
00931
00932 #ifdef YYPARSE_PARAM
00933 # if defined (__STDC__) || defined (__cplusplus)
00934 int yyparse (void *YYPARSE_PARAM);
00935 # else
00936 int yyparse ();
00937 # endif
00938 #else
00939 #if defined (__STDC__) || defined (__cplusplus)
00940 int yyparse (void);
00941 #else
00942 int yyparse ();
00943 #endif
00944 #endif
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955 #ifdef YYPARSE_PARAM
00956 # if defined (__STDC__) || defined (__cplusplus)
00957 int yyparse (void *YYPARSE_PARAM)
00958 # else
00959 int yyparse (YYPARSE_PARAM)
00960 void *YYPARSE_PARAM;
00961 # endif
00962 #else
00963 #if defined (__STDC__) || defined (__cplusplus)
00964 int
00965 yyparse (void)
00966 #else
00967 int
00968 yyparse ()
00969
00970 #endif
00971 #endif
00972 {
00973
00974 int yychar;
00975
00976
00977 YYSTYPE yylval;
00978
00979
00980 int yynerrs;
00981
00982 register int yystate;
00983 register int yyn;
00984 int yyresult;
00985
00986 int yyerrstatus;
00987
00988 int yytoken = 0;
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999 short yyssa[YYINITDEPTH];
01000 short *yyss = yyssa;
01001 register short *yyssp;
01002
01003
01004 YYSTYPE yyvsa[YYINITDEPTH];
01005 YYSTYPE *yyvs = yyvsa;
01006 register YYSTYPE *yyvsp;
01007
01008
01009
01010 #define YYPOPSTACK (yyvsp--, yyssp--)
01011
01012 YYSIZE_T yystacksize = YYINITDEPTH;
01013
01014
01015
01016 YYSTYPE yyval;
01017
01018
01019
01020
01021 int yylen;
01022
01023 YYDPRINTF ((stderr, "Starting parse\n"));
01024
01025 yystate = 0;
01026 yyerrstatus = 0;
01027 yynerrs = 0;
01028 yychar = YYEMPTY;
01029
01030
01031
01032
01033
01034
01035 yyssp = yyss;
01036 yyvsp = yyvs;
01037
01038 goto yysetstate;
01039
01040
01041
01042
01043 yynewstate:
01044
01045
01046
01047 yyssp++;
01048
01049 yysetstate:
01050 *yyssp = yystate;
01051
01052 if (yyss + yystacksize - 1 <= yyssp)
01053 {
01054
01055 YYSIZE_T yysize = yyssp - yyss + 1;
01056
01057 #ifdef yyoverflow
01058 {
01059
01060
01061
01062 YYSTYPE *yyvs1 = yyvs;
01063 short *yyss1 = yyss;
01064
01065
01066
01067
01068
01069
01070 yyoverflow ("parser stack overflow",
01071 &yyss1, yysize * sizeof (*yyssp),
01072 &yyvs1, yysize * sizeof (*yyvsp),
01073
01074 &yystacksize);
01075
01076 yyss = yyss1;
01077 yyvs = yyvs1;
01078 }
01079 #else
01080 # ifndef YYSTACK_RELOCATE
01081 goto yyoverflowlab;
01082 # else
01083
01084 if (YYMAXDEPTH <= yystacksize)
01085 goto yyoverflowlab;
01086 yystacksize *= 2;
01087 if (YYMAXDEPTH < yystacksize)
01088 yystacksize = YYMAXDEPTH;
01089
01090 {
01091 short *yyss1 = yyss;
01092 union yyalloc *yyptr =
01093 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01094 if (! yyptr)
01095 goto yyoverflowlab;
01096 YYSTACK_RELOCATE (yyss);
01097 YYSTACK_RELOCATE (yyvs);
01098
01099 # undef YYSTACK_RELOCATE
01100 if (yyss1 != yyssa)
01101 YYSTACK_FREE (yyss1);
01102 }
01103 # endif
01104 #endif
01105
01106 yyssp = yyss + yysize - 1;
01107 yyvsp = yyvs + yysize - 1;
01108
01109
01110 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01111 (unsigned long int) yystacksize));
01112
01113 if (yyss + yystacksize - 1 <= yyssp)
01114 YYABORT;
01115 }
01116
01117 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01118
01119 goto yybackup;
01120
01121
01122
01123
01124 yybackup:
01125
01126
01127
01128
01129
01130
01131
01132 yyn = yypact[yystate];
01133 if (yyn == YYPACT_NINF)
01134 goto yydefault;
01135
01136
01137
01138
01139 if (yychar == YYEMPTY)
01140 {
01141 YYDPRINTF ((stderr, "Reading a token: "));
01142 yychar = YYLEX;
01143 }
01144
01145 if (yychar <= YYEOF)
01146 {
01147 yychar = yytoken = YYEOF;
01148 YYDPRINTF ((stderr, "Now at end of input.\n"));
01149 }
01150 else
01151 {
01152 yytoken = YYTRANSLATE (yychar);
01153 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
01154 }
01155
01156
01157
01158 yyn += yytoken;
01159 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01160 goto yydefault;
01161 yyn = yytable[yyn];
01162 if (yyn <= 0)
01163 {
01164 if (yyn == 0 || yyn == YYTABLE_NINF)
01165 goto yyerrlab;
01166 yyn = -yyn;
01167 goto yyreduce;
01168 }
01169
01170 if (yyn == YYFINAL)
01171 YYACCEPT;
01172
01173
01174 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
01175
01176
01177 if (yychar != YYEOF)
01178 yychar = YYEMPTY;
01179
01180 *++yyvsp = yylval;
01181
01182
01183
01184
01185 if (yyerrstatus)
01186 yyerrstatus--;
01187
01188 yystate = yyn;
01189 goto yynewstate;
01190
01191
01192
01193
01194
01195 yydefault:
01196 yyn = yydefact[yystate];
01197 if (yyn == 0)
01198 goto yyerrlab;
01199 goto yyreduce;
01200
01201
01202
01203
01204
01205 yyreduce:
01206
01207 yylen = yyr2[yyn];
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217 yyval = yyvsp[1-yylen];
01218
01219
01220 YY_REDUCE_PRINT (yyn);
01221 switch (yyn)
01222 {
01223 case 4:
01224 #line 195 "getdate.y"
01225 { PC.times_seen++; }
01226 break;
01227
01228 case 5:
01229 #line 197 "getdate.y"
01230 { PC.local_zones_seen++; }
01231 break;
01232
01233 case 6:
01234 #line 199 "getdate.y"
01235 { PC.zones_seen++; }
01236 break;
01237
01238 case 7:
01239 #line 201 "getdate.y"
01240 { PC.dates_seen++; }
01241 break;
01242
01243 case 8:
01244 #line 203 "getdate.y"
01245 { PC.days_seen++; }
01246 break;
01247
01248 case 9:
01249 #line 205 "getdate.y"
01250 { PC.rels_seen++; }
01251 break;
01252
01253 case 11:
01254 #line 211 "getdate.y"
01255 {
01256 PC.hour = yyvsp[-1].textintval.value;
01257 PC.minutes = 0;
01258 PC.seconds = 0;
01259 PC.meridian = yyvsp[0].intval;
01260 }
01261 break;
01262
01263 case 12:
01264 #line 218 "getdate.y"
01265 {
01266 PC.hour = yyvsp[-3].textintval.value;
01267 PC.minutes = yyvsp[-1].textintval.value;
01268 PC.seconds = 0;
01269 PC.meridian = yyvsp[0].intval;
01270 }
01271 break;
01272
01273 case 13:
01274 #line 225 "getdate.y"
01275 {
01276 PC.hour = yyvsp[-3].textintval.value;
01277 PC.minutes = yyvsp[-1].textintval.value;
01278 PC.meridian = MER24;
01279 PC.zones_seen++;
01280 PC.time_zone = yyvsp[0].textintval.value % 100 + (yyvsp[0].textintval.value / 100) * 60;
01281 }
01282 break;
01283
01284 case 14:
01285 #line 233 "getdate.y"
01286 {
01287 PC.hour = yyvsp[-5].textintval.value;
01288 PC.minutes = yyvsp[-3].textintval.value;
01289 PC.seconds = yyvsp[-1].textintval.value;
01290 PC.meridian = yyvsp[0].intval;
01291 }
01292 break;
01293
01294 case 15:
01295 #line 240 "getdate.y"
01296 {
01297 PC.hour = yyvsp[-5].textintval.value;
01298 PC.minutes = yyvsp[-3].textintval.value;
01299 PC.seconds = yyvsp[-1].textintval.value;
01300 PC.meridian = MER24;
01301 PC.zones_seen++;
01302 PC.time_zone = yyvsp[0].textintval.value % 100 + (yyvsp[0].textintval.value / 100) * 60;
01303 }
01304 break;
01305
01306 case 16:
01307 #line 252 "getdate.y"
01308 { PC.local_isdst = yyvsp[0].intval; }
01309 break;
01310
01311 case 17:
01312 #line 254 "getdate.y"
01313 { PC.local_isdst = yyvsp[-1].intval < 0 ? 1 : yyvsp[-1].intval + 1; }
01314 break;
01315
01316 case 18:
01317 #line 259 "getdate.y"
01318 { PC.time_zone = yyvsp[0].intval; }
01319 break;
01320
01321 case 19:
01322 #line 261 "getdate.y"
01323 { PC.time_zone = yyvsp[0].intval + 60; }
01324 break;
01325
01326 case 20:
01327 #line 263 "getdate.y"
01328 { PC.time_zone = yyvsp[-1].intval + 60; }
01329 break;
01330
01331 case 21:
01332 #line 268 "getdate.y"
01333 {
01334 PC.day_ordinal = 1;
01335 PC.day_number = yyvsp[0].intval;
01336 }
01337 break;
01338
01339 case 22:
01340 #line 273 "getdate.y"
01341 {
01342 PC.day_ordinal = 1;
01343 PC.day_number = yyvsp[-1].intval;
01344 }
01345 break;
01346
01347 case 23:
01348 #line 278 "getdate.y"
01349 {
01350 PC.day_ordinal = yyvsp[-1].textintval.value;
01351 PC.day_number = yyvsp[0].intval;
01352 }
01353 break;
01354
01355 case 24:
01356 #line 286 "getdate.y"
01357 {
01358 PC.month = yyvsp[-2].textintval.value;
01359 PC.day = yyvsp[0].textintval.value;
01360 }
01361 break;
01362
01363 case 25:
01364 #line 291 "getdate.y"
01365 {
01366
01367
01368
01369
01370
01371 if (4 <= yyvsp[-4].textintval.digits)
01372 {
01373 PC.year = yyvsp[-4].textintval;
01374 PC.month = yyvsp[-2].textintval.value;
01375 PC.day = yyvsp[0].textintval.value;
01376 }
01377 else
01378 {
01379 PC.month = yyvsp[-4].textintval.value;
01380 PC.day = yyvsp[-2].textintval.value;
01381 PC.year = yyvsp[0].textintval;
01382 }
01383 }
01384 break;
01385
01386 case 26:
01387 #line 311 "getdate.y"
01388 {
01389
01390 PC.year = yyvsp[-2].textintval;
01391 PC.month = -yyvsp[-1].textintval.value;
01392 PC.day = -yyvsp[0].textintval.value;
01393 }
01394 break;
01395
01396 case 27:
01397 #line 318 "getdate.y"
01398 {
01399
01400 PC.day = yyvsp[-2].textintval.value;
01401 PC.month = yyvsp[-1].intval;
01402 PC.year.value = -yyvsp[0].textintval.value;
01403 PC.year.digits = yyvsp[0].textintval.digits;
01404 }
01405 break;
01406
01407 case 28:
01408 #line 326 "getdate.y"
01409 {
01410 PC.month = yyvsp[-1].intval;
01411 PC.day = yyvsp[0].textintval.value;
01412 }
01413 break;
01414
01415 case 29:
01416 #line 331 "getdate.y"
01417 {
01418 PC.month = yyvsp[-3].intval;
01419 PC.day = yyvsp[-2].textintval.value;
01420 PC.year = yyvsp[0].textintval;
01421 }
01422 break;
01423
01424 case 30:
01425 #line 337 "getdate.y"
01426 {
01427 PC.day = yyvsp[-1].textintval.value;
01428 PC.month = yyvsp[0].intval;
01429 }
01430 break;
01431
01432 case 31:
01433 #line 342 "getdate.y"
01434 {
01435 PC.day = yyvsp[-2].textintval.value;
01436 PC.month = yyvsp[-1].intval;
01437 PC.year = yyvsp[0].textintval;
01438 }
01439 break;
01440
01441 case 32:
01442 #line 351 "getdate.y"
01443 {
01444 PC.rel_seconds = -PC.rel_seconds;
01445 PC.rel_minutes = -PC.rel_minutes;
01446 PC.rel_hour = -PC.rel_hour;
01447 PC.rel_day = -PC.rel_day;
01448 PC.rel_month = -PC.rel_month;
01449 PC.rel_year = -PC.rel_year;
01450 }
01451 break;
01452
01453 case 34:
01454 #line 364 "getdate.y"
01455 { PC.rel_year += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01456 break;
01457
01458 case 35:
01459 #line 366 "getdate.y"
01460 { PC.rel_year += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01461 break;
01462
01463 case 36:
01464 #line 368 "getdate.y"
01465 { PC.rel_year += yyvsp[0].intval; }
01466 break;
01467
01468 case 37:
01469 #line 370 "getdate.y"
01470 { PC.rel_month += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01471 break;
01472
01473 case 38:
01474 #line 372 "getdate.y"
01475 { PC.rel_month += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01476 break;
01477
01478 case 39:
01479 #line 374 "getdate.y"
01480 { PC.rel_month += yyvsp[0].intval; }
01481 break;
01482
01483 case 40:
01484 #line 376 "getdate.y"
01485 { PC.rel_day += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01486 break;
01487
01488 case 41:
01489 #line 378 "getdate.y"
01490 { PC.rel_day += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01491 break;
01492
01493 case 42:
01494 #line 380 "getdate.y"
01495 { PC.rel_day += yyvsp[0].intval; }
01496 break;
01497
01498 case 43:
01499 #line 382 "getdate.y"
01500 { PC.rel_hour += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01501 break;
01502
01503 case 44:
01504 #line 384 "getdate.y"
01505 { PC.rel_hour += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01506 break;
01507
01508 case 45:
01509 #line 386 "getdate.y"
01510 { PC.rel_hour += yyvsp[0].intval; }
01511 break;
01512
01513 case 46:
01514 #line 388 "getdate.y"
01515 { PC.rel_minutes += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01516 break;
01517
01518 case 47:
01519 #line 390 "getdate.y"
01520 { PC.rel_minutes += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01521 break;
01522
01523 case 48:
01524 #line 392 "getdate.y"
01525 { PC.rel_minutes += yyvsp[0].intval; }
01526 break;
01527
01528 case 49:
01529 #line 394 "getdate.y"
01530 { PC.rel_seconds += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01531 break;
01532
01533 case 50:
01534 #line 396 "getdate.y"
01535 { PC.rel_seconds += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01536 break;
01537
01538 case 51:
01539 #line 398 "getdate.y"
01540 { PC.rel_seconds += yyvsp[0].intval; }
01541 break;
01542
01543 case 52:
01544 #line 403 "getdate.y"
01545 {
01546 if (PC.dates_seen
01547 && ! PC.rels_seen && (PC.times_seen || 2 < yyvsp[0].textintval.digits))
01548 PC.year = yyvsp[0].textintval;
01549 else
01550 {
01551 if (4 < yyvsp[0].textintval.digits)
01552 {
01553 PC.dates_seen++;
01554 PC.day = yyvsp[0].textintval.value % 100;
01555 PC.month = (yyvsp[0].textintval.value / 100) % 100;
01556 PC.year.value = yyvsp[0].textintval.value / 10000;
01557 PC.year.digits = yyvsp[0].textintval.digits - 4;
01558 }
01559 else
01560 {
01561 PC.times_seen++;
01562 if (yyvsp[0].textintval.digits <= 2)
01563 {
01564 PC.hour = yyvsp[0].textintval.value;
01565 PC.minutes = 0;
01566 }
01567 else
01568 {
01569 PC.hour = yyvsp[0].textintval.value / 100;
01570 PC.minutes = yyvsp[0].textintval.value % 100;
01571 }
01572 PC.seconds = 0;
01573 PC.meridian = MER24;
01574 }
01575 }
01576 }
01577 break;
01578
01579 case 53:
01580 #line 439 "getdate.y"
01581 { yyval.intval = MER24; }
01582 break;
01583
01584 case 54:
01585 #line 441 "getdate.y"
01586 { yyval.intval = yyvsp[0].intval; }
01587 break;
01588
01589
01590 }
01591
01592
01593 #line 1593 "getdate.c"
01594
01595 yyvsp -= yylen;
01596 yyssp -= yylen;
01597
01598
01599 YY_STACK_PRINT (yyss, yyssp);
01600
01601 *++yyvsp = yyval;
01602
01603
01604
01605
01606
01607
01608 yyn = yyr1[yyn];
01609
01610 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
01611 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01612 yystate = yytable[yystate];
01613 else
01614 yystate = yydefgoto[yyn - YYNTOKENS];
01615
01616 goto yynewstate;
01617
01618
01619
01620
01621
01622 yyerrlab:
01623
01624 if (!yyerrstatus)
01625 {
01626 ++yynerrs;
01627 #if YYERROR_VERBOSE
01628 yyn = yypact[yystate];
01629
01630 if (YYPACT_NINF < yyn && yyn < YYLAST)
01631 {
01632 YYSIZE_T yysize = 0;
01633 int yytype = YYTRANSLATE (yychar);
01634 char *yymsg;
01635 int yyx, yycount;
01636
01637 yycount = 0;
01638
01639
01640 for (yyx = yyn < 0 ? -yyn : 0;
01641 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
01642 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01643 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
01644 yysize += yystrlen ("syntax error, unexpected ") + 1;
01645 yysize += yystrlen (yytname[yytype]);
01646 yymsg = (char *) YYSTACK_ALLOC (yysize);
01647 if (yymsg != 0)
01648 {
01649 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
01650 yyp = yystpcpy (yyp, yytname[yytype]);
01651
01652 if (yycount < 5)
01653 {
01654 yycount = 0;
01655 for (yyx = yyn < 0 ? -yyn : 0;
01656 yyx < (int) (sizeof (yytname) / sizeof (char *));
01657 yyx++)
01658 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01659 {
01660 const char *yyq = ! yycount ? ", expecting " : " or ";
01661 yyp = yystpcpy (yyp, yyq);
01662 yyp = yystpcpy (yyp, yytname[yyx]);
01663 yycount++;
01664 }
01665 }
01666 yyerror (yymsg);
01667 YYSTACK_FREE (yymsg);
01668 }
01669 else
01670 yyerror ("syntax error; also virtual memory exhausted");
01671 }
01672 else
01673 #endif
01674 yyerror ("syntax error");
01675 }
01676
01677
01678
01679 if (yyerrstatus == 3)
01680 {
01681
01682
01683
01684
01685 if (yychar == YYEOF)
01686 {
01687
01688 YYPOPSTACK;
01689
01690 while (yyss < yyssp)
01691 {
01692 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
01693 yydestruct (yystos[*yyssp], yyvsp);
01694 YYPOPSTACK;
01695 }
01696 YYABORT;
01697 }
01698
01699 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
01700 yydestruct (yytoken, &yylval);
01701 yychar = YYEMPTY;
01702
01703 }
01704
01705
01706
01707 goto yyerrlab1;
01708
01709
01710
01711
01712
01713 yyerrlab1:
01714 yyerrstatus = 3;
01715
01716 for (;;)
01717 {
01718 yyn = yypact[yystate];
01719 if (yyn != YYPACT_NINF)
01720 {
01721 yyn += YYTERROR;
01722 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
01723 {
01724 yyn = yytable[yyn];
01725 if (0 < yyn)
01726 break;
01727 }
01728 }
01729
01730
01731 if (yyssp == yyss)
01732 YYABORT;
01733
01734 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
01735 yydestruct (yystos[yystate], yyvsp);
01736 yyvsp--;
01737 yystate = *--yyssp;
01738
01739 YY_STACK_PRINT (yyss, yyssp);
01740 }
01741
01742 if (yyn == YYFINAL)
01743 YYACCEPT;
01744
01745 YYDPRINTF ((stderr, "Shifting error token, "));
01746
01747 *++yyvsp = yylval;
01748
01749
01750 yystate = yyn;
01751 goto yynewstate;
01752
01753
01754
01755
01756
01757 yyacceptlab:
01758 yyresult = 0;
01759 goto yyreturn;
01760
01761
01762
01763
01764 yyabortlab:
01765 yyresult = 1;
01766 goto yyreturn;
01767
01768 #ifndef yyoverflow
01769
01770
01771
01772 yyoverflowlab:
01773 yyerror ("parser stack overflow");
01774 yyresult = 2;
01775
01776 #endif
01777
01778 yyreturn:
01779 #ifndef yyoverflow
01780 if (yyss != yyssa)
01781 YYSTACK_FREE (yyss);
01782 #endif
01783 return yyresult;
01784 }
01785
01786
01787 #line 444 "getdate.y"
01788
01789
01790
01791
01792
01793 #include "modules/getdate.h"
01794
01795 #ifndef gmtime
01796 struct tm *gmtime ();
01797 #endif
01798 #ifndef localtime
01799 struct tm *localtime ();
01800 #endif
01801 #ifndef mktime
01802 time_t mktime ();
01803 #endif
01804
01805 static table const meridian_table[] =
01806 {
01807 { "AM", tMERIDIAN, MERam },
01808 { "A.M.", tMERIDIAN, MERam },
01809 { "PM", tMERIDIAN, MERpm },
01810 { "P.M.", tMERIDIAN, MERpm },
01811 { 0, 0, 0 }
01812 };
01813
01814 static table const dst_table[] =
01815 {
01816 { "DST", tDST, 0 }
01817 };
01818
01819 static table const month_and_day_table[] =
01820 {
01821 { "JANUARY", tMONTH, 1 },
01822 { "FEBRUARY", tMONTH, 2 },
01823 { "MARCH", tMONTH, 3 },
01824 { "APRIL", tMONTH, 4 },
01825 { "MAY", tMONTH, 5 },
01826 { "JUNE", tMONTH, 6 },
01827 { "JULY", tMONTH, 7 },
01828 { "AUGUST", tMONTH, 8 },
01829 { "SEPTEMBER",tMONTH, 9 },
01830 { "SEPT", tMONTH, 9 },
01831 { "OCTOBER", tMONTH, 10 },
01832 { "NOVEMBER", tMONTH, 11 },
01833 { "DECEMBER", tMONTH, 12 },
01834 { "SUNDAY", tDAY, 0 },
01835 { "MONDAY", tDAY, 1 },
01836 { "TUESDAY", tDAY, 2 },
01837 { "TUES", tDAY, 2 },
01838 { "WEDNESDAY",tDAY, 3 },
01839 { "WEDNES", tDAY, 3 },
01840 { "THURSDAY", tDAY, 4 },
01841 { "THUR", tDAY, 4 },
01842 { "THURS", tDAY, 4 },
01843 { "FRIDAY", tDAY, 5 },
01844 { "SATURDAY", tDAY, 6 },
01845 { 0, 0, 0 }
01846 };
01847
01848 static table const time_units_table[] =
01849 {
01850 { "YEAR", tYEAR_UNIT, 1 },
01851 { "MONTH", tMONTH_UNIT, 1 },
01852 { "FORTNIGHT",tDAY_UNIT, 14 },
01853 { "WEEK", tDAY_UNIT, 7 },
01854 { "DAY", tDAY_UNIT, 1 },
01855 { "HOUR", tHOUR_UNIT, 1 },
01856 { "MINUTE", tMINUTE_UNIT, 1 },
01857 { "MIN", tMINUTE_UNIT, 1 },
01858 { "SECOND", tSEC_UNIT, 1 },
01859 { "SEC", tSEC_UNIT, 1 },
01860 { 0, 0, 0 }
01861 };
01862
01863
01864 static table const relative_time_table[] =
01865 {
01866 { "TOMORROW", tMINUTE_UNIT, 24 * 60 },
01867 { "YESTERDAY",tMINUTE_UNIT, - (24 * 60) },
01868 { "TODAY", tMINUTE_UNIT, 0 },
01869 { "NOW", tMINUTE_UNIT, 0 },
01870 { "LAST", tUNUMBER, -1 },
01871 { "THIS", tUNUMBER, 0 },
01872 { "NEXT", tUNUMBER, 1 },
01873 { "FIRST", tUNUMBER, 1 },
01874
01875 { "THIRD", tUNUMBER, 3 },
01876 { "FOURTH", tUNUMBER, 4 },
01877 { "FIFTH", tUNUMBER, 5 },
01878 { "SIXTH", tUNUMBER, 6 },
01879 { "SEVENTH", tUNUMBER, 7 },
01880 { "EIGHTH", tUNUMBER, 8 },
01881 { "NINTH", tUNUMBER, 9 },
01882 { "TENTH", tUNUMBER, 10 },
01883 { "ELEVENTH", tUNUMBER, 11 },
01884 { "TWELFTH", tUNUMBER, 12 },
01885 { "AGO", tAGO, 1 },
01886 { 0, 0, 0 }
01887 };
01888
01889
01890
01891
01892
01893
01894 static table const time_zone_table[] =
01895 {
01896 { "GMT", tZONE, HOUR ( 0) },
01897 { "UT", tZONE, HOUR ( 0) },
01898 { "UTC", tZONE, HOUR ( 0) },
01899 { "WET", tZONE, HOUR ( 0) },
01900 { "WEST", tDAYZONE, HOUR ( 0) },
01901 { "BST", tDAYZONE, HOUR ( 0) },
01902 { "ART", tZONE, -HOUR ( 3) },
01903 { "BRT", tZONE, -HOUR ( 3) },
01904 { "BRST", tDAYZONE, -HOUR ( 3) },
01905 { "NST", tZONE, -(HOUR ( 3) + 30) },
01906 { "NDT", tDAYZONE,-(HOUR ( 3) + 30) },
01907 { "AST", tZONE, -HOUR ( 4) },
01908 { "ADT", tDAYZONE, -HOUR ( 4) },
01909 { "CLT", tZONE, -HOUR ( 4) },
01910 { "CLST", tDAYZONE, -HOUR ( 4) },
01911 { "EST", tZONE, -HOUR ( 5) },
01912 { "EDT", tDAYZONE, -HOUR ( 5) },
01913 { "CST", tZONE, -HOUR ( 6) },
01914 { "CDT", tDAYZONE, -HOUR ( 6) },
01915 { "MST", tZONE, -HOUR ( 7) },
01916 { "MDT", tDAYZONE, -HOUR ( 7) },
01917 { "PST", tZONE, -HOUR ( 8) },
01918 { "PDT", tDAYZONE, -HOUR ( 8) },
01919 { "AKST", tZONE, -HOUR ( 9) },
01920 { "AKDT", tDAYZONE, -HOUR ( 9) },
01921 { "HST", tZONE, -HOUR (10) },
01922 { "HAST", tZONE, -HOUR (10) },
01923 { "HADT", tDAYZONE, -HOUR (10) },
01924 { "SST", tZONE, -HOUR (12) },
01925 { "WAT", tZONE, HOUR ( 1) },
01926 { "CET", tZONE, HOUR ( 1) },
01927 { "CEST", tDAYZONE, HOUR ( 1) },
01928 { "MET", tZONE, HOUR ( 1) },
01929 { "MEZ", tZONE, HOUR ( 1) },
01930 { "MEST", tDAYZONE, HOUR ( 1) },
01931 { "MESZ", tDAYZONE, HOUR ( 1) },
01932 { "EET", tZONE, HOUR ( 2) },
01933 { "EEST", tDAYZONE, HOUR ( 2) },
01934 { "CAT", tZONE, HOUR ( 2) },
01935 { "SAST", tZONE, HOUR ( 2) },
01936 { "EAT", tZONE, HOUR ( 3) },
01937 { "MSK", tZONE, HOUR ( 3) },
01938 { "MSD", tDAYZONE, HOUR ( 3) },
01939 { "IST", tZONE, (HOUR ( 5) + 30) },
01940 { "SGT", tZONE, HOUR ( 8) },
01941 { "KST", tZONE, HOUR ( 9) },
01942 { "JST", tZONE, HOUR ( 9) },
01943 { "GST", tZONE, HOUR (10) },
01944 { "NZST", tZONE, HOUR (12) },
01945 { "NZDT", tDAYZONE, HOUR (12) },
01946 { 0, 0, 0 }
01947 };
01948
01949
01950 static table const military_table[] =
01951 {
01952 { "A", tZONE, -HOUR ( 1) },
01953 { "B", tZONE, -HOUR ( 2) },
01954 { "C", tZONE, -HOUR ( 3) },
01955 { "D", tZONE, -HOUR ( 4) },
01956 { "E", tZONE, -HOUR ( 5) },
01957 { "F", tZONE, -HOUR ( 6) },
01958 { "G", tZONE, -HOUR ( 7) },
01959 { "H", tZONE, -HOUR ( 8) },
01960 { "I", tZONE, -HOUR ( 9) },
01961 { "K", tZONE, -HOUR (10) },
01962 { "L", tZONE, -HOUR (11) },
01963 { "M", tZONE, -HOUR (12) },
01964 { "N", tZONE, HOUR ( 1) },
01965 { "O", tZONE, HOUR ( 2) },
01966 { "P", tZONE, HOUR ( 3) },
01967 { "Q", tZONE, HOUR ( 4) },
01968 { "R", tZONE, HOUR ( 5) },
01969 { "S", tZONE, HOUR ( 6) },
01970 { "T", tZONE, HOUR ( 7) },
01971 { "U", tZONE, HOUR ( 8) },
01972 { "V", tZONE, HOUR ( 9) },
01973 { "W", tZONE, HOUR (10) },
01974 { "X", tZONE, HOUR (11) },
01975 { "Y", tZONE, HOUR (12) },
01976 { "Z", tZONE, HOUR ( 0) },
01977 { 0, 0, 0 }
01978 };
01979
01980
01981
01982 static int
01983 to_hour (int hours, int meridian)
01984 {
01985 switch (meridian)
01986 {
01987 case MER24:
01988 return 0 <= hours && hours < 24 ? hours : -1;
01989 case MERam:
01990 return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
01991 case MERpm:
01992 return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
01993 default:
01994 abort ();
01995 }
01996
01997 return 0;
01998 }
01999
02000 static int
02001 to_year (textint textyear)
02002 {
02003 int year = textyear.value;
02004
02005 if (year < 0)
02006 year = -year;
02007
02008
02009
02010 if (textyear.digits == 2)
02011 year += year < 69 ? 2000 : 1900;
02012
02013 return year;
02014 }
02015
02016 static table const *
02017 lookup_zone (parser_control const *pc, char const *name)
02018 {
02019 table const *tp;
02020
02021
02022 for (tp = pc->local_time_zone_table; tp->name; tp++)
02023 if (strcmp (name, tp->name) == 0)
02024 return tp;
02025
02026 for (tp = time_zone_table; tp->name; tp++)
02027 if (strcmp (name, tp->name) == 0)
02028 return tp;
02029
02030 return 0;
02031 }
02032
02033 #if ! HAVE_TM_GMTOFF
02034
02035
02036
02037
02038 static int
02039 tm_diff (struct tm const *a, struct tm const *b)
02040 {
02041
02042
02043
02044 int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
02045 int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
02046 int a100 = a4 / 25 - (a4 % 25 < 0);
02047 int b100 = b4 / 25 - (b4 % 25 < 0);
02048 int a400 = a100 >> 2;
02049 int b400 = b100 >> 2;
02050 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
02051 int years = a->tm_year - b->tm_year;
02052 int days = (365 * years + intervening_leap_days
02053 + (a->tm_yday - b->tm_yday));
02054 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
02055 + (a->tm_min - b->tm_min))
02056 + (a->tm_sec - b->tm_sec));
02057 }
02058 #endif
02059
02060 static table const *
02061 lookup_word (parser_control const *pc, char *word)
02062 {
02063 char *p;
02064 char *q;
02065 size_t wordlen;
02066 table const *tp;
02067 int i;
02068 int abbrev;
02069
02070
02071 for (p = word; *p; p++)
02072 if (ISLOWER ((unsigned char) *p))
02073 *p = toupper ((unsigned char) *p);
02074
02075 for (tp = meridian_table; tp->name; tp++)
02076 if (strcmp (word, tp->name) == 0)
02077 return tp;
02078
02079
02080 wordlen = strlen (word);
02081 abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.');
02082
02083 for (tp = month_and_day_table; tp->name; tp++)
02084 if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0)
02085 return tp;
02086
02087 if ((tp = lookup_zone (pc, word)))
02088 return tp;
02089
02090 if (strcmp (word, dst_table[0].name) == 0)
02091 return dst_table;
02092
02093 for (tp = time_units_table; tp->name; tp++)
02094 if (strcmp (word, tp->name) == 0)
02095 return tp;
02096
02097
02098 if (word[wordlen - 1] == 'S')
02099 {
02100 word[wordlen - 1] = '\0';
02101 for (tp = time_units_table; tp->name; tp++)
02102 if (strcmp (word, tp->name) == 0)
02103 return tp;
02104 word[wordlen - 1] = 'S';
02105 }
02106
02107 for (tp = relative_time_table; tp->name; tp++)
02108 if (strcmp (word, tp->name) == 0)
02109 return tp;
02110
02111
02112 if (wordlen == 1)
02113 for (tp = military_table; tp->name; tp++)
02114 if (word[0] == tp->name[0])
02115 return tp;
02116
02117
02118 for (i = 0, p = q = word; (*p = *q); q++)
02119 if (*q == '.')
02120 i = 1;
02121 else
02122 p++;
02123 if (i && (tp = lookup_zone (pc, word)))
02124 return tp;
02125
02126 return 0;
02127 }
02128
02129 static int
02130 yylex (YYSTYPE *lvalp, parser_control *pc)
02131 {
02132 unsigned char c;
02133 int count;
02134
02135 for (;;)
02136 {
02137 while (c = *pc->input, ISSPACE (c))
02138 pc->input++;
02139
02140 if (ISDIGIT (c) || c == '-' || c == '+')
02141 {
02142 char const *p;
02143 int sign;
02144 int value;
02145 if (c == '-' || c == '+')
02146 {
02147 sign = c == '-' ? -1 : 1;
02148 c = *++pc->input;
02149 if (! ISDIGIT (c))
02150
02151 continue;
02152 }
02153 else
02154 sign = 0;
02155 p = pc->input;
02156 value = 0;
02157 do
02158 {
02159 value = 10 * value + c - '0';
02160 c = *++p;
02161 }
02162 while (ISDIGIT (c));
02163 lvalp->textintval.value = sign < 0 ? -value : value;
02164 lvalp->textintval.digits = p - pc->input;
02165 pc->input = p;
02166 return sign ? tSNUMBER : tUNUMBER;
02167 }
02168
02169 if (ISALPHA (c))
02170 {
02171 char buff[20];
02172 char *p = buff;
02173 table const *tp;
02174
02175 do
02176 {
02177 if (p < buff + sizeof buff - 1)
02178 *p++ = c;
02179 c = *++pc->input;
02180 }
02181 while (ISALPHA (c) || c == '.');
02182
02183 *p = '\0';
02184 tp = lookup_word (pc, buff);
02185 if (! tp)
02186 return '?';
02187 lvalp->intval = tp->value;
02188 return tp->type;
02189 }
02190
02191 if (c != '(')
02192 return *pc->input++;
02193 count = 0;
02194 do
02195 {
02196 c = *pc->input++;
02197 if (c == '\0')
02198 return c;
02199 if (c == '(')
02200 count++;
02201 else if (c == ')')
02202 count--;
02203 }
02204 while (count > 0);
02205 }
02206 }
02207
02208
02209 static int
02210 yyerror (char *s ATTRIBUTE_UNUSED)
02211 {
02212 return 0;
02213 }
02214
02215
02216
02217
02218
02219 time_t
02220 get_date (const char *p, const time_t *now)
02221 {
02222 time_t Start = now ? *now : time (0);
02223 struct tm *tmp = localtime (&Start);
02224 struct tm tm;
02225 struct tm tm0;
02226 parser_control pc;
02227
02228 if (! tmp)
02229 return -1;
02230
02231 pc.input = p;
02232 pc.year.value = tmp->tm_year + TM_YEAR_BASE;
02233 pc.year.digits = 4;
02234 pc.month = tmp->tm_mon + 1;
02235 pc.day = tmp->tm_mday;
02236 pc.hour = tmp->tm_hour;
02237 pc.minutes = tmp->tm_min;
02238 pc.seconds = tmp->tm_sec;
02239 tm.tm_isdst = tmp->tm_isdst;
02240
02241 pc.meridian = MER24;
02242 pc.rel_seconds = 0;
02243 pc.rel_minutes = 0;
02244 pc.rel_hour = 0;
02245 pc.rel_day = 0;
02246 pc.rel_month = 0;
02247 pc.rel_year = 0;
02248 pc.dates_seen = 0;
02249 pc.days_seen = 0;
02250 pc.rels_seen = 0;
02251 pc.times_seen = 0;
02252 pc.local_zones_seen = 0;
02253 pc.zones_seen = 0;
02254
02255 #if HAVE_STRUCT_TM_TM_ZONE
02256 pc.local_time_zone_table[0].name = tmp->tm_zone;
02257 pc.local_time_zone_table[0].type = tLOCAL_ZONE;
02258 pc.local_time_zone_table[0].value = tmp->tm_isdst;
02259 pc.local_time_zone_table[1].name = 0;
02260
02261
02262
02263 {
02264 int quarter;
02265 for (quarter = 1; quarter <= 3; quarter++)
02266 {
02267 time_t probe = Start + quarter * (90 * 24 * 60 * 60);
02268 struct tm *probe_tm = localtime (&probe);
02269 if (probe_tm && probe_tm->tm_zone
02270 && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
02271 {
02272 {
02273 pc.local_time_zone_table[1].name = probe_tm->tm_zone;
02274 pc.local_time_zone_table[1].type = tLOCAL_ZONE;
02275 pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
02276 pc.local_time_zone_table[2].name = 0;
02277 }
02278 break;
02279 }
02280 }
02281 }
02282 #else
02283 #if HAVE_TZNAME
02284 {
02285 # ifndef tzname
02286 extern char *tzname[];
02287 # endif
02288 int i;
02289 for (i = 0; i < 2; i++)
02290 {
02291 pc.local_time_zone_table[i].name = tzname[i];
02292 pc.local_time_zone_table[i].type = tLOCAL_ZONE;
02293 pc.local_time_zone_table[i].value = i;
02294 }
02295 pc.local_time_zone_table[i].name = 0;
02296 }
02297 #else
02298 pc.local_time_zone_table[0].name = 0;
02299 #endif
02300 #endif
02301
02302 if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
02303 && ! strcmp (pc.local_time_zone_table[0].name,
02304 pc.local_time_zone_table[1].name))
02305 {
02306
02307
02308
02309 pc.local_time_zone_table[0].value = -1;
02310 pc.local_time_zone_table[1].name = 0;
02311 }
02312
02313 if (yyparse (&pc) != 0
02314 || 1 < pc.times_seen || 1 < pc.dates_seen || 1 < pc.days_seen
02315 || 1 < (pc.local_zones_seen + pc.zones_seen)
02316 || (pc.local_zones_seen && 1 < pc.local_isdst))
02317 return -1;
02318
02319 tm.tm_year = to_year (pc.year) - TM_YEAR_BASE + pc.rel_year;
02320 tm.tm_mon = pc.month - 1 + pc.rel_month;
02321 tm.tm_mday = pc.day + pc.rel_day;
02322 if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
02323 {
02324 tm.tm_hour = to_hour (pc.hour, pc.meridian);
02325 if (tm.tm_hour < 0)
02326 return -1;
02327 tm.tm_min = pc.minutes;
02328 tm.tm_sec = pc.seconds;
02329 }
02330 else
02331 {
02332 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
02333 }
02334
02335
02336
02337 if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day
02338 | pc.rel_month | pc.rel_year)
02339 tm.tm_isdst = -1;
02340
02341
02342
02343 if (pc.local_zones_seen)
02344 tm.tm_isdst = pc.local_isdst;
02345
02346 tm0 = tm;
02347
02348 Start = mktime (&tm);
02349
02350 if (Start == (time_t) -1)
02351 {
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361 if (pc.zones_seen)
02362 {
02363 tm = tm0;
02364 if (tm.tm_year <= EPOCH_YEAR - TM_YEAR_BASE)
02365 {
02366 tm.tm_mday++;
02367 pc.time_zone += 24 * 60;
02368 }
02369 else
02370 {
02371 tm.tm_mday--;
02372 pc.time_zone -= 24 * 60;
02373 }
02374 Start = mktime (&tm);
02375 }
02376
02377 if (Start == (time_t) -1)
02378 return Start;
02379 }
02380
02381 if (pc.days_seen && ! pc.dates_seen)
02382 {
02383 tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
02384 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
02385 tm.tm_isdst = -1;
02386 Start = mktime (&tm);
02387 if (Start == (time_t) -1)
02388 return Start;
02389 }
02390
02391 if (pc.zones_seen)
02392 {
02393 int delta = pc.time_zone * 60;
02394 #ifdef HAVE_TM_GMTOFF
02395 delta -= tm.tm_gmtoff;
02396 #else
02397 struct tm *gmt = gmtime (&Start);
02398 if (! gmt)
02399 return -1;
02400 delta -= tm_diff (&tm, gmt);
02401 #endif
02402 if ((Start < Start - delta) != (delta < 0))
02403 return -1;
02404 Start -= delta;
02405 }
02406
02407
02408
02409
02410
02411
02412
02413 {
02414 time_t t0 = Start;
02415 long d1 = 60 * 60 * (long) pc.rel_hour;
02416 time_t t1 = t0 + d1;
02417 long d2 = 60 * (long) pc.rel_minutes;
02418 time_t t2 = t1 + d2;
02419 int d3 = pc.rel_seconds;
02420 time_t t3 = t2 + d3;
02421 if ((d1 / (60 * 60) ^ pc.rel_hour)
02422 | (d2 / 60 ^ pc.rel_minutes)
02423 | ((t0 + d1 < t0) ^ (d1 < 0))
02424 | ((t1 + d2 < t1) ^ (d2 < 0))
02425 | ((t2 + d3 < t2) ^ (d3 < 0)))
02426 return -1;
02427 Start = t3;
02428 }
02429
02430 return Start;
02431 }
02432
02433 #if TEST
02434
02435 #include <stdio.h>
02436
02437 int
02438 main (int ac, char **av)
02439 {
02440 char buff[BUFSIZ];
02441 time_t d;
02442
02443 printf ("Enter date, or blank line to exit.\n\t> ");
02444 fflush (stdout);
02445
02446 buff[BUFSIZ - 1] = 0;
02447 while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
02448 {
02449 d = get_date (buff, 0);
02450 if (d == (time_t) -1)
02451 printf ("Bad format - couldn't convert.\n");
02452 else
02453 printf ("%s", ctime (&d));
02454 printf ("\t> ");
02455 fflush (stdout);
02456 }
02457 return 0;
02458 }
02459 #endif
02460
02461