X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fdtimep.c;h=68616b846116ba94d22f9e47527d613f2dfeaf30;hb=da12435096e47ec1d362215141fc8b21f24e5e01;hp=2ddeae6134658ca104c86ce2285d4e123bfe7a94;hpb=859187428420e9089e91a45f3a833135172d1822;p=mmh diff --git a/sbr/dtimep.c b/sbr/dtimep.c index 2ddeae6..68616b8 100644 --- a/sbr/dtimep.c +++ b/sbr/dtimep.c @@ -877,8 +877,10 @@ static int month_map[] = { }; /* - * Same trick for day-of-week using the hash function - * (c1 & 7) + (c2 & 4) + * Lookup table for day-of-week using the same hash trick as for above name-of- + * month table, but using the first and second character, not second and third. + * + * Compute index into table using: (day_name[0] & 7) + (day_name[1] & 4) */ static int day_map[] = { 0, @@ -906,8 +908,7 @@ static int day_map[] = { */ #define INIT() { cp = yytext;} -#define SETWDAY() { cp++; \ - tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)]; \ +#define SETWDAY() { tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)]; \ tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; \ SKIPA(); } #define SETMON() { cp++; \ @@ -943,6 +944,34 @@ static int day_map[] = { --cp; } #define SKIPTOSP() { while ( !isspace(*cp++) ) ; \ --cp; } + +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST +# ifdef TIME_WITH_SYS_TIME +# include +# include +# else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +# endif + +static void +zonehack (struct tws *tw) +{ + register struct tm *tm; + + if (dmktime (tw) == (time_t) -1) + return; + + tm = localtime (&tw->tw_clock); + if (tm->tm_isdst) { + tw->tw_flags |= TW_DST; + tw->tw_zone -= 60; + } +} +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ /* The year can either be 2 digits, or 4. However, after Y2K, we found that some MUA were reporting the year 100, hence the middle term here. yyterminate() resolves the actual @@ -1095,10 +1124,10 @@ YY_MALLOC_DECL YY_DECL { register yy_state_type yy_current_state; - register char *yy_cp = NULL, *yy_bp = NULL; + register char *yy_cp, *yy_bp; register int yy_act; -#line 197 "dtimep.lex" +#line 226 "dtimep.lex" /* This section begins the definition of dparsetime(). @@ -1198,7 +1227,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 212 "dtimep.lex" +#line 241 "dtimep.lex" { INIT(); SETWDAY(); @@ -1214,7 +1243,7 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 225 "dtimep.lex" +#line 254 "dtimep.lex" { INIT(); SETWDAY(); @@ -1230,7 +1259,7 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 237 "dtimep.lex" +#line 266 "dtimep.lex" { INIT(); SETDAY(); @@ -1244,7 +1273,7 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 247 "dtimep.lex" +#line 276 "dtimep.lex" { INIT(); SETWDAY(); @@ -1260,7 +1289,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 259 "dtimep.lex" +#line 288 "dtimep.lex" { INIT(); SETWDAY(); @@ -1274,7 +1303,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 269 "dtimep.lex" +#line 298 "dtimep.lex" { INIT(); SETMON(); @@ -1288,7 +1317,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 279 "dtimep.lex" +#line 308 "dtimep.lex" { INIT(); SETMON(); @@ -1300,7 +1329,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 287 "dtimep.lex" +#line 316 "dtimep.lex" { INIT(); if(europeandate) { @@ -1322,7 +1351,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 305 "dtimep.lex" +#line 334 "dtimep.lex" { INIT(); if(europeandate) { @@ -1342,135 +1371,141 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 322 "dtimep.lex" +#line 351 "dtimep.lex" YY_BREAK case 11: YY_RULE_SETUP -#line 323 "dtimep.lex" +#line 352 "dtimep.lex" tw.tw_hour += 12; YY_BREAK case 12: YY_RULE_SETUP -#line 325 "dtimep.lex" +#line 354 "dtimep.lex" { INIT(); SKIPTOD(); SETZONE(atoi(cp)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ } YY_BREAK case 13: YY_RULE_SETUP -#line 330 "dtimep.lex" +#line 362 "dtimep.lex" { INIT(); SKIPTOD(); SETZONE(-atoi(cp)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ } YY_BREAK case 14: YY_RULE_SETUP -#line 335 "dtimep.lex" +#line 370 "dtimep.lex" INIT(); SETZONE(0); YY_BREAK case 15: YY_RULE_SETUP -#line 336 "dtimep.lex" +#line 371 "dtimep.lex" INIT(); SETZONE(0); YY_BREAK case 16: YY_RULE_SETUP -#line 337 "dtimep.lex" +#line 372 "dtimep.lex" INIT(); SETZONE(200); YY_BREAK case 17: YY_RULE_SETUP -#line 338 "dtimep.lex" +#line 373 "dtimep.lex" INIT(); SETDST(); SETZONE(2); YY_BREAK case 18: YY_RULE_SETUP -#line 339 "dtimep.lex" +#line 374 "dtimep.lex" INIT(); SETZONE(-500); YY_BREAK case 19: YY_RULE_SETUP -#line 340 "dtimep.lex" +#line 375 "dtimep.lex" INIT(); SETDST(); SETZONE(-500); YY_BREAK case 20: YY_RULE_SETUP -#line 341 "dtimep.lex" +#line 376 "dtimep.lex" INIT(); SETZONE(-600); YY_BREAK case 21: YY_RULE_SETUP -#line 342 "dtimep.lex" +#line 377 "dtimep.lex" INIT(); SETDST(); SETZONE(-600); YY_BREAK case 22: YY_RULE_SETUP -#line 343 "dtimep.lex" +#line 378 "dtimep.lex" INIT(); SETZONE(-700); YY_BREAK case 23: YY_RULE_SETUP -#line 344 "dtimep.lex" +#line 379 "dtimep.lex" INIT(); SETDST(); SETZONE(-700); YY_BREAK case 24: YY_RULE_SETUP -#line 345 "dtimep.lex" +#line 380 "dtimep.lex" INIT(); SETZONE(-800); YY_BREAK case 25: YY_RULE_SETUP -#line 346 "dtimep.lex" +#line 381 "dtimep.lex" INIT(); SETDST(); SETZONE(-800); YY_BREAK case 26: YY_RULE_SETUP -#line 347 "dtimep.lex" +#line 382 "dtimep.lex" INIT(); SETZONE(-330); YY_BREAK case 27: YY_RULE_SETUP -#line 348 "dtimep.lex" +#line 383 "dtimep.lex" INIT(); SETZONE(-400); YY_BREAK case 28: YY_RULE_SETUP -#line 349 "dtimep.lex" +#line 384 "dtimep.lex" INIT(); SETDST(); SETZONE(-400); YY_BREAK case 29: YY_RULE_SETUP -#line 350 "dtimep.lex" +#line 385 "dtimep.lex" INIT(); SETZONE(-900); YY_BREAK case 30: YY_RULE_SETUP -#line 351 "dtimep.lex" +#line 386 "dtimep.lex" INIT(); SETDST(); SETZONE(-900); YY_BREAK case 31: YY_RULE_SETUP -#line 352 "dtimep.lex" +#line 387 "dtimep.lex" INIT(); SETZONE(-1000); YY_BREAK case 32: YY_RULE_SETUP -#line 353 "dtimep.lex" +#line 388 "dtimep.lex" INIT(); SETDST(); SETZONE(-1000); YY_BREAK case 33: YY_RULE_SETUP -#line 354 "dtimep.lex" +#line 389 "dtimep.lex" INIT(); SETDST(); SETZONE(-100); YY_BREAK case 34: YY_RULE_SETUP -#line 355 "dtimep.lex" +#line 390 "dtimep.lex" { INIT(); SETZONE(100*(('a'-1) - tolower(*cp))); @@ -1478,7 +1513,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 359 "dtimep.lex" +#line 394 "dtimep.lex" { INIT(); SETZONE(100*('a' - tolower(*cp))); @@ -1486,7 +1521,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 363 "dtimep.lex" +#line 398 "dtimep.lex" { INIT(); SETZONE(100*(tolower(*cp) - 'm')); @@ -1494,12 +1529,12 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 367 "dtimep.lex" +#line 402 "dtimep.lex" YY_BREAK case 38: YY_RULE_SETUP -#line 368 "dtimep.lex" +#line 403 "dtimep.lex" ECHO; YY_BREAK case YY_STATE_EOF(INITIAL): @@ -2387,4 +2422,4 @@ int main() return 0; } #endif -#line 368 "dtimep.lex" +#line 403 "dtimep.lex"