- * 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,
- 0,
- 0,
- 6, /* 3 - Sat */
- 4, /* 4 - Thu */
- 0,
- 5, /* 6 - Fri */
- 0, /* 7 - Sun */
- 2, /* 8 - Tue */
- 1 /* 9 - Mon */,
- 0,
- 3 /*11 - Wed */
-};
-
-/* The SET* macros will parse for the appropriate field, and leave the
- * cp pointer at the first character after the desired field. Be
- * careful with variable-length fields or alpha-num mixes.
-
- * The SKIP* macros skip over characters of a particular class and
- * leave cp at the position of the first character that doesn't match
- * that class. Correspondingly, SKIPTO* skips until it reaches a
- * character of a particular class.
- */
-
-#define INIT() { cp = yytext;}
-#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++; \
- tw.tw_mon = month_map[(cp[0] + 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; \
- SKIPD(); }
-#define SETTIME() { tw.tw_hour = atoi(cp); \
- cp += 2; \
- SKIPTOD(); \
- tw.tw_min = atoi(cp); \
- cp += 2; \
- if(*cp == ':') { \
- tw.tw_sec = atoi(++cp); SKIPD(); } }
-#define SETZONE(x) { tw.tw_zone = ((x)/100)*60+(x)%100; \
- tw.tw_flags |= TW_SZEXP; \
- SKIPD(); }
-#define SETDST() { tw.tw_flags |= TW_DST; }
-#define SKIPD() { while ( isdigit(*cp++) ) ; \
- --cp; }
-#define SKIPTOD() { while ( !isdigit(*cp++) ) ; \
- --cp; }
-#define SKIPA() { while ( isalpha(*cp++) ) ; \
- --cp; }
-#define SKIPTOA() { while ( !isalpha(*cp++) ) ; \
- --cp; }
-#define SKIPSP() { while ( isspace(*cp++) ) ; \
- --cp; }
-#define SKIPTOSP() { while ( !isspace(*cp++) ) ; \
- --cp; }
+** The SET* macros will parse for the appropriate field, and leave the
+** cp pointer at the first character after the desired field. Be
+** careful with variable-length fields or alpha-num mixes.
+**
+** The SKIP* macros skip over characters of a particular class and
+** leave cp at the position of the first character that doesn't match
+** that class. Correspondingly, SKIPTO* skips until it reaches a
+** character of a particular class.
+*/
+
+#define INIT() { cp = yytext;}
+#define SETWDAY() { tw.tw_wday = name2num(cp, tw_dotw); \
+ tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; SKIPA(); }
+#define SETMON() { tw.tw_mon = name2num(cp, tw_moty); 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; SKIPD(); }
+#define SETTIME() { tw.tw_hour = atoi(cp); cp += 2; SKIPTOD(); \
+ tw.tw_min = atoi(cp); cp += 2; if(*cp == ':') { \
+ tw.tw_sec = atoi(++cp); SKIPD(); } }
+#define SETZONE(x) { tw.tw_zone = ((x)/100)*60+(x)%100; \
+ tw.tw_flags |= TW_SZEXP; SKIPD(); }
+#define SETZONEC(h, m) { tw.tw_zone = (h)*60+(m); \
+ tw.tw_flags |= TW_SZEXP; SKIPD(); }
+#define SETDST() { tw.tw_flags |= TW_DST; }
+#define SKIPD() { while ( isdigit(*cp++) ) ; --cp; }
+#define SKIPTOD() { while ( !isdigit(*cp++) ) ; --cp; }
+#define SKIPA() { while ( isalpha(*cp++) ) ; --cp; }
+#define SKIPTOA() { while ( !isalpha(*cp++) ) ; --cp; }
+#define SKIPSP() { while ( isspace(*cp++) ) ; --cp; }
+#define SKIPTOSP() { while ( !isspace(*cp++) ) ; --cp; }
+
+#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# endif
+#include <time.h>
+
+static void
+zonehack (struct tws *tw)
+{
+ 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 */