]> diplodocus.org Git - nmh/commitdiff
tws.h: Remove redundant TW_SZONE and TW_SZNIL bit-masks.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 23 Apr 2017 12:18:20 +0000 (13:18 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 23 Apr 2017 12:18:20 +0000 (13:18 +0100)
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.

h/tws.h
sbr/dtime.c
sbr/fmt_scan.c

diff --git a/h/tws.h b/h/tws.h
index 051ee4c96c60a369e6dec079a7229c3d5dd6747a..03964b6094b9c931e144844363b15e97fca3472a 100644 (file)
--- 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     */
index 14051b922460994ccd5f57cd35b47767c46be815..d24694ea45306cd8d167322027691f56ec6005b0 100644 (file)
@@ -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],
index 25d864bb4ab50b2a3dc94fb63c906b3da65184a2..ef3ab1b1b8b975cff1c6bbfeab1bd11631659940 100644 (file)
@@ -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;