]> diplodocus.org Git - nmh/commitdiff
tws.h: Remove zero-valued TW_SNIL macro, used once.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 23 Apr 2017 12:33:57 +0000 (13:33 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 23 Apr 2017 12:33:57 +0000 (13:33 +0100)
Macro TW_SNIL was the zero value for a two-bit field.  It was only used
once, and that is better ordered to check for bits set with none set
being the last, else, case, rather than in the middle.  Kept the
behaviour of undefined value 3 being treated as TW_SIMP, 2.

h/tws.h
sbr/dtime.c

diff --git a/h/tws.h b/h/tws.h
index 03964b6094b9c931e144844363b15e97fca3472a..66e33613954933562b1a2d45c6ac23242ad1d265 100644 (file)
--- a/h/tws.h
+++ b/h/tws.h
@@ -25,7 +25,6 @@ struct tws {
 #define        TW_NULL  0x0000
 
 #define        TW_SDAY  0x0003 /* how day-of-week was determined */
-#define        TW_SNIL  0x0000 /*   not given                    */
 #define        TW_SEXP  0x0001 /*   explicitly given             */
 #define        TW_SIMP  0x0002 /*   implicitly given             */
 
index d24694ea45306cd8d167322027691f56ec6005b0..53c565786a97cbbc6d812a62e4fef4058f6c7515 100644 (file)
@@ -249,6 +249,7 @@ dasctime (struct tws *tw, int flags)
 {
     char buffer[80];
     static char result[80];
+    int twf;
 
     if (!tw)
        return NULL;
@@ -264,13 +265,13 @@ dasctime (struct tws *tw, int flags)
            tw->tw_year < 100 ? 2 : 4, tw->tw_year,
            tw->tw_hour, tw->tw_min, tw->tw_sec, result);
 
-    if ((tw->tw_flags & TW_SDAY) == TW_SEXP)
-       snprintf (result, sizeof(result), "%s, %s", tw_dotw[tw->tw_wday], buffer);
-    else
-       if ((tw->tw_flags & TW_SDAY) == TW_SNIL)
-           strncpy (result, buffer, sizeof(result));
-       else
-           snprintf (result, sizeof(result), "%s (%s)", buffer, tw_dotw[tw->tw_wday]);
+    if ((twf = tw->tw_flags & TW_SDAY)) {
+        if (twf == TW_SEXP)
+            snprintf(result, sizeof(result), "%s, %s", tw_dotw[tw->tw_wday], buffer);
+        else
+           snprintf(result, sizeof(result), "%s (%s)", buffer, tw_dotw[tw->tw_wday]);
+    } else
+        strncpy(result, buffer, sizeof(result));
 
     return result;
 }