From: Ralph Corderoy Date: Sun, 23 Apr 2017 12:18:20 +0000 (+0100) Subject: tws.h: Remove redundant TW_SZONE and TW_SZNIL bit-masks. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/4db310433eb20ec95643299b0d14fefaea44b8bd?ds=inline;hp=b5f387a8a688647ce765609890a6ab86d3257c04 tws.h: Remove redundant TW_SZONE and TW_SZNIL bit-masks. TW_SZONE is a mask of one bit that can either be 0, TW_SZNIL, or set, TW_SZEXP. Rather than three macros for the single bit, have one, TW_SZEXP. Simplifies the test too when the mask is known to be one-bit wide. --- diff --git a/h/tws.h b/h/tws.h index 051ee4c9..03964b60 100644 --- a/h/tws.h +++ b/h/tws.h @@ -29,9 +29,7 @@ struct tws { #define TW_SEXP 0x0001 /* explicitly given */ #define TW_SIMP 0x0002 /* implicitly given */ -#define TW_SZONE 0x0004 /* how timezone was determined */ -#define TW_SZNIL 0x0000 /* not given */ -#define TW_SZEXP 0x0004 /* explicitly given */ +#define TW_SZEXP 0x0004 /* Explicit timezone. */ #define TW_DST 0x0010 /* daylight savings time */ #define TW_ZONE 0x0020 /* use numeric timezones only */ diff --git a/sbr/dtime.c b/sbr/dtime.c index 14051b92..d24694ea 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -113,7 +113,6 @@ dlocaltime (time_t *clock) tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; - tw.tw_flags &= ~TW_SZONE; tw.tw_flags |= TW_SZEXP; tw.tw_clock = *clock; @@ -161,7 +160,6 @@ dgmtime (time_t *clock) tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; - tw.tw_flags &= ~TW_SZONE; tw.tw_flags |= TW_SZEXP; tw.tw_clock = *clock; @@ -256,10 +254,10 @@ dasctime (struct tws *tw, int flags) return NULL; /* Display timezone if known */ - if ((tw->tw_flags & TW_SZONE) == TW_SZNIL) - result[0] = '\0'; - else + if (tw->tw_flags & TW_SZEXP) snprintf(result, sizeof(result), " %s", dtimezone(tw->tw_zone, tw->tw_flags | flags)); + else + result[0] = '\0'; snprintf(buffer, sizeof(buffer), "%02d %s %0*d %02d:%02d:%02d%s", tw->tw_mday, tw_moty[tw->tw_mon], diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 25d864bb..ef3ab1b1 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -833,7 +833,7 @@ fmt_scan (struct format *format, charstring_t scanlp, int width, int *dat, } break; case FT_LV_ZONEF: - if ((fmt->f_comp->c_tws->tw_flags & TW_SZONE) == TW_SZEXP) + if (fmt->f_comp->c_tws->tw_flags & TW_SZEXP) value = 1; else value = -1;