From: Ralph Corderoy Date: Wed, 1 Nov 2017 17:21:23 +0000 (+0000) Subject: uip: Replace some ints that are only ever 0 or 1 with bool. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/06efa573c7894caa4e5aa1ac7c64bd10ea25928b?ds=inline;hp=d4aff07086b9c2296a9dcac2f04f9f371b5801c4 uip: Replace some ints that are only ever 0 or 1 with bool. Knowing the domain of the variable is Boolean aids comprehension of the variable's name and purpose. --- diff --git a/uip/mhstore.c b/uip/mhstore.c index 6f2fdd39..66ad91e9 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -63,7 +63,8 @@ static void pipeser (int); int main (int argc, char **argv) { - int msgnum, *icachesw, autosw = 0; + int msgnum, *icachesw; + bool autosw = false; /* verbosw defaults to 1 for backward compatibility. */ bool verbosw = true; const char *clobbersw = "always"; @@ -107,10 +108,10 @@ main (int argc, char **argv) done (0); case AUTOSW: - autosw++; + autosw = true; continue; case NAUTOSW: - autosw = 0; + autosw = false; continue; case RCACHESW: diff --git a/uip/msgchk.c b/uip/msgchk.c index 21aca33b..bf95d907 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -78,9 +78,14 @@ static int remotemail (char *, char *, char *, char *, int, int, int, int, int main (int argc, char **argv) { - int datesw = 1, notifysw = NT_ALL; - int status = 0, sasl = 0, tls = 0, noverify = 0; - int snoop = 0, vecp = 0; + bool datesw = true; + int notifysw = NT_ALL; + int status = 0; + bool sasl = false; + bool tls = false; + bool noverify = false; + bool snoop = false; + int vecp = 0; char *cp, *host = NULL, *port = NULL, *user = NULL, *proxy = NULL; char buf[BUFSIZ], *saslmech = NULL, *auth_svc = NULL; char **argp, **arguments, *vec[MAXVEC]; @@ -112,10 +117,10 @@ main (int argc, char **argv) done (0); case DATESW: - datesw++; + datesw = true; continue; case NDATESW: - datesw = 0; + datesw = false; continue; case NOTESW: @@ -148,15 +153,15 @@ main (int argc, char **argv) continue; case SNOOPSW: - snoop++; + snoop = true; continue; case SASLSW: - sasl++; + sasl = true; continue; case NOSASLSW: - sasl = 0; + sasl = false; continue; case SASLMECHSW: @@ -165,19 +170,19 @@ main (int argc, char **argv) continue; case INITTLSSW: - tls++; + tls = true; continue; case NOTLSSW: - tls = 0; + tls = false; continue; case CERTVERSW: - noverify = 0; + noverify = false; continue; case NOCERTVERSW: - noverify++; + noverify = true; continue; case AUTHSERVICESW: diff --git a/uip/pick.c b/uip/pick.c index 01e2081a..967e1255 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -56,7 +56,9 @@ static void putzero_done (int) NORETURN; int main (int argc, char **argv) { - int publicsw = -1, zerosw = 1, vecp = 0; + int publicsw = -1; + bool zerosw = true; + int vecp = 0; size_t seqp = 0; int msgnum; char *maildir, *folder = NULL, buf[100]; @@ -153,10 +155,10 @@ main (int argc, char **argv) publicsw = 0; continue; case ZEROSW: - zerosw++; + zerosw = true; continue; case NZEROSW: - zerosw = 0; + zerosw = false; continue; case LISTSW: diff --git a/uip/picksbr.c b/uip/picksbr.c index a5184799..4d4d99a1 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -644,21 +644,23 @@ cerror: ; static int GREPaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop) { - int c, body, lf; + int c; + bool body; + bool lf; long pos = start; char *p1, *p2, *ebp, *cbp; char ibuf[BUFSIZ]; NMH_UNUSED (msgnum); fseek (fp, start, SEEK_SET); - body = 0; + body = false; ebp = cbp = ibuf; for (;;) { if (body && n->n_header) return 0; p1 = linebuf; p2 = cbp; - lf = 0; + lf = false; for (;;) { if (p2 >= ebp) { if (fgets (ibuf, sizeof ibuf, fp) == NULL @@ -677,16 +679,16 @@ GREPaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop) --p2; break; } - lf = 0; + lf = false; } if (c == '\n') { if (body) break; if (lf) { - body++; + body = true; break; } - lf++; + lf = true; /* Unfold by skipping the newline. */ c = 0; } @@ -701,7 +703,7 @@ GREPaction(struct nexus *n, FILE *fp, int msgnum, long start, long stop) /* Attempt to decode as a MIME header. If it's the last header, body will be 1 and lf will be at least 1. */ - if ((body == 0 || lf > 0) && + if ((!body || lf) && decode_rfc2047 (linebuf, decoded_linebuf, sizeof decoded_linebuf)) { p1 = decoded_linebuf; } diff --git a/uip/popsbr.c b/uip/popsbr.c index ac1117be..1466a2e1 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -39,7 +39,8 @@ static int pop_sasl_callback(enum sasl_message_type, unsigned const char *, static int check_mech(char *server_mechs, size_t server_mechs_size) { - int status, sasl_capability = 0; + int status; + bool sasl_capability = false; /* * First off, we're going to send the CAPA command to see if we can @@ -62,7 +63,7 @@ check_mech(char *server_mechs, size_t server_mechs_size) if (strncasecmp(response, "SASL ", 5) == 0) { /* We've seen the SASL capability. Grab the mech list. */ - sasl_capability++; + sasl_capability = true; strncpy(server_mechs, response + 5, server_mechs_size); } } diff --git a/uip/post.c b/uip/post.c index 2917945b..c2af2948 100644 --- a/uip/post.c +++ b/uip/post.c @@ -225,27 +225,27 @@ static short fccind = 0; /* index into fccfold[] */ static short outputlinelen = OUTPUTLINELEN; static int pfd = NOTOK; /* fd to write annotation list to */ -static int recipients = 0; /* how many people will get a copy */ +static bool recipients; /* how many people will get a copy */ static int unkadr = 0; /* how many of those were unknown */ static int badadr = 0; /* number of bad addrs */ -static int badmsg = 0; /* message has bad semantics */ -static int verbose = 0; /* spell it out */ +static bool badmsg; /* message has bad semantics */ +static bool verbose; /* spell it out */ static bool format = true; /* format addresses */ -static int mime = 0; /* use MIME-style encapsulations for Bcc */ -static int msgid = 0; /* add msgid */ -static int debug = 0; /* debugging post */ -static int watch = 0; /* watch the delivery process */ -static int whomsw = 0; /* we are whom not post */ -static int checksw = 0; /* whom -check */ +static bool mime; /* use MIME-style encapsulations for Bcc */ +static bool msgid; /* add msgid */ +static bool debug; /* debugging post */ +static bool watch; /* watch the delivery process */ +static bool whomsw; /* we are whom not post */ +static bool checksw; /* whom -check */ static int linepos=0; /* putadr()'s position on the line */ static int nameoutput=0; /* putadr() has output header name */ -static int sasl=0; /* Use SASL auth for SMTP */ +static bool sasl; /* Use SASL auth for SMTP */ static char *saslmech=NULL; /* Force use of particular SASL mech */ static char *user=NULL; /* Authenticate as this user */ static char *port="submission"; /* Name of server port for SMTP submission */ static int tlsflag=0; /* Flags to control TLS settings */ static int fromcount=0; /* Count of addresses on From: header */ -static int seensender=0; /* Have we seen a Sender: header? */ +static bool seensender; /* Have we seen a Sender: header? */ static unsigned msgflags = 0; /* what we've seen */ @@ -277,7 +277,7 @@ static struct mailname netaddrs; /* network addrs */ static struct mailname uuaddrs; /* uucp addrs */ static struct mailname tmpaddrs; /* temporary queue */ -static int snoop = 0; +static bool snoop; static char *clientsw = NULL; static char *serversw = NULL; @@ -318,8 +318,10 @@ static int find_prefix (void); int main (int argc, char **argv) { - int state, compnum, dashstuff = 0, swnum, oauth_flag = 0, tls = -1; - int noverify = 0; + int state, compnum, dashstuff = 0, swnum; + bool oauth_flag = false; + int tls = -1; + bool noverify = false; int eai = 0; /* use Email Address Internationalization (EAI) (SMTPUTF8) */ char *cp, *msg = NULL, **argp, **arguments, *envelope; char buf[NMH_BUFSIZ], name[NAMESZ], *auth_svc = NULL; @@ -366,14 +368,14 @@ main (int argc, char **argv) continue; case CHKSW: - checksw++; + checksw = true; continue; case NCHKSW: - checksw = 0; + checksw = false; continue; case DEBUGSW: - debug++; + debug = true; continue; case DISTSW: @@ -383,7 +385,7 @@ main (int argc, char **argv) case FILTSW: if (!(filter = *argp++) || *filter == '-') die("missing argument to %s", argp[-2]); - mime = 0; + mime = false; continue; case NFILTSW: filter = NULL; @@ -404,36 +406,36 @@ main (int argc, char **argv) continue; case MIMESW: - mime++; + mime = true; filter = NULL; continue; case NMIMESW: - mime = 0; + mime = false; continue; case MSGDSW: - msgid++; + msgid = true; continue; case NMSGDSW: - msgid = 0; + msgid = false; continue; case VERBSW: - verbose++; + verbose = true; continue; case NVERBSW: - verbose = 0; + verbose = false; continue; case WATCSW: - watch++; + watch = true; continue; case NWATCSW: - watch = 0; + watch = false; continue; case WHOMSW: - whomsw++; + whomsw = true; continue; case WIDTHSW: @@ -459,7 +461,7 @@ main (int argc, char **argv) die("missing argument to %s", argp[-2]); continue; case SNOOPSW: - snoop++; + snoop = true; continue; case PARTSW: @@ -468,11 +470,11 @@ main (int argc, char **argv) continue; case SASLSW: - sasl++; + sasl = true; continue; case NOSASLSW: - sasl = 0; + sasl = false; continue; case SASLMECHSW: @@ -483,7 +485,7 @@ main (int argc, char **argv) case AUTHSERVICESW: if (!(auth_svc = *argp++) || *auth_svc == '-') die("missing argument to %s", argp[-2]); - oauth_flag++; + oauth_flag = true; continue; case OAUTHCREDFILESW: @@ -510,7 +512,7 @@ main (int argc, char **argv) die("internal error: cannot map switch %s " "to profile entry", argp[-2]); - oauth_flag++; + oauth_flag = true; continue; } @@ -537,11 +539,11 @@ main (int argc, char **argv) continue; case CERTVERSW: - noverify = 0; + noverify = false; continue; case NOCERTVERSW: - noverify++; + noverify = true; continue; case FILEPROCSW: @@ -601,7 +603,7 @@ main (int argc, char **argv) start_headers (); if (debug) { - verbose++; + verbose = true; out = stdout; } else { if (whomsw) { @@ -788,7 +790,9 @@ main (int argc, char **argv) static void putfmt (char *name, char *str, int *eai, FILE *out) { - int count, grp, i, keep; + int count; + bool grp; + int i, keep; char *cp, *pp, *qp; char namep[BUFSIZ], error[BUFSIZ]; char *savehdr = NULL; @@ -801,7 +805,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) if (msgstate == NORMAL && uprf (name, "resent")) { inform("illegal header line -- %s:", name); - badmsg++; + badmsg = true; return; } @@ -845,7 +849,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) } if (hdr->flags & HBAD) { inform("illegal header line -- %s:", name); - badmsg++; + badmsg = true; return; } msgflags |= (hdr->set & ~(MVIS | MINV)); @@ -904,7 +908,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) if (hdr->flags & HTRY) badadr++; else - badmsg++; + badmsg = true; } } @@ -918,11 +922,11 @@ putfmt (char *name, char *str, int *eai, FILE *out) if ((msgstate == RESENT) ? (hdr->set & MRSN) : (hdr->set & MSND)) { inform("%s: field requires one address", name); - badmsg++; + badmsg = true; } #ifdef notdef inform("%s: field requires at least one address", name); - badmsg++; + badmsg = true; #endif /* notdef */ } return; @@ -930,7 +934,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) if (count > 1 && (hdr->flags & HONE)) { inform("%s: field only permits one address", name); - badmsg++; + badmsg = true; return; } @@ -938,7 +942,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) snprintf (namep, sizeof(namep), "%s%s", (hdr->flags & HMNG) ? "Original-" : "", name); - for (grp = 0, mp = tmpaddrs.m_next; mp; mp = np) + for (grp = false, mp = tmpaddrs.m_next; mp; mp = np) if (mp->m_nohost) { /* also used to test (hdr->flags & HTRY) */ /* The address doesn't include a host, so it might be an alias. */ pp = akvalue (mp->m_mbox); /* do mh alias substitution */ @@ -973,7 +977,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) : (hdr->set & MSND)) { strncpy(sender, auxformat(mp, 0), sizeof(sender) - 1); sender[sizeof(sender) - 1] = '\0'; - seensender++; + seensender = true; } /* @@ -1004,7 +1008,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) " sendmail/pipe"); } - grp++; + grp = true; } if (putadr (namep, qp, mp, out, hdr->flags, savehdr, savehdrlen)) @@ -1038,7 +1042,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) : (hdr->set & MSND)) { strncpy(sender, auxformat(mp, 0), sizeof(sender) - 1); sender[sizeof(sender) - 1] = '\0'; - seensender++; + seensender = true; } /* @@ -1055,7 +1059,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) if (mp->m_gname) putgrp (namep, mp->m_gname, out, hdr->flags); if (mp->m_ingrp) - grp++; + grp = true; keep = putadr (namep, "", mp, out, hdr->flags, savehdr, savehdrlen); np = mp->m_next; if (keep) { @@ -1077,9 +1081,9 @@ putfmt (char *name, char *str, int *eai, FILE *out) } } - if (grp > 0 && (hdr->flags & HNGR)) { + if (grp && (hdr->flags & HNGR)) { inform("%s: field does not allow groups", name); - badmsg++; + badmsg = true; } if (linepos) { putc ('\n', out); @@ -1120,14 +1124,14 @@ finish_headers (FILE *out) */ inform("message has no From: header"); inform("See default components files for examples"); - badmsg++; + badmsg = true; break; } - if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) { + if (fromcount > 1 && (!seensender && !(msgflags & MEFM))) { inform("A Sender: or Envelope-From: header is required " "with multiple\nFrom: addresses"); - badmsg++; + badmsg = true; break; } @@ -1143,12 +1147,12 @@ finish_headers (FILE *out) * from Envelope-From: (which in this case, cannot be blank) */ - if (fromcount > 1 && seensender == 0) { + if (fromcount > 1 && !seensender) { if (efrom[0] == '\0') { inform("Envelope-From cannot be blank when there " "is multiple From: addresses\nand no Sender: " "header"); - badmsg++; + badmsg = true; } else { fprintf (out, "Sender: %s\n", efrom); } @@ -1161,22 +1165,22 @@ finish_headers (FILE *out) case RESENT: if (!(msgflags & MDAT)) { inform("message has no Date: header"); - badmsg++; + badmsg = true; } if (!(msgflags & MFRM)) { inform("message has no From: header"); - badmsg++; + badmsg = true; } if (!(msgflags & MRFM)) { inform("message has no Resent-From: header"); inform("See default components files for examples"); - badmsg++; + badmsg = true; break; } - if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) { + if (fromcount > 1 && (!seensender && !(msgflags & MEFM))) { inform("A Resent-Sender: or Envelope-From: header is " "required with multiple\nResent-From: addresses"); - badmsg++; + badmsg = true; break; } @@ -1193,12 +1197,12 @@ finish_headers (FILE *out) * from Envelope-From (which in this case, cannot be blank) */ - if (fromcount > 1 && seensender == 0) { + if (fromcount > 1 && !seensender) { if (efrom[0] == '\0') { inform("Envelope-From cannot be blank when there " "is multiple Resent-From: addresses and no " "Resent-Sender: header"); - badmsg++; + badmsg = true; } else { fprintf (out, "Resent-Sender: %s\n", efrom); } @@ -1359,7 +1363,7 @@ insert (struct mailname *np) return 0; mp->m_next = np; - recipients++; + recipients = true; return 1; } diff --git a/uip/prompter.c b/uip/prompter.c index 1564852d..2c346607 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -42,7 +42,7 @@ DEFINE_SWITCH_ARRAY(PROMPTER, switches); static struct termios tio; static bool wtuser; -static int sigint = 0; +static bool sigint; static jmp_buf sigenv; /* @@ -57,8 +57,11 @@ static void intrser (int); int main (int argc, char **argv) { - int body = 1, prepend = 1, rapid = 0; - int doteof = 0, fdi, fdo, i, state; + bool body = true; + bool prepend = true; + bool rapid = false; + bool doteof = false; + int fdi, fdo, i, state; char *cp, *drft = NULL, *erasep = NULL; char *killp = NULL, name[NAMESZ], field[NMH_BUFSIZ]; char buffer[BUFSIZ]; @@ -100,31 +103,31 @@ main (int argc, char **argv) continue; case PREPSW: - prepend++; + prepend = true; continue; case NPREPSW: - prepend = 0; + prepend = false; continue; case RAPDSW: - rapid++; + rapid = true; continue; case NRAPDSW: - rapid = 0; + rapid = false; continue; case BODYSW: - body++; + body = true; continue; case NBODYSW: - body = 0; + body = false; continue; case DOTSW: - doteof++; + doteof = true; continue; case NDOTSW: - doteof = 0; + doteof = false; continue; } } else { @@ -177,7 +180,7 @@ main (int argc, char **argv) tio.c_cc[VERASE] = save_erase; } - sigint = 0; + sigint = false; SIGNAL2 (SIGINT, intrser); /* @@ -379,7 +382,7 @@ intrser (int i) if (wtuser) longjmp (sigenv, NOTOK); - sigint++; + sigint = true; } diff --git a/uip/rcvstore.c b/uip/rcvstore.c index d952a3a2..e3277093 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -47,8 +47,9 @@ static void unlink_done(int) NORETURN; int main (int argc, char **argv) { - int publicsw = -1, zerosw = 0; - int create = 1; + int publicsw = -1; + bool zerosw = false; + bool create = true; bool unseensw = true; int fd, msgnum; size_t seqp = 0; @@ -108,17 +109,17 @@ main (int argc, char **argv) continue; case ZEROSW: - zerosw++; + zerosw = true; continue; case NZEROSW: - zerosw = 0; + zerosw = false; continue; case CRETSW: - create++; + create = true; continue; case NCRETSW: - create = 0; + create = false; continue; } } diff --git a/uip/refile.c b/uip/refile.c index 9ee6dab4..2552ec66 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -58,10 +58,12 @@ static void copy_seqs (struct msgs *, int, struct msgs *, int); int main (int argc, char **argv) { - int linkf = 0, preserve = 0; + bool linkf = false; + bool preserve = false; bool retainseqs = false; int filep = 0; - int foldp = 0, isdf = 0, unlink_msgs = 0; + int foldp = 0, isdf = 0; + bool unlink_msgs = false; int i, msgnum; char *cp, *folder = NULL, buf[BUFSIZ]; char **argp, **arguments; @@ -98,17 +100,17 @@ main (int argc, char **argv) done (0); case LINKSW: - linkf++; + linkf = true; continue; case NLINKSW: - linkf = 0; + linkf = false; continue; case PRESSW: - preserve++; + preserve = true; continue; case NPRESSW: - preserve = 0; + preserve = false; continue; case RETAINSEQSSW: @@ -119,10 +121,10 @@ main (int argc, char **argv) continue; case UNLINKSW: - unlink_msgs++; + unlink_msgs = true; continue; case NUNLINKSW: - unlink_msgs = 0; + unlink_msgs = false; continue; case SRCSW: diff --git a/uip/repl.c b/uip/repl.c index e114273d..6101641b 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -98,9 +98,9 @@ short ccme = -1; short querysw = 0; static short outputlinelen = OUTPUTLINELEN; -static short groupreply = 0; /* Is this a group reply? */ +static bool groupreply; /* Is this a group reply? */ -static int mime = 0; /* include original as MIME part */ +static bool mime; /* include original as MIME part */ static char *form = NULL; /* form (components) file */ static char *filter = NULL; /* message filter file */ static char *fcc = NULL; /* folders to add to Fcc: header */ @@ -117,10 +117,11 @@ int main (int argc, char **argv) { int i, isdf = 0; - int anot = 0; + bool anot = false; bool inplace = true; - int nedit = 0, nwhat = 0; - int atfile = 0; + bool nedit = false; + bool nwhat = false; + bool atfile = false; int fmtproc = -1; char *cp, *cwd, *dp, *maildir, *file = NULL; char *folder = NULL, *msg = NULL, *dfolder = NULL; @@ -132,8 +133,7 @@ main (int argc, char **argv) struct msgs *mp = NULL; struct stat st; FILE *in; - - int buildsw = 0; + bool buildsw = false; if (nmh_init(argv[0], true, true)) { return 1; } @@ -159,17 +159,17 @@ main (int argc, char **argv) done (0); case GROUPSW: - groupreply++; + groupreply = true; continue; case NGROUPSW: - groupreply = 0; + groupreply = false; continue; case ANNOSW: - anot++; + anot = true; continue; case NANNOSW: - anot = 0; + anot = false; continue; case CCSW: @@ -186,10 +186,10 @@ main (int argc, char **argv) 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 CONVERTARGSW: { @@ -223,13 +223,13 @@ main (int argc, char **argv) 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 FCCSW: @@ -255,7 +255,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 == '-') @@ -264,7 +264,7 @@ main (int argc, char **argv) case FRMTSW: filter = mh_xstrdup(etcpath(mhlreply)); - mime = 0; + mime = false; continue; case NFRMTSW: filter = NULL; @@ -278,11 +278,11 @@ main (int argc, char **argv) continue; case MIMESW: - mime++; + mime = true; filter = NULL; continue; case NMIMESW: - mime = 0; + mime = false; continue; case QURYSW: @@ -319,10 +319,10 @@ main (int argc, char **argv) continue; case ATFILESW: - atfile++; + atfile = true; continue; case NOATFILESW: - atfile = 0; + atfile = false; continue; case FMTPROCSW: @@ -398,7 +398,7 @@ try_it_again: /* * We are replying to a file. */ - anot = 0; /* we don't want to annotate a file */ + anot = false; /* we don't want to annotate a file */ } else { /* * We are replying to a message. diff --git a/uip/replsbr.c b/uip/replsbr.c index 46742e66..2fadb1d1 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -282,7 +282,7 @@ replformataddr (char *orig, char *str) { int len; char baddr[BUFSIZ], error[BUFSIZ]; - int isgroup; + bool isgroup; char *dst; char *cp; char *sp; @@ -312,7 +312,7 @@ replformataddr (char *orig, char *str) } /* concatenate all the new addresses onto 'buf' */ - for (isgroup = 0; (cp = getname (fixed_str)); ) { + for (isgroup = false; (cp = getname (fixed_str)); ) { if ((mp = getm (cp, dfhost, dftype, error, sizeof(error))) == NULL) { snprintf (baddr, sizeof(baddr), "\t%s -- %s\n", cp, error); badaddrs = add (baddr, badaddrs); @@ -320,7 +320,7 @@ replformataddr (char *orig, char *str) } if (isgroup && (mp->m_gname || !mp->m_ingrp)) { *dst++ = ';'; - isgroup = 0; + isgroup = false; } if (insert (mp)) { /* if we get here we're going to add an address */ @@ -331,7 +331,7 @@ replformataddr (char *orig, char *str) if (mp->m_gname) { CHECKMEM (mp->m_gname); CPY (mp->m_gname); - isgroup++; + isgroup = true; } sp = adrformat (mp); CHECKMEM (sp); diff --git a/uip/rmf.c b/uip/rmf.c index 724bd26f..38b07a14 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -35,7 +35,8 @@ static void rma (char *); int main (int argc, char **argv) { - int defolder = 0, interactive = -1; + bool defolder = false; + int interactive = -1; char *cp, *folder = NULL, newfolder[BUFSIZ]; char buf[BUFSIZ], **argp, **arguments; char *fp; @@ -84,7 +85,7 @@ main (int argc, char **argv) free (path ("./", TFOLDER)); if (!folder) { folder = getfolder (1); - defolder++; + defolder = true; } fp = m_mailpath(folder); if (!strcmp(fp, pwd())) @@ -127,7 +128,8 @@ main (int argc, char **argv) static int rmf (char *folder) { - int i, others; + int i; + bool others; char *fp; char *maildir; char cur[BUFSIZ]; @@ -155,7 +157,7 @@ rmf (char *folder) if ((dd = opendir (".")) == NULL) die("unable to read folder +%s", folder); - others = 0; + others = false; /* * Run the external delete hook program. @@ -183,12 +185,12 @@ rmf (char *folder) inform("file \"%s/%s\" not deleted, continuing...", folder, dp->d_name); - others++; + others = true; continue; } if (m_unlink (dp->d_name) == NOTOK) { admonish (dp->d_name, "unable to unlink %s:", folder); - others++; + others = true; } } @@ -203,7 +205,7 @@ rmf (char *folder) if (chdir ("..") < 0) { advise ("..", "chdir"); } - if (others == 0 && remdir (maildir)) + if (!others && remdir (maildir)) return OK; inform("folder +%s not removed", folder); diff --git a/uip/rmm.c b/uip/rmm.c index 0d71be96..fc32a520 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -30,7 +30,8 @@ DEFINE_SWITCH_ARRAY(RMM, switches); int main (int argc, char **argv) { - int msgnum, unlink_msgs = 0; + int msgnum; + bool unlink_msgs = false; char *cp, *maildir, *folder = NULL; char buf[BUFSIZ], **argp; char **arguments; @@ -62,10 +63,10 @@ main (int argc, char **argv) done (0); case UNLINKSW: - unlink_msgs++; + unlink_msgs = true; continue; case NUNLINKSW: - unlink_msgs = 0; + unlink_msgs = false; continue; case RPROCSW: diff --git a/uip/scan.c b/uip/scan.c index ba238d9c..60c5ebcc 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -41,8 +41,11 @@ DEFINE_SWITCH_ARRAY(SCAN, switches); int main (int argc, char **argv) { - int clearflag = 0, hdrflag = 0, ontty; - int width = -1, revflag = 0; + bool clearflag = false; + bool hdrflag = false; + int ontty; + int width = -1; + bool revflag = false; int i, state, msgnum; ivector_t seqnum = ivector_create (0); bool unseen; @@ -82,10 +85,10 @@ main (int argc, char **argv) done (0); case CLRSW: - clearflag++; + clearflag = true; continue; case NCLRSW: - clearflag = 0; + clearflag = false; continue; case FORMSW: @@ -100,10 +103,10 @@ main (int argc, char **argv) continue; case HEADSW: - hdrflag++; + hdrflag = true; continue; case NHEADSW: - hdrflag = 0; + hdrflag = false; continue; case WIDTHSW: @@ -112,10 +115,10 @@ main (int argc, char **argv) width = atoi (cp); continue; case REVSW: - revflag++; + revflag = true; continue; case NREVSW: - revflag = 0; + revflag = false; continue; case FILESW: @@ -272,7 +275,7 @@ main (int argc, char **argv) } charstring_free (scanl); scan_finished (); - hdrflag = 0; + hdrflag = false; fclose (in); if (ontty) fflush (stdout); diff --git a/uip/send.c b/uip/send.c index 235946ec..dde2029b 100644 --- a/uip/send.c +++ b/uip/send.c @@ -98,12 +98,12 @@ DEFINE_SWITCH_ARRAY(USE, anyl); #undef X extern int debugsw; /* from sendsbr.c */ -extern int forwsw; +extern bool forwsw; extern int inplace; -extern int pushsw; +extern bool pushsw; extern int splitsw; -extern int unique; -extern int verbsw; +extern bool unique; +extern bool verbsw; extern char *altmsg; /* .. */ extern char *annotext; @@ -190,10 +190,10 @@ main (int argc, char **argv) continue; case PUSHSW: - pushsw++; + pushsw = true; continue; case NPUSHSW: - pushsw = 0; + pushsw = false; continue; case SPLITSW: @@ -202,25 +202,25 @@ main (int argc, char **argv) continue; case UNIQSW: - unique++; + unique = true; continue; case NUNIQSW: - unique = 0; + unique = false; continue; case FORWSW: - forwsw++; + forwsw = true; continue; case NFORWSW: - forwsw = 0; + forwsw = false; continue; case VERBSW: - verbsw++; + verbsw = true; vec[vecp++] = --cp; continue; case NVERBSW: - verbsw = 0; + verbsw = false; vec[vecp++] = --cp; continue; diff --git a/uip/sendsbr.c b/uip/sendsbr.c index f2c2762f..8d6dd616 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -34,12 +34,12 @@ static int setup_oauth_params(char *[], int *, const char *, const char **); #endif /* OAUTH_SUPPORT */ int debugsw = 0; /* global */ -int forwsw = 1; +bool forwsw = true; int inplace = 1; -int pushsw = 0; +bool pushsw; int splitsw = -1; -int unique = 0; -int verbsw = 0; +bool unique; +bool verbsw; char *altmsg = NULL; /* .. */ char *annotext = NULL; diff --git a/uip/show.c b/uip/show.c index 3943118a..3de3a836 100644 --- a/uip/show.c +++ b/uip/show.c @@ -66,9 +66,10 @@ static int is_nontext(char *); int main (int argc, char **argv) { - int draftsw = 0; + bool draftsw = false; bool headersw = true; - int nshow = 0, checkmime = 1; + bool nshow = false; + bool checkmime = true; bool mime = false; int isdf = 0, mode = SHOW, msgnum; char *cp, *maildir, *file = NULL, *folder = NULL, *proc, *program; @@ -126,7 +127,7 @@ non_mhl_switches: case DRFTSW: if (file) die("only one file at a time!"); - draftsw++; + draftsw = true; if (mode == SHOW) continue; usage: @@ -168,22 +169,22 @@ usage: case SHOWSW: if (!(showproc = *argp++) || *showproc == '-') die("missing argument to %s", argp[-2]); - nshow = 0; + nshow = false; continue; case NSHOWSW: - nshow++; + nshow = true; continue; case SHOWMIMESW: if (!(showmimeproc = *argp++) || *showmimeproc == '-') die("missing argument to %s", argp[-2]); - nshow = 0; + nshow = false; continue; case CHECKMIMESW: - checkmime++; + checkmime = true; continue; case NOCHECKMIMESW: - checkmime = 0; + checkmime = false; continue; } } diff --git a/uip/slocal.c b/uip/slocal.c index b3f0aa23..8677b3f2 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -83,10 +83,10 @@ DEFINE_SWITCH_ARRAY(SLOCAL, switches); static int globbed = 0; /* have we built "vars" table yet? */ static int parsed = 0; /* have we built header field table yet */ static int utmped = 0; /* have we scanned umtp(x) file yet */ -static int suppressdup = 0; /* are we suppressing duplicate messages? */ +static bool suppressdup; /* are we suppressing duplicate messages? */ -static int verbose = 0; -static int debug = 0; +static bool verbose; +static bool debug; static char *addr = NULL; static char *user = NULL; @@ -251,20 +251,20 @@ main (int argc, char **argv) continue; case VERBSW: - verbose++; + verbose = true; continue; case NVERBSW: - verbose = 0; + verbose = false; continue; case SUPPRESSDUP: - suppressdup++; + suppressdup = true; continue; case NSUPPRESSDUP: - suppressdup = 0; + suppressdup = false; continue; case DEBUGSW: - debug++; + debug = true; continue; } } else { @@ -423,7 +423,9 @@ usr_delivery (int fd, char *delivery, int su) { int i; bool accept; - int status=1, won, vecp; + int status=1; + bool won; + int vecp; bool next; char *field, *pattern, *action, *result, *string; char buffer[BUFSIZ], tmpbuf[BUFSIZ]; @@ -447,7 +449,7 @@ usr_delivery (int fd, char *delivery, int su) return -1; } - won = 0; + won = false; next = true; /* read and process delivery file */ @@ -636,7 +638,7 @@ usr_delivery (int fd, char *delivery, int su) if (status) next = false; /* action failed, mark for 'N' result */ if (accept && status == 0) - won++; + won = true; } fclose (fp); diff --git a/uip/sortm.c b/uip/sortm.c index a47eb9e4..75c322a2 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -46,8 +46,8 @@ int nmsgs; char *subjsort; /* sort on subject if != 0 */ time_t datelimit = 0; -int submajor = 0; /* if true, sort on subject-major */ -int verbose; +bool submajor; /* if true, sort on subject-major */ +bool verbose; int allmsgs = 1; int check_failed = 0; @@ -131,7 +131,7 @@ main (int argc, char **argv) while (*cp == '0') cp++; /* skip any leading zeros */ if (!*cp) { /* hit end of string */ - submajor++; /* sort subject-major */ + submajor = true; /* sort subject-major */ continue; } if (!isdigit((unsigned char) *cp) || !(datelimit = atoi(cp))) @@ -139,15 +139,15 @@ main (int argc, char **argv) datelimit *= 60*60*24; continue; case NLIMSW: - submajor = 0; /* use date-major, but */ - datelimit = 0; /* use no limit */ + submajor = false; /* use date-major, but */ + datelimit = 0; /* use no limit */ continue; case VERBSW: - verbose++; + verbose = true; continue; case NVERBSW: - verbose = 0; + verbose = false; continue; case ALLMSGS: diff --git a/uip/viamail.c b/uip/viamail.c index 7d9214e6..c2520542 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -41,7 +41,7 @@ DEFINE_SWITCH_ARRAY(VIAMAIL, switches); extern int debugsw; extern int splitsw; -extern int verbsw; +extern bool verbsw; /* * static prototypes @@ -117,10 +117,10 @@ main (int argc, char **argv) continue; case VERBSW: - verbsw = 1; + verbsw = true; continue; case NVERBSW: - verbsw = 0; + verbsw = false; continue; case DEBUGSW: diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index 2fa0ed85..8a4c372b 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -23,7 +23,8 @@ int what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, struct msgs *mp, char *text, int inplace, char *cwd, int atfile) { - int found, k, msgnum, vecp; + bool found; + int k, msgnum, vecp; int len, buflen; char *bp; char buffer[BUFSIZ], *vec[MAXARGS]; @@ -68,7 +69,7 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, unsetenv("mhinplace"); if (text && mp && !is_readonly(mp)) { - found = 0; + found = false; bp = buffer; buflen = sizeof(buffer); for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) { @@ -86,7 +87,7 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, buflen -= len; } msgnum = k + 1; - found++; + found = true; } } if (found) { diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 9d9ab633..2f00ba58 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -120,7 +120,9 @@ static int copyf (char *, char *); int WhatNow (int argc, char **argv) { - int isdf = 0, nedit = 0, use = 0, atfile = 1; + int isdf = 0; + bool nedit = false; + int use = 0, atfile = 1; char *cp, *dfolder = NULL, *dmsg = NULL; char *ed = NULL, *drft = NULL, *msgnam = NULL; char buf[BUFSIZ]; @@ -186,10 +188,10 @@ WhatNow (int argc, char **argv) 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 PRMPTSW: @@ -216,7 +218,7 @@ WhatNow (int argc, char **argv) if (ed == NULL && ((ed = getenv ("mheditor")) == NULL || *ed == 0)) { ed = NULL; - nedit++; + nedit = true; } /* start editing the draft, unless -noedit was given */ @@ -634,7 +636,7 @@ popen_in_dir(const char *dir, const char *cmd, const char *type) * EDIT */ -static int reedit = 0; /* have we been here before? */ +static bool reedit; /* have we been here before? */ static char *edsave = NULL; /* the editor we used previously */ @@ -739,7 +741,7 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, break; } - reedit++; + reedit = true; if (altmsg && mp && !is_readonly(mp) @@ -956,12 +958,12 @@ DEFINE_SWITCH_ARRAY(SEND, sendswitches); extern int debugsw; /* from sendsbr.c */ -extern int forwsw; +extern bool forwsw; extern int inplace; -extern int pushsw; +extern bool pushsw; extern int splitsw; -extern int unique; -extern int verbsw; +extern bool unique; +extern bool verbsw; extern char *altmsg; /* .. */ extern char *annotext; @@ -1012,9 +1014,9 @@ sendit (char *sp, char **arg, char *file, int pushed) argp = arguments; debugsw = 0; - forwsw = 1; + forwsw = true; inplace = 1; - unique = 0; + unique = false; altmsg = NULL; annotext = NULL; @@ -1078,24 +1080,24 @@ sendit (char *sp, char **arg, char *file, int pushed) continue; case UNIQSW: - unique++; + unique = true; continue; case NUNIQSW: - unique = 0; + unique = false; continue; case FORWSW: - forwsw++; + forwsw = true; continue; case NFORWSW: - forwsw = 0; + forwsw = false; continue; case VERBSW: - verbsw++; + verbsw = true; vec[vecp++] = --cp; continue; case NVERBSW: - verbsw = 0; + verbsw = false; vec[vecp++] = --cp; continue;