]> diplodocus.org Git - nmh/commitdiff
uip: Replace some ints that are only ever 0 or 1 with bool.
authorRalph Corderoy <ralph@inputplus.co.uk>
Wed, 1 Nov 2017 00:09:32 +0000 (00:09 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 1 Nov 2017 00:09:32 +0000 (00:09 +0000)
Knowing the domain of the variable is Boolean aids comprehension of the
variable's name and purpose.

uip/folder.c
uip/forw.c
uip/imaptest.c
uip/inc.c
uip/install-mh.c
uip/mark.c
uip/mhbuild.c
uip/mhlist.c
uip/mhlsbr.c
uip/mhn.c

index 2141f32..97a1fdc 100644 (file)
@@ -47,12 +47,12 @@ DEFINE_SWITCH_ENUM(FOLDER);
 DEFINE_SWITCH_ARRAY(FOLDER, switches);
 #undef X
 
-static int fshort   = 0;       /* output only folder names                 */
+static bool fshort;            /* output only folder names                 */
 static int fcreat   = 0;       /* should we ask to create new folders?     */
-static int fpack    = 0;       /* are we packing the folder?               */
-static int fverb    = 0;       /* print actions taken while packing folder */
+static bool fpack;             /* are we packing the folder?               */
+static bool fverb;             /* print actions taken while packing folder */
 static int fheader  = 0;       /* should we output a header?               */
-static int frecurse = 0;       /* recurse through subfolders               */
+static bool frecurse;          /* recurse through subfolders               */
 static int ftotal   = 0;       /* should we output the totals?             */
 static bool all;               /* should we output all folders             */
 
@@ -159,10 +159,10 @@ main (int argc, char **argv)
                    continue;
 
                case FASTSW: 
-                   fshort++;
+                   fshort = true;
                    continue;
                case NFASTSW: 
-                   fshort = 0;
+                   fshort = false;
                    continue;
 
                case HDRSW: 
@@ -173,24 +173,24 @@ main (int argc, char **argv)
                    continue;
 
                case PACKSW: 
-                   fpack++;
+                   fpack = true;
                    continue;
                case NPACKSW: 
-                   fpack = 0;
+                   fpack = false;
                    continue;
 
                case VERBSW:
-                   fverb++;
+                   fverb = true;
                    continue;
                case NVERBSW:
-                   fverb = 0;
+                   fverb = false;
                    continue;
 
                case RECURSW: 
-                   frecurse++;
+                   frecurse = true;
                    continue;
                case NRECRSW: 
-                   frecurse = 0;
+                   frecurse = false;
                    continue;
 
                case TOTALSW: 
index 3d52696..6e9f3bd 100644 (file)
@@ -102,9 +102,13 @@ static void copy_mime_draft (int);
 int
 main (int argc, char **argv)
 {
-    int anot = 0, inplace = 1, mime = 0;
+    bool anot = false;
+    bool inplace = true;
+    bool mime = false;
     int issue = 0, volume = 0, dashstuff = 0;
-    int nedit = 0, nwhat = 0, i, in;
+    bool nedit = false;
+    bool nwhat = false;
+    int i, in;
     int out, isdf = 0, msgnum = 0;
     int outputlinelen = OUTPUTLINELEN;
     int dat[5];
@@ -116,7 +120,7 @@ main (int argc, char **argv)
     char **argp, **arguments;
     struct stat st;
     struct msgs_array msgs = { 0, 0, NULL };
-    int buildsw = 0;
+    bool buildsw = false;
 
     if (nmh_init(argv[0], true, true)) { return 1; }
 
@@ -142,31 +146,31 @@ main (int argc, char **argv)
                    done (0);
 
                case ANNOSW: 
-                   anot++;
+                   anot = true;
                    continue;
                case NANNOSW: 
-                   anot = 0;
+                   anot = false;
                    continue;
 
                case EDITRSW: 
                    if (!(ed = *argp++) || *ed == '-')
                        die("missing argument to %s", argp[-2]);
-                   nedit = 0;
+                   nedit = false;
                    continue;
                case NEDITSW:
-                   nedit++;
+                   nedit = true;
                    continue;
 
                case WHATSW: 
                    if (!(whatnowproc = *argp++) || *whatnowproc == '-')
                        die("missing argument to %s", argp[-2]);
-                   nwhat = 0;
+                   nwhat = false;
                    continue;
                case BILDSW:
-                   buildsw++;
+                   buildsw = true;
                    /* FALLTHRU */
                case NWHATSW: 
-                   nwhat++;
+                   nwhat = true;
                    continue;
 
                case FILESW: 
@@ -180,7 +184,7 @@ main (int argc, char **argv)
                    if (!(cp = *argp++) || *cp == '-')
                        die("missing argument to %s", argp[-2]);
                    filter = mh_xstrdup(etcpath(cp));
-                   mime = 0;
+                   mime = false;
                    continue;
                case FORMSW: 
                    if (!(form = *argp++) || *form == '-')
@@ -195,25 +199,25 @@ main (int argc, char **argv)
                    continue;
 
                case INPLSW: 
-                   inplace++;
+                   inplace = true;
                    continue;
                case NINPLSW: 
-                   inplace = 0;
+                   inplace = false;
                    continue;
 
                case MIMESW:
-                   mime++;
+                   mime = true;
                    filter = NULL;
                    continue;
                case NMIMESW: 
-                   mime = 0;
+                   mime = false;
                    continue;
 
                case DGSTSW: 
                    if (!(cp = *argp++) || *cp == '-')
                        die("missing argument to %s", argp[-2]);
                    digest = mh_xstrdup(cp);
-                   mime = 0;
+                   mime = false;
                    continue;
                case ISSUESW:
                    if (!(cp = *argp++) || *cp == '-')
@@ -342,7 +346,7 @@ try_it_again:
        /*
         * Forwarding a file.
          */
-       anot = 0;       /* don't want to annotate a file */
+       anot = false;   /* don't want to annotate a file */
     } else {
        /*
         * Forwarding a message.
index e51fe2c..def3bd8 100644 (file)
@@ -702,7 +702,7 @@ get_imap_response(netsec_context *nsc, const char *token, char **tokenresponse,
 {
     char *line;
     struct imap_cmd *cmd;
-    int numerrs = 0;
+    bool numerrs = false;
 
     if (tokenresponse)
        *tokenresponse = NULL;
@@ -733,7 +733,7 @@ getline:
                        cmd->next = cmd->next->next;
                        if (failerr && strncmp(line + strlen(cmd2->tag),
                                                        "OK ", 3) != 0) {
-                           numerrs++;
+                           numerrs = true;
                            netsec_err(errstr, "%s", line + strlen(cmd2->tag));
                        }
                        free(cmd2);
@@ -749,7 +749,7 @@ getline:
        }
     }
 
-    return numerrs == 0 ? OK : NOTOK;
+    return numerrs ? NOTOK : OK;
 }
 
 /*
index d65c46f..44d6193 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -99,7 +99,7 @@ static struct Maildir_entry {
        time_t mtime;
 } *Maildir = NULL;
 static int num_maildir_entries = 0;
-static int snoop = 0;
+static bool snoop;
 
 typedef struct {
     FILE *mailout;
@@ -329,7 +329,7 @@ main (int argc, char **argv)
                continue;
 
            case SNOOPSW:
-               snoop++;
+               snoop = true;
                continue;
        
            case SASLSW:
index c3fc4f7..f059296 100644 (file)
@@ -31,7 +31,7 @@ DEFINE_SWITCH_ARRAY(INSTALLMH, switches);
 int
 main (int argc, char **argv)
 {
-    int autof = 0;
+    bool autof = false;
     char *cp, buf[BUFSIZ];
     const char *pathname;
     char *dp, **arguments, **argp;
@@ -66,7 +66,7 @@ main (int argc, char **argv)
                    done (0);
 
                case AUTOSW:
-                   autof++;
+                   autof = true;
                    continue;
 
                case CHECKSW:
index 8c02825..3941e93 100644 (file)
@@ -43,8 +43,13 @@ static void seq_printdebug (struct msgs *);
 int
 main (int argc, char **argv)
 {
-    int addsw = 0, deletesw = 0, debugsw = 0;
-    int listsw = 0, publicsw = -1, zerosw = 0, msgnum;
+    bool addsw = false;
+    bool deletesw = false;
+    bool debugsw = false;
+    bool listsw = false;
+    int publicsw = -1;
+    bool zerosw = false;
+    int msgnum;
     unsigned int seqp = 0;
     char *cp, *maildir, *folder = NULL, buf[BUFSIZ];
     char **argp, **arguments;
@@ -79,16 +84,19 @@ main (int argc, char **argv)
                done (0);
 
            case ADDSW: 
-               addsw++;
-               deletesw = listsw = 0;
+               addsw = true;
+               deletesw = false;
+                listsw = false;
                continue;
            case DELSW: 
-               deletesw++;
-               addsw = listsw = 0;
+               deletesw = true;
+               addsw = false;
+                listsw = false;
                continue;
            case LSTSW: 
-               listsw++;
-               addsw = deletesw = 0;
+               listsw = true;
+               addsw = false;
+                deletesw = false;
                continue;
 
            case SEQSW: 
@@ -107,14 +115,14 @@ main (int argc, char **argv)
                continue;
 
            case DEBUGSW: 
-               debugsw++;
+               debugsw = true;
                continue;
 
            case ZEROSW: 
-               zerosw++;
+               zerosw = true;
                continue;
            case NZEROSW: 
-               zerosw = 0;
+               zerosw = false;
                continue;
            }
        }
@@ -133,9 +141,9 @@ main (int argc, char **argv)
      */
     if (!addsw && !deletesw && !listsw) {
        if (seqp)
-           addsw++;
+           addsw = true;
        else
-           listsw++;
+           listsw = true;
     }
 
     if (!context_find ("path"))
index 2306e37..d9ad442 100644 (file)
@@ -89,11 +89,12 @@ static char outfile[BUFSIZ];
 int
 main (int argc, char **argv)
 {
-    int sizesw = 1, headsw = 1;
+    bool sizesw = true;
+    bool headsw = true;
     bool directives = true;
     bool autobuild = false;
     bool dist = false;
-    int verbosw = 0;
+    bool verbosw = false;
     bool dispo = false;
     size_t maxunencoded = MAXTEXTPERLN;
     int *icachesw;
@@ -117,7 +118,7 @@ main (int argc, char **argv)
                die("cannot specify both standard input and a file");
             compfile = cp;
            listsw = false;     /* turn off -list if using standard in/out */
-           verbosw = 0;        /* turn off -verbose listings */
+           verbosw = false;    /* turn off -verbose listings */
            break;
        }
        if (*cp == '-') {
@@ -177,10 +178,10 @@ main (int argc, char **argv)
                continue;
 
            case HEADSW:
-               headsw++;
+               headsw = true;
                continue;
            case NHEADSW:
-               headsw = 0;
+               headsw = false;
                continue;
 
            case DIRECTIVES:
@@ -205,10 +206,10 @@ main (int argc, char **argv)
                continue;
 
            case SIZESW:
-               sizesw++;
+               sizesw = true;
                continue;
            case NSIZESW:
-               sizesw = 0;
+               sizesw = false;
                continue;
 
            case CONTENTIDSW:
@@ -258,10 +259,10 @@ main (int argc, char **argv)
                continue;
 
            case VERBSW: 
-               verbosw++;
+               verbosw = true;
                continue;
            case NVERBSW: 
-               verbosw = 0;
+               verbosw = false;
                continue;
            case DISPOSW:
                dispo = true;
index 1a1ccf9..dd9b6d0 100644 (file)
@@ -71,7 +71,7 @@ main (int argc, char **argv)
 {
     bool sizesw = true;
     bool headsw = true;
-    int chgflag = 1;
+    bool chgflag = true;
     bool verbosw = false;
     bool dispo = false;
     int msgnum, *icachesw;
@@ -191,10 +191,10 @@ do_cache:
                continue;
 
            case CHGSW:
-               chgflag++;
+               chgflag = true;
                continue;
            case NCHGSW:
-               chgflag = 0;
+               chgflag = false;
                continue;
 
            case VERBSW: 
index 6253994..ef9f830 100644 (file)
@@ -261,8 +261,8 @@ static int bellflg   = 0;
 static int clearflg  = 0;
 static int dashstuff = 0;
 static bool dobody = true;
-static int forwflg   = 0;
-static int forwall   = 0;
+static bool forwflg;
+static bool forwall;
 
 static int sleepsw = NOTOK;
 
@@ -271,7 +271,7 @@ static int volume = 0;
 static int issue = 0;
 
 static int exitstat = 0;
-static int mhldebug = 0;
+static bool mhldebug;
 
 static int filesize = 0;
 
@@ -338,7 +338,8 @@ static void compile_filterargs (void);
 int
 mhl (int argc, char **argv)
 {
-    int length = 0, nomore = 0;
+    int length = 0;
+    bool nomore = false;
     unsigned int i, vecp = 0;
     int width = 0;
     char *cp, *folder = NULL, *form = NULL;
@@ -352,7 +353,7 @@ mhl (int argc, char **argv)
     argp = arguments;
 
     if ((cp = getenv ("MHLDEBUG")) && *cp)
-       mhldebug++;
+       mhldebug = true;
 
     while ((cp = *argp++)) {
        if (*cp == '-') {
@@ -405,7 +406,7 @@ mhl (int argc, char **argv)
                        mhladios (NULL, "missing argument to %s", argp[-2]);
                    continue;
                case NPROGSW:
-                   nomore++;
+                   nomore = true;
                    continue;
 
                case FMTPROCSW:
@@ -447,10 +448,10 @@ mhl (int argc, char **argv)
                    continue;
 
                case FORW2SW: 
-                   forwall++;
+                   forwall = true;
                    /* FALLTHRU */
                case FORW1SW: 
-                   forwflg++;
+                   forwflg = true;
                    clearflg = -1;/* XXX */
                    continue;
 
@@ -1267,7 +1268,8 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
 {
     char *text; /* c1's text, or the name as a fallback. */
     char *trimmed_prefix;
-    int count, cchdr;
+    int count;
+    bool cchdr;
     char *cp;
     const int utf8 = strcasecmp(get_charset(), "UTF-8") == 0;
 
@@ -1282,7 +1284,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
      * blank lines. */
     trimmed_prefix = rtrim(mh_xstrdup(FENDNULL(text)));
 
-    cchdr = 0;
+    cchdr = false;
     lm = 0;
     llim = c1->c_length ? c1->c_length : -1;
     wid = c1->c_width ? c1->c_width : global.c_width;
@@ -1325,7 +1327,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
            if (!(c1->c_flags & SPLIT))
                c1->c_flags |= HDROUTPUT;
 
-       cchdr++;
+       cchdr = true;
        if ((count = c1->c_cwidth - strlen(text) - 2) > 0)
            while (count--)
                putstr (" ", c1->c_flags);
@@ -1344,7 +1346,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
        if (!(c1->c_flags & SPLIT))
            c2->c_flags |= HDROUTPUT;
 
-       cchdr++;
+       cchdr = true;
        if ((count = c1->c_cwidth - strlen (c2->c_name) - 2) > 0)
            while (count--)
                putstr (" ", c1->c_flags);
@@ -1397,7 +1399,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
 static char *
 oneline (char *stuff, unsigned long flags)
 {
-    int spc;
+    bool spc;
     char *cp, *ret;
 
     if (onelp == NULL)
@@ -1408,7 +1410,7 @@ oneline (char *stuff, unsigned long flags)
     ret = onelp;
     term = 0;
     if (flags & COMPRESS) {
-       for (spc = 1, cp = ret; *onelp; onelp++)
+       for (spc = true, cp = ret; *onelp; onelp++)
            if (isspace ((unsigned char) *onelp)) {
                if (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT))) {
                    term = '\n';
@@ -1417,12 +1419,12 @@ oneline (char *stuff, unsigned long flags)
                }
                 if (!spc) {
                     *cp++ = ' ';
-                    spc++;
+                    spc = true;
                 }
            }
            else {
                *cp++ = *onelp;
-               spc = 0;
+               spc = false;
            }
 
        *cp = 0;
index 0d1d48e..9e50688 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -89,7 +89,7 @@ static int rfc934sw = 0;
 /*
  * what action to take?
  */
-static int cachesw = 0;
+static bool cachesw;
 static bool listsw;
 static bool showsw;
 static bool storesw;
@@ -107,7 +107,7 @@ main (int argc, char **argv)
 {
     bool sizesw = true;
     bool headsw = true;
-    int autosw = 0;
+    bool autosw = false;
     int msgnum, *icachesw;
     char *cp, *file = NULL, *folder = NULL;
     char *maildir, buf[100], **argp;
@@ -148,17 +148,17 @@ main (int argc, char **argv)
                done (0);
 
            case AUTOSW:
-               autosw++;
+               autosw = true;
                continue;
            case NAUTOSW:
-               autosw = 0;
+               autosw = false;
                continue;
 
            case CACHESW:
-               cachesw++;
+               cachesw = true;
                continue;
            case NCACHESW:
-               cachesw = 0;
+               cachesw = false;
                continue;
 
            case RCACHESW: