X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fdtimep.lex;h=01910868f37f60f2a4a532559a4ff4b301e01baf;hb=4dd01e6c68874a5fc2988d63d6c26984889310a3;hp=3a3782576dd4804805121482716947cfd637a99d;hpb=5b26f4fcdfeb7153b92c18f1478a0626341c609d;p=mmh diff --git a/sbr/dtimep.lex b/sbr/dtimep.lex index 3a37825..0191086 100644 --- a/sbr/dtimep.lex +++ b/sbr/dtimep.lex @@ -1,7 +1,12 @@ -%e 2000 -%p 5000 -%n 1000 -%a 4000 +/* dtimep.lex exceeds the default table capacities for some old versions + * of lex (and the minimum defaults as specified by POSIX). The following + * choices meet or exceed the lex defaults for older SunOS4.x, Solaris, + * HPUX, and AIX. + */ +%e4000 +%p7000 +%n2500 +%a5000 %{ #include #include @@ -12,7 +17,7 @@ #define yywrap() 1 #define YY_SKIP_YYWRAP -#define YY_NO_UNPUT +#define YY_NO_INPUT /* This is the tricky thing that makes this function cool. We * replace the traditional int yylex(void) declaration with our @@ -32,9 +37,9 @@ if(!(tw.tw_flags & TW_SUCC)) { \ return (struct tws *)NULL; \ } \ - if(tw.tw_year < 1960) \ + if(tw.tw_year < 1970) \ tw.tw_year += 1900; \ - if(tw.tw_year < 1960) \ + if(tw.tw_year < 1970) \ tw.tw_year += 100; \ return(&tw) @@ -222,6 +227,7 @@ w ([ \t]*) W ([ \t]+) D ([0-9]?[0-9]) d [0-9] +nl [ \t\n()] %% %{ @@ -230,7 +236,7 @@ d [0-9] YY_BUFFER_STATE lexhandle; - register char *cp; + register unsigned char *cp; static struct tws tw; memset(&tw,0,sizeof(struct tws)); @@ -358,7 +364,7 @@ d [0-9] #ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST zonehack (&tw); #endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ - // yyterminate(); + yyterminate(); } "-"{D}{d}{d} { INIT(); @@ -367,23 +373,41 @@ d [0-9] #ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST zonehack (&tw); #endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ - // yyterminate(); + yyterminate(); } -"-"?("ut"|"UT") INIT(); SETZONE(0); -"-"?("gmt"|"GMT") INIT(); SETZONE(0); -"-"?("est"|"EST") INIT(); SETZONE(-500); -"-"?("edt"|"EDT") INIT(); SETDST(); SETZONE(-500); -"-"?("cst"|"CST") INIT(); SETZONE(-600); -"-"?("cdt"|"CDT") INIT(); SETDST(); SETZONE(-600); -"-"?("mst"|"MST") INIT(); SETZONE(-700); -"-"?("mdt"|"MDT") INIT(); SETDST(); SETZONE(-700); -"-"?("pst"|"PST") INIT(); SETZONE(-800); -"-"?("pdt"|"PDT") INIT(); SETDST(); SETZONE(-800); -"-"?("nst"|"NST") INIT(); SETZONE(-330); -"-"?("ast"|"AST") INIT(); SETZONE(-400); -"-"?("adt"|"ADT") INIT(); SETDST(); SETZONE(-400); -"-"?("hst"|"HST") INIT(); SETZONE(-1000); -"-"?("hdt"|"HDT") INIT(); SETDST(); SETZONE(-1000); -"-"?([a-z]{3}|[A-Z]{3}) ; +{nl}("ut"|"UT") INIT(); SETZONE(0); yyterminate(); +{nl}("gmt"|"GMT") INIT(); SETZONE(0); yyterminate(); +{nl}("est"|"EST") INIT(); SETZONE(-500); yyterminate(); +{nl}("edt"|"EDT") { INIT(); SETDST(); SETZONE(-500); + yyterminate(); } +{nl}("cst"|"CST") INIT(); SETZONE(-600); yyterminate(); +{nl}("cdt"|"CDT") { INIT(); SETDST(); SETZONE(-600); + yyterminate(); } +{nl}("mst"|"MST") INIT(); SETZONE(-700); yyterminate(); +{nl}("mdt"|"MDT") { INIT(); SETDST(); SETZONE(-700); + yyterminate(); } +{nl}("pst"|"PST") INIT(); SETZONE(-800); yyterminate(); +{nl}("pdt"|"PDT") { INIT(); SETDST(); SETZONE(-800); + yyterminate(); } +{nl}("nst"|"NST") INIT(); SETZONE(-330); yyterminate(); +{nl}("ast"|"AST") INIT(); SETZONE(-400); yyterminate(); +{nl}("adt"|"ADT") { INIT(); SETDST(); SETZONE(-400); + yyterminate(); } +{nl}("hst"|"HST") INIT(); SETZONE(-1000); yyterminate(); +{nl}("hdt"|"HDT") { INIT(); SETDST(); SETZONE(-1000); + yyterminate(); } .|\n + +%% +/* This is a portable way to squash a warning about the yyunput() + * function being static but never used. It costs us a tiny amount + * of extra code in the binary but the other options are: + * "%option nounput" which is flex-specific + * makefile hackery just to compile dtimep.c with different flags + */ +void dtimep_yyunput(int c) +{ + unput(c); +} +