X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fdtimep.lex;h=c36844da2e5a8283c558bf23af5a45aaee134213;hb=a5ff28a9c0927f27efd1378ebc97ad72ffeb56d1;hp=4f019808c42d844a1643e0856c56c1b493a7170e;hpb=859187428420e9089e91a45f3a833135172d1822;p=mmh diff --git a/sbr/dtimep.lex b/sbr/dtimep.lex index 4f01980..c36844d 100644 --- a/sbr/dtimep.lex +++ b/sbr/dtimep.lex @@ -86,8 +86,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, @@ -115,8 +117,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++; \ @@ -152,6 +153,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 */ %} sun ([Ss]un(day)?) @@ -326,11 +355,17 @@ d [0-9] INIT(); SKIPTOD(); SETZONE(atoi(cp)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ } "-"{D}{d}{d} { INIT(); SKIPTOD(); SETZONE(-atoi(cp)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ } "-"?("ut"|"UT") INIT(); SETZONE(0); "-"?("gmt"|"GMT") INIT(); SETZONE(0);