+/* 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 <h/nmh.h>
#include <h/tws.h>
#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
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)
W ([ \t]+)
D ([0-9]?[0-9])
d [0-9]
+nl [ \t\n()]
%%
%{
YY_BUFFER_STATE lexhandle;
- register char *cp;
+ register unsigned char *cp;
static struct tws tw;
memset(&tw,0,sizeof(struct tws));
#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
zonehack (&tw);
#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */
- // yyterminate();
+ yyterminate();
}
"-"{D}{d}{d} {
INIT();
#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);
+}
+