X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/da04deaf832ac32974a5bb9499a0ba8321eaf86b..ca3143890523c6d3092f0e7c3f9aceffa698dbd9:/sbr/dtimep.l diff --git a/sbr/dtimep.l b/sbr/dtimep.l index 29c4dd0c..2b6df175 100644 --- a/sbr/dtimep.l +++ b/sbr/dtimep.l @@ -1,4 +1,6 @@ -/* dtimep.lex exceeds the default table capacities for some old versions +/* dtimep.l -- parse dates and times. + * + * This 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. @@ -14,6 +16,12 @@ /* Since we're looking at a string at a time, don't worry about * wrapping to the next buffer. */ +#if YY_FLEX_MAJOR_VERSION == 2 && \ + YY_FLEX_MINOR_VERSION == 6 && \ + YY_FLEX_SUBMINOR_VERSION == 3 +/* https://github.com/westes/flex/issues/162 */ +#undef yywrap +#endif #define yywrap() 1 #define YY_SKIP_YYWRAP @@ -27,7 +35,7 @@ */ #define YY_DECL struct tws *dparsetime(char *lexstr) - /* yyerminate() is called after the input string is matched to + /* yyterminate() is called after the input string is matched to * completion (actually, when the lexer reaches an EOF). The only * thing that really needs to be in this macro function is the * return call, which must be substituted inline into dparsetime. @@ -43,14 +51,6 @@ tw.tw_year += 100; \ return(&tw) -/* - * Patchable flag that says how to interpret NN/NN/NN dates. When - * true, we do it European style: DD/MM/YY. When false, we do it - * American style: MM/DD/YY. Of course, these are all non-RFC822 - * compliant. - */ -int europeandate = 0; - /* * Table to convert month names to numeric month. We use the * fact that the low order 5 bits of the sum of the 2nd & 3rd @@ -126,14 +126,14 @@ static int day_map[] = { tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; \ SKIPA(); } #define SETMON() { cp++; \ - tw.tw_mon = month_map[(cp[0] + cp[1]) & 0x1f]; \ + tw.tw_mon = month_map[(((unsigned char) cp[0]) + ((unsigned char) cp[1])) & 0x1f]; \ SKIPA(); } #define SETMON_NUM() { tw.tw_mon = atoi(cp)-1; \ SKIPD(); } #define SETYEAR() { tw.tw_year = atoi(cp); \ SKIPD(); } #define SETDAY() { tw.tw_mday = atoi(cp); \ - tw.tw_flags |= TW_YES; \ + tw.tw_flags |= TW_SUCC; \ SKIPD(); } #define SETTIME() { tw.tw_hour = atoi(cp); \ cp += 2; \ @@ -146,20 +146,19 @@ static int day_map[] = { tw.tw_flags |= TW_SZEXP; \ SKIPD(); } #define SETDST() { tw.tw_flags |= TW_DST; } -#define SKIPD() { while ( isdigit(*cp++) ) ; \ +#define SKIPD() { while ( isdigit((unsigned char) *cp++) ) ; \ --cp; } -#define SKIPTOD() { while ( !isdigit(*cp++) ) ; \ +#define SKIPTOD() { while ( !isdigit((unsigned char) *cp++) ) ; \ --cp; } -#define SKIPA() { while ( isalpha(*cp++) ) ; \ +#define SKIPA() { while ( isalpha((unsigned char) *cp++) ) ; \ --cp; } -#define SKIPTOA() { while ( !isalpha(*cp++) ) ; \ +#define SKIPTOA() { while ( !isalpha((unsigned char) *cp++) ) ; \ --cp; } -#define SKIPSP() { while ( isspace(*cp++) ) ; \ +#define SKIPSP() { while ( isspace((unsigned char) *cp++) ) ; \ --cp; } -#define SKIPTOSP() { while ( !isspace(*cp++) ) ; \ +#define SKIPTOSP() { while ( !isspace((unsigned char) *cp++) ) ; \ --cp; } -#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST # ifdef HAVE_SYS_TIME_H # include # endif @@ -168,7 +167,7 @@ static int day_map[] = { static void zonehack (struct tws *tw) { - register struct tm *tm; + struct tm *tm; if (dmktime (tw) == (time_t) -1) return; @@ -179,7 +178,6 @@ zonehack (struct tws *tw) tw->tw_zone -= 60; } } -#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ %} sun ([Ss]un(day)?) @@ -230,7 +228,7 @@ nl [ \t\n()] YY_BUFFER_STATE lexhandle; - register unsigned char *cp; + char *cp; static struct tws tw; memset(&tw,0,sizeof(struct tws)); @@ -315,17 +313,10 @@ nl [ \t\n()] } {D}("-"|"/"){D}("-"|"/"){YEAR}{W}{TIME} { INIT(); - if(europeandate) { - /* DD/MM/YY */ - SETDAY(); - SKIPTOD(); - SETMON_NUM(); - } else { - /* MM/DD/YY */ + /* MM/DD/YY */ SETMON_NUM(); SKIPTOD(); SETDAY(); - } SKIPTOD(); SETYEAR(); SKIPTOD(); @@ -333,17 +324,10 @@ nl [ \t\n()] } {D}("-"|"/"){D}("-"|"/"){YEAR} { INIT(); - if(europeandate) { - /* DD/MM/YY */ - SETDAY(); - SKIPTOD(); - SETMON_NUM(); - } else { - /* MM/DD/YY */ + /* MM/DD/YY */ SETMON_NUM(); SKIPTOD(); SETDAY(); - } SKIPTOD(); SETYEAR(); } @@ -355,18 +339,14 @@ nl [ \t\n()] INIT(); SKIPTOD(); SETZONE(atoi(cp)); -#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST zonehack (&tw); -#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ yyterminate(); } "-"{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 */ yyterminate(); } @@ -404,4 +384,3 @@ void dtimep_yyunput(int c) { unput(c); } -