From: Ralph Corderoy Date: Mon, 30 Oct 2017 23:29:32 +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/1ca8f21e0edfe448b71ac86de1b0cd987547a002?hp=69819af4834557e60c33bb378e29cf3d4e8269f8 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/flist.c b/uip/flist.c index fec2c841..2372ffc0 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -443,7 +443,8 @@ static int AddFolder(char *name, int force) { unsigned int i; - int msgnum, nonzero; + int msgnum; + bool nonzero; ivector_t seqnum = ivector_create (0), nSeq = ivector_create (0); struct Folder *f; struct msgs *mp; @@ -478,10 +479,10 @@ AddFolder(char *name, int force) } /* Check if any of the sequence checks were nonzero */ - nonzero = 0; + nonzero = false; for (i = 0; i < svector_size (sequencesToDo); i++) { if (ivector_at (nSeq, i) > 0) { - nonzero = 1; + nonzero = true; break; } } @@ -521,7 +522,8 @@ static void PrintFolders(void) { char tmpname[BUFSIZ]; - unsigned int i, j, len, has_private = 0; + unsigned int i, j, len; + bool has_private = false; unsigned int maxfolderlen = 0, maxseqlen = 0; int maxnum = 0, maxseq = 0; @@ -561,7 +563,7 @@ PrintFolders(void) /* check if this sequence is private in any of the folders */ if (ivector_at (folders[i].private, j)) - has_private = 1; + has_private = true; } } diff --git a/uip/fmttest.c b/uip/fmttest.c index 91a83a5f..446d5b0b 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -102,7 +102,7 @@ static char *test_concataddr(char *, char *); static int insert(struct mailname *); static void mlistfree(void); -static int nodupcheck = 0; /* If set, no check for duplicates */ +static bool nodupcheck; /* If set, no check for duplicates */ static int ccme = 0; /* Should I cc myself? */ static struct mailname mq; /* Mail addresses to check for duplicates */ static char *dummy = "dummy"; @@ -1283,9 +1283,9 @@ test_concataddr(char *orig, char *str) { char *cp; - nodupcheck = 1; + nodupcheck = true; cp = test_formataddr(orig, str); - nodupcheck = 0; + nodupcheck = false; return cp; } diff --git a/uip/folder.c b/uip/folder.c index e7dc1873..2141f32d 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -54,7 +54,7 @@ static int fverb = 0; /* print actions taken while packing folder */ static int fheader = 0; /* should we output a header? */ static int frecurse = 0; /* recurse through subfolders */ static int ftotal = 0; /* should we output the totals? */ -static int all = 0; /* should we output all folders */ +static bool all; /* should we output all folders */ static int total_folders = 0; /* total number of folders */ @@ -107,8 +107,10 @@ nonexistent_folder (int status) { int main (int argc, char **argv) { - int printsw = 0, listsw = 0; - int pushsw = 0, popsw = 0; + bool printsw = false; + bool listsw = false; + bool pushsw = false; + bool popsw = false; char *cp, *dp, *msg = NULL, *argfolder = NULL; char **ap, **argp, buf[BUFSIZ], **arguments; @@ -142,11 +144,11 @@ main (int argc, char **argv) done (0); case ALLSW: - all = 1; + all = true; continue; case NALLSW: - all = 0; + all = false; continue; case CREATSW: @@ -199,28 +201,28 @@ main (int argc, char **argv) continue; case PRNTSW: - printsw = 1; + printsw = true; continue; case NPRNTSW: - printsw = 0; + printsw = false; continue; case LISTSW: - listsw = 1; + listsw = true; continue; case NLISTSW: - listsw = 0; + listsw = false; continue; case PUSHSW: - pushsw = 1; - listsw = 1; - popsw = 0; + pushsw = true; + listsw = true; + popsw = false; continue; case POPSW: - popsw = 1; - listsw = 1; - pushsw = 0; + popsw = true; + listsw = true; + pushsw = false; continue; } } @@ -243,8 +245,8 @@ main (int argc, char **argv) * If we aren't working with the folder stack * (-push, -pop, -list) then the default is to print. */ - if (pushsw == 0 && popsw == 0 && listsw == 0) - printsw++; + if (!pushsw && !popsw && !listsw) + printsw = true; /* Pushing a folder onto the folder stack */ if (pushsw) { @@ -474,7 +476,9 @@ get_folder_info (char *fold, char *msg) static void print_folders (void) { - int i, len, hasempty = 0, curprinted; + int i, len; + bool hasempty = false; + bool curprinted; int maxlen = 0, maxnummsg = 0, maxlowmsg = 0; int maxhghmsg = 0, maxcurmsg = 0, total_msgs = 0; int nummsgdigits, lowmsgdigits; @@ -518,7 +522,7 @@ print_folders (void) /* check for empty folders */ if (fi[i].nummsg == 0) - hasempty = 1; + hasempty = true; } nummsgdigits = num_digits (maxnummsg); lowmsgdigits = num_digits (maxlowmsg); @@ -562,7 +566,7 @@ print_folders (void) printf ("%-*s ", maxlen+1, tmpname); - curprinted = 0; /* remember if we print cur */ + curprinted = false; /* remember if we print cur */ if (fi[i].nummsg == 0) { printf ("has %*s messages%*s", nummsgdigits, "no", @@ -574,7 +578,7 @@ print_folders (void) lowmsgdigits, fi[i].lowmsg, hghmsgdigits, fi[i].hghmsg); if (fi[i].curmsg >= fi[i].lowmsg && fi[i].curmsg <= fi[i].hghmsg) { - curprinted = 1; + curprinted = true; printf ("; cur=%*d", curmsgdigits, fi[i].curmsg); } } diff --git a/uip/install-mh.c b/uip/install-mh.c index b1184899..c3fc4f7a 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -39,14 +39,14 @@ main (int argc, char **argv) struct passwd *pw; struct stat st; FILE *in, *out; - int check; + bool check; if (nmh_init(argv[0], false, false)) { return 1; } arguments = getarguments (invo_name, argc, argv, 0); argp = arguments; - check = 0; + check = false; while ((dp = *argp++)) { if (*dp == '-') { @@ -70,7 +70,7 @@ main (int argc, char **argv) continue; case CHECKSW: - check = 1; + check = true; continue; } } else { diff --git a/uip/mhbuild.c b/uip/mhbuild.c index c94002df..233d7a6a 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -89,8 +89,12 @@ static char outfile[BUFSIZ]; int main (int argc, char **argv) { - int sizesw = 1, headsw = 1, directives = 1, autobuild = 0, dist = 0; - int verbosw = 0, dispo = 0; + int sizesw = 1, headsw = 1; + bool directives = true; + bool autobuild = false; + bool dist = false; + int verbosw = 0; + bool dispo = false; size_t maxunencoded = MAXTEXTPERLN; int *icachesw; char *cp, buf[BUFSIZ]; @@ -134,16 +138,16 @@ main (int argc, char **argv) case AUTOSW: /* -auto implies -nodirectives */ - autobuild = 1; - directives = 0; + autobuild = true; + directives = false; continue; case NAUTOSW: /* * We're turning directives back on since this is likely here * to override a profile entry */ - autobuild = 0; - directives = 1; + autobuild = false; + directives = true; continue; case RCACHESW: @@ -180,10 +184,10 @@ main (int argc, char **argv) continue; case DIRECTIVES: - directives = 1; + directives = true; continue; case NDIRECTIVES: - directives = 0; + directives = false; continue; case LISTSW: @@ -260,16 +264,16 @@ main (int argc, char **argv) verbosw = 0; continue; case DISPOSW: - dispo = 1; + dispo = true; continue; case NDISPOSW: - dispo = 0; + dispo = false; continue; case DEBUGSW: debugsw = 1; continue; case DISTSW: - dist = 1; + dist = true; continue; } } diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 6ab9564a..fc41dd10 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -677,7 +677,7 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename) */ if (!do_direct() || buf[0] != '#' || buf[1] == '#' || buf[1] == '<') { int headers; - int inlineD; + bool inlineD; long pos; char content[BUFSIZ]; FILE *out; @@ -694,10 +694,10 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename) if (do_direct() && (buf[0] == '#' && buf[1] == '<')) { strncpy (content, buf + 2, sizeof(content)); - inlineD = 1; + inlineD = true; goto rock_and_roll; } - inlineD = 0; + inlineD = false; /* the directive is implicit */ strncpy (content, "text/plain", sizeof(content)); @@ -1181,13 +1181,13 @@ compose_content (CT ct, int verbose) * subparts with the rfc934 compatibility mode flag. */ if (rfc934sw && ct->c_subtype == MULTI_DIGEST) { - int is934 = 1; + bool is934 = true; for (part = m->mp_parts; part; part = part->mp_next) { CT p = part->mp_part; if (p->c_subtype != MESSAGE_RFC822) { - is934 = 0; + is934 = false; break; } } @@ -1221,7 +1221,8 @@ compose_content (CT ct, int verbose) default: if (!ce->ce_file) { pid_t child_id; - int xstdout, len, buflen; + bool xstdout; + int len, buflen; char *bp, *cp; char *vec[4], buffer[BUFSIZ]; FILE *out; @@ -1238,7 +1239,7 @@ compose_content (CT ct, int verbose) ce->ce_file = mh_xstrdup(tfile); ce->ce_unlink = 1; - xstdout = 0; + xstdout = false; /* Get buffer ready to go */ bp = buffer; @@ -1270,7 +1271,7 @@ compose_content (CT ct, int verbose) case 'F': /* %f, and stdout is not-redirected */ - xstdout = 1; + xstdout = true; /* FALLTHRU */ case 'f': @@ -1376,12 +1377,12 @@ static int scan_content (CT ct, size_t maxunencoded) { int prefix_len; - int check8bit = 0, contains8bit = 0; /* check if contains 8bit data */ - int checknul = 0, containsnul = 0; /* check if contains NULs */ - int checklinelen = 0, linelen = 0; /* check for long lines */ - int checkllinelen = 0; /* check for extra-long lines */ - int checkboundary = 0, boundaryclash = 0; /* check if clashes with multipart boundary */ - int checklinespace = 0, linespace = 0; /* check if any line ends with space */ + bool check8bit = false, contains8bit = false; /* check if contains 8bit data */ + bool checknul = false, containsnul = false; /* check if contains NULs */ + bool checklinelen = false, linelen = false; /* check for long lines */ + bool checkllinelen = false; /* check for extra-long lines */ + bool checkboundary = false, boundaryclash = false; /* check if clashes with multipart boundary */ + bool checklinespace = false, linespace = false; /* check if any line ends with space */ char *cp = NULL; char *bufp = NULL; size_t buflen; @@ -1429,18 +1430,18 @@ scan_content (CT ct, size_t maxunencoded) if (ct->c_type == CT_TEXT) { t = (struct text *) ct->c_ctparams; if (t->tx_charset == CHARSET_UNSPECIFIED) { - checknul = 1; + checknul = true; } - check8bit = 1; + check8bit = true; } switch (ct->c_reqencoding) { case CE_8BIT: - checkllinelen = 1; - checkboundary = 1; + checkllinelen = true; + checkboundary = true; break; case CE_QUOTED: - checkboundary = 1; + checkboundary = true; break; case CE_BASE64: break; @@ -1448,34 +1449,34 @@ scan_content (CT ct, size_t maxunencoded) /* Use the default rules based on content-type */ switch (ct->c_type) { case CT_TEXT: - checkboundary = 1; - checklinelen = 1; + checkboundary = true; + checklinelen = true; if (ct->c_subtype == TEXT_PLAIN) { - checklinespace = 0; + checklinespace = false; } else { - checklinespace = 1; + checklinespace = true; } break; case CT_APPLICATION: - check8bit = 1; - checknul = 1; - checklinelen = 1; - checklinespace = 1; - checkboundary = 1; + check8bit = true; + checknul = true; + checklinelen = true; + checklinespace = true; + checkboundary = true; break; case CT_MESSAGE: - checklinelen = 0; - checklinespace = 0; + checklinelen = false; + checklinespace = false; /* don't check anything for message/external */ if (ct->c_subtype == MESSAGE_EXTERNAL) { - checkboundary = 0; - check8bit = 0; + checkboundary = false; + check8bit = false; } else { - checkboundary = 1; - check8bit = 1; + checkboundary = true; + check8bit = true; } break; @@ -1487,10 +1488,10 @@ scan_content (CT ct, size_t maxunencoded) * since we are forcing use of base64, unless * the content-type was specified by a mhbuild directive. */ - check8bit = 0; - checklinelen = 0; - checklinespace = 0; - checkboundary = 0; + check8bit = false; + checklinelen = false; + checklinespace = false; + checkboundary = false; break; } } @@ -1511,12 +1512,12 @@ scan_content (CT ct, size_t maxunencoded) for (cp = bufp; (check8bit || checknul) && cp < bufp + gotlen; cp++) { if (!isascii ((unsigned char) *cp)) { - contains8bit = 1; - check8bit = 0; /* no need to keep checking */ + contains8bit = true; + check8bit = false; /* no need to keep checking */ } if (!*cp) { - containsnul = 1; - checknul = 0; /* no need to keep checking */ + containsnul = true; + checknul = false; /* no need to keep checking */ } } @@ -1524,8 +1525,8 @@ scan_content (CT ct, size_t maxunencoded) * Check line length. */ if (checklinelen && ((size_t)gotlen > maxunencoded + 1)) { - linelen = 1; - checklinelen = 0; /* no need to keep checking */ + linelen = true; + checklinelen = false; /* no need to keep checking */ } /* @@ -1545,8 +1546,8 @@ scan_content (CT ct, size_t maxunencoded) */ if (checklinespace && (cp = bufp + gotlen - 2) > bufp && isspace ((unsigned char) *cp)) { - linespace = 1; - checklinespace = 0; /* no need to keep checking */ + linespace = true; + checklinespace = false; /* no need to keep checking */ } /* @@ -1560,8 +1561,8 @@ scan_content (CT ct, size_t maxunencoded) *++cp = '\0'; if (!strncmp(bufp + 2, prefix, prefix_len) && isdigit((unsigned char) bufp[2 + prefix_len])) { - boundaryclash = 1; - checkboundary = 0; /* no need to keep checking */ + boundaryclash = true; + checkboundary = false; /* no need to keep checking */ } } } @@ -2125,7 +2126,7 @@ expand_pseudoheaders (CT ct, struct multipart *m, const char *infile, struct part *part; if (ct->c_subtype == MULTI_ALTERNATE) { - int matched = 0; + bool matched = false; /* The parts are in descending priority order (defined by RFC 2046 Sec. 5.1.4) because they were reversed by @@ -2148,7 +2149,7 @@ expand_pseudoheaders (CT ct, struct multipart *m, const char *infile, expand_pseudoheader (part->mp_part, &text_plain_ct, m, infile, c->type, c->argstring); - matched = 1; + matched = true; break; } } @@ -2340,7 +2341,7 @@ expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m, int extract_headers (CT ct, char *reply_file, FILE **reply_fp) { char *buffer = NULL, *cp, *end_of_header; - int found_header = 0; + bool found_header = false; struct stat statbuf; /* Read the convert reply from the file to memory. */ @@ -2364,10 +2365,10 @@ extract_headers (CT ct, char *reply_file, FILE **reply_fp) { buffer[LEN(TYPE_FIELD)] == ':') { if ((end_of_header = strstr (buffer, "\r\n\r\n"))) { end_of_header += 2; - found_header = 1; + found_header = true; } else if ((end_of_header = strstr (buffer, "\n\n"))) { ++end_of_header; - found_header = 1; + found_header = true; } } diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index b740e231..10f41d87 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -270,14 +270,15 @@ static int find_cache_aux (int writing, char *directory, char *id, char *buffer, int buflen) { - int mask, usemap; + int mask; + bool usemap; char mapfile[BUFSIZ], mapname[BUFSIZ]; FILE *fp; int failed_to_lock = 0; static int partno, pid; static time_t clock = 0; - usemap = 1; + usemap = true; if (debugsw) fprintf (stderr, "find_cache_aux %s usemap=%d\n", directory, usemap); diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 7a298e0b..25116206 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -132,8 +132,8 @@ main (int argc, char **argv) { struct msgs *mp = NULL; CT *ctp; FILE *fp, *infp = NULL, *outfp = NULL; - int using_stdin = 0; - int chgflag = 1; + bool using_stdin = false; + bool chgflag = true; int status = OK; fix_transformations fx; fx.reformat = fx.fixcompositecte = fx.fixboundary = 1; @@ -265,10 +265,10 @@ main (int argc, char **argv) { rmmproc = NULL; continue; case CHGSW: - chgflag = 1; + chgflag = true; continue; case NCHGSW: - chgflag = 0; + chgflag = false; continue; case VERBSW: verbosw = 1; @@ -338,7 +338,7 @@ main (int argc, char **argv) { int fd; char *cp; - using_stdin = 1; + using_stdin = true; if ((cp = m_mktemp2 (NULL, invo_name, &fd, NULL)) == NULL) { die("unable to create temporary file in %s", @@ -523,7 +523,7 @@ mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx, char *input_filename = maildir ? concat (maildir, "/", (*ctp)->c_file, NULL) : mh_xstrdup ((*ctp)->c_file); - int modify_inplace = 0; + bool modify_inplace = false; int message_mods = 0; int status = OK; @@ -535,7 +535,7 @@ mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx, } if (outfile == NULL) { - modify_inplace = 1; + modify_inplace = true; if ((*ctp)->c_file) { char *tempfile; @@ -1183,7 +1183,7 @@ set_ce (CT ct, int encoding) { if (ctinit) { char *cte = concat (" ", ce, "\n", NULL); - int found_cte = 0; + bool found_cte = false; HF hf; /* Decoded contents might be in ct->c_cefile.ce_file, if the caller is decode_text_parts (). Save because we'll @@ -1210,7 +1210,7 @@ set_ce (CT ct, int encoding) { /* Update/add Content-Transfer-Encoding header field. */ for (hf = ct->c_first_hf; hf; hf = hf->next) { if (! strcasecmp (ENCODING_FIELD, hf->name)) { - found_cte = 1; + found_cte = true; free (hf->value); hf->value = cte; } @@ -1398,7 +1398,7 @@ find_textplain_sibling (CT parent, int replacetextplain, int *new_subpart_number) { struct multipart *mp = (struct multipart *) parent->c_ctparams; struct part *part, *prev; - int has_text_plain = 0; + bool has_text_plain = false; for (prev = part = mp->mp_parts; part; part = part->mp_next) { ++*new_subpart_number; @@ -1421,7 +1421,7 @@ find_textplain_sibling (CT parent, int replacetextplain, free_content (old_part->mp_part); free (old_part); } else { - has_text_plain = 1; + has_text_plain = true; } break; } @@ -1834,7 +1834,7 @@ static int boundary_in_content (FILE **fp, char *file, const char *boundary) { char buffer[NMH_BUFSIZ]; size_t bytes_read; - int found_boundary = 0; + bool found_boundary = false; /* free_content() will close *fp if we fopen it here. */ if (! *fp && (*fp = fopen (file, "r")) == NULL) { @@ -1845,7 +1845,7 @@ boundary_in_content (FILE **fp, char *file, const char *boundary) { fseeko (*fp, 0L, SEEK_SET); while ((bytes_read = fread (buffer, 1, sizeof buffer, *fp)) > 0) { if (find_str (buffer, bytes_read, boundary)) { - found_boundary = 1; + found_boundary = true; break; } } @@ -1909,7 +1909,7 @@ set_ct_type (CT ct, int type, int subtype, int encoding) { char *type_subtypename = concat (" ", typename, "/", subtypename, NULL); /* E.g, " text/plain\n" */ char *name_plus_nl = concat (type_subtypename, "\n", NULL); - int found_content_type = 0; + bool found_content_type = false; HF hf; const char *cp = NULL; char *ctline; @@ -1918,7 +1918,7 @@ set_ct_type (CT ct, int type, int subtype, int encoding) { /* Update/add Content-Type header field. */ for (hf = ct->c_first_hf; hf; hf = hf->next) { if (! strcasecmp (TYPE_FIELD, hf->name)) { - found_content_type = 1; + found_content_type = true; free (hf->value); hf->value = (cp = strchr (ct->c_ctline, ';')) ? concat (type_subtypename, cp, "\n", NULL) @@ -2088,18 +2088,18 @@ should_decode(const char *decodetypes, const char *type, const char *subtype) { decodetypes with commas, then search for ,type, and ,type/subtype, in it. */ - int found_match = 0; + bool found_match = false; char *delimited_decodetypes = concat(",", decodetypes, ",", NULL); char *delimited_type = concat(",", type, ",", NULL); if (nmh_strcasestr(delimited_decodetypes, delimited_type)) { - found_match = 1; + found_match = true; } else if (subtype != NULL) { char *delimited_type_subtype = concat(",", type, "/", subtype, ",", NULL); if (nmh_strcasestr(delimited_decodetypes, delimited_type_subtype)) { - found_match = 1; + found_match = true; } free(delimited_type_subtype); } @@ -2194,8 +2194,8 @@ strip_crs (CT ct, int *message_mods) { FILE **fp = NULL; size_t begin; size_t end; - int has_crs = 0; - int opened_input_file = 0; + bool has_crs = false; + bool opened_input_file = false; if (ct->c_cefile.ce_file) { file = &ct->c_cefile.ce_file; @@ -2214,7 +2214,7 @@ strip_crs (CT ct, int *message_mods) { advise (*file, "unable to open for reading"); status = NOTOK; } else { - opened_input_file = 1; + opened_input_file = true; } } } @@ -2234,13 +2234,13 @@ strip_crs (CT ct, int *message_mods) { modify the content. */ char *cp; size_t i; - int last_char_was_cr = 0; + bool last_char_was_cr = false; if (end > 0) { bytes_to_read -= bytes_read; } for (i = 0, cp = buffer; i < bytes_read; ++i, ++cp) { if (*cp == '\n' && last_char_was_cr) { - has_crs = 1; + has_crs = true; break; } @@ -2265,11 +2265,11 @@ strip_crs (CT ct, int *message_mods) { 0) { char *cp; size_t i; - int last_char_was_cr = 0; + bool last_char_was_cr = false; for (i = 0, cp = buffer; i < bytes_read; ++i, ++cp) { if (*cp == '\r') { - last_char_was_cr = 1; + last_char_was_cr = true; } else if (last_char_was_cr) { if (*cp != '\n') { if (write (fd, "\r", 1) < 0) { @@ -2279,12 +2279,12 @@ strip_crs (CT ct, int *message_mods) { if (write (fd, cp, 1) < 0) { advise (tempfile, "write"); } - last_char_was_cr = 0; + last_char_was_cr = false; } else { if (write (fd, cp, 1) < 0) { advise (tempfile, "write"); } - last_char_was_cr = 0; + last_char_was_cr = false; } } } @@ -2338,12 +2338,12 @@ update_cte (CT ct) { least_restrictive_enc != CE_7BIT) { char *cte = concat (" ", ce_str (least_restrictive_enc), "\n", NULL); HF hf; - int found_cte = 0; + bool found_cte = false; /* Update/add Content-Transfer-Encoding header field. */ for (hf = ct->c_first_hf; hf; hf = hf->next) { if (! strcasecmp (ENCODING_FIELD, hf->name)) { - found_cte = 1; + found_cte = true; free (hf->value); hf->value = cte; } @@ -2575,7 +2575,7 @@ fix_always (CT ct, int *message_mods) { */ static int fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) { - int fixed = 0; + bool fixed = false; if (has_prefix(value, "=?") && has_suffix(value, "?=")) { /* Looks like an RFC 2047 encoded parameter. */ @@ -2584,7 +2584,7 @@ fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) { if (decode_rfc2047 (value, decoded, sizeof decoded)) { /* Encode using RFC 2231. */ replace_param (first_pm, last_pm, name, decoded, 0); - fixed = 1; + fixed = true; } else { inform("failed to decode %s parameter %s", name, value); } diff --git a/uip/mhical.c b/uip/mhical.c index 6cf7c0e1..a25b08bf 100644 --- a/uip/mhical.c +++ b/uip/mhical.c @@ -70,7 +70,8 @@ main (int argc, char *argv[]) { act action = ACT_NONE; char *infile = NULL, *outfile = NULL; FILE *inputfile = NULL, *outputfile = NULL; - int contenttype = 0, unfold = 0; + bool contenttype = false; + bool unfold = false; vevent *v, *nextvevent; char *form = "mhical.24hour", *format = NULL; char **argp, **arguments, *cp; @@ -150,14 +151,14 @@ main (int argc, char *argv[]) { continue; case CONTENTTYPESW: - contenttype = 1; + contenttype = true; continue; case NCONTENTTYPESW: - contenttype = 0; + contenttype = false; continue; case UNFOLDSW: - unfold = 1; + unfold = true; continue; } } @@ -258,7 +259,7 @@ main (int argc, char *argv[]) { static void convert_to_reply (contentline *clines, act action) { char *partstat = NULL; - int found_my_attendee_line = 0; + bool found_my_attendee_line = false; contentline *node; convert_common (clines, action); @@ -302,7 +303,7 @@ convert_to_reply (contentline *clines, act action) { while (getname ("")) { continue; } if (ismymbox (mn)) { - found_my_attendee_line = 1; + found_my_attendee_line = true; for (p = node->params; p && p->param_name; p = p->next) { value_list *v; @@ -386,7 +387,7 @@ convert_to_cancellation (contentline *clines) { static void convert_common (contentline *clines, act action) { contentline *node; - int in_valarm; + bool in_valarm; if ((node = find_contentline (clines, "METHOD", 0))) { free (node->value); @@ -470,7 +471,7 @@ convert_common (contentline *clines, act action) { } /* Excise X- lines and VALARM section(s). */ - in_valarm = 0; + in_valarm = false; for (node = clines; node; node = node->next) { /* node->name will be NULL if the line was deleted. */ if (! node->name) { continue; } @@ -478,13 +479,13 @@ convert_common (contentline *clines, act action) { if (in_valarm) { if (! strcasecmp ("END", node->name) && ! strcasecmp ("VALARM", node->value)) { - in_valarm = 0; + in_valarm = false; } remove_contentline (node); } else { if (! strcasecmp ("BEGIN", node->name) && ! strcasecmp ("VALARM", node->value)) { - in_valarm = 1; + in_valarm = true; remove_contentline (node); } else if (! strncasecmp ("X-", node->name, 2)) { remove_contentline (node); @@ -559,8 +560,8 @@ output (FILE *file, contentline *clines, int contenttype) { static void display (FILE *file, contentline *clines, char *nfs) { tzdesc_t timezones = load_timezones (clines); - int in_vtimezone; - int in_valarm; + bool in_vtimezone; + bool in_valarm; contentline *node; struct format *fmt; int dat[5] = { 0, 0, 0, INT_MAX, 0 }; @@ -595,7 +596,7 @@ display (FILE *file, contentline *clines, char *nfs) { } /* Only display DESCRIPTION lines that are outside VALARM section(s). */ - in_valarm = 0; + in_valarm = false; if ((c = fmt_findcomp ("description"))) { for (node = clines; node; node = node->next) { /* node->name will be NULL if the line was deleted. */ @@ -606,12 +607,12 @@ display (FILE *file, contentline *clines, char *nfs) { } else if (in_valarm) { if (! strcasecmp ("END", node->name) && ! strcasecmp ("VALARM", node->value)) { - in_valarm = 0; + in_valarm = false; } } else { if (! strcasecmp ("BEGIN", node->name) && ! strcasecmp ("VALARM", node->value)) { - in_valarm = 1; + in_valarm = true; } } } @@ -626,7 +627,7 @@ display (FILE *file, contentline *clines, char *nfs) { if ((c = fmt_findcomp ("dtstart"))) { /* Find DTSTART outsize of a VTIMEZONE section. */ - in_vtimezone = 0; + in_vtimezone = false; for (node = clines; node; node = node->next) { /* node->name will be NULL if the line was deleted. */ if (! node->name) { continue; } @@ -634,12 +635,12 @@ display (FILE *file, contentline *clines, char *nfs) { if (in_vtimezone) { if (! strcasecmp ("END", node->name) && ! strcasecmp ("VTIMEZONE", node->value)) { - in_vtimezone = 0; + in_vtimezone = false; } } else { if (! strcasecmp ("BEGIN", node->name) && ! strcasecmp ("VTIMEZONE", node->value)) { - in_vtimezone = 1; + in_vtimezone = true; } else if (! strcasecmp ("DTSTART", node->name)) { /* Got it: DTSTART outside of a VTIMEZONE section. */ char *datetime = format_datetime (timezones, node); diff --git a/uip/mhlist.c b/uip/mhlist.c index 5b14b88a..e6fc1dd7 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -69,7 +69,11 @@ static void pipeser (int); int main (int argc, char **argv) { - int sizesw = 1, headsw = 1, chgflag = 1, verbosw = 0, dispo = 0; + bool sizesw = true; + bool headsw = true; + int chgflag = 1; + bool verbosw = false; + bool dispo = false; int msgnum, *icachesw; char *cp, *file = NULL, *folder = NULL; char *maildir, buf[100], **argp; @@ -133,17 +137,17 @@ do_cache: continue; case HEADSW: - headsw = 1; + headsw = true; continue; case NHEADSW: - headsw = 0; + headsw = false; continue; case SIZESW: - sizesw = 1; + sizesw = true; continue; case NSIZESW: - sizesw = 0; + sizesw = false; continue; case PARTSW: @@ -194,16 +198,16 @@ do_cache: continue; case VERBSW: - verbosw = 1; + verbosw = true; continue; case NVERBSW: - verbosw = 0; + verbosw = false; continue; case DISPOSW: - dispo = 1; + dispo = true; continue; case NDISPOSW: - dispo = 0; + dispo = false; continue; case DEBUGSW: debugsw = 1; diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index e7070fd3..62539947 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -260,7 +260,7 @@ static char *addrcomps[] = { static int bellflg = 0; static int clearflg = 0; static int dashstuff = 0; -static int dobody = 1; +static bool dobody = true; static int forwflg = 0; static int forwall = 0; @@ -462,7 +462,7 @@ mhl (int argc, char **argv) continue; case NBODYSW: - dobody = 0; + dobody = false; continue; } } diff --git a/uip/mhn.c b/uip/mhn.c index c361c5be..ab9c8f52 100644 --- a/uip/mhn.c +++ b/uip/mhn.c @@ -83,16 +83,16 @@ int verbosw = 0; /* * variables for mhbuild (mhn -build) */ -static int buildsw = 0; +static bool buildsw; static int rfc934sw = 0; /* * what action to take? */ static int cachesw = 0; -static int listsw = 0; -static int showsw = 0; -static int storesw = 0; +static bool listsw; +static bool showsw; +static bool storesw; #define quitser pipeser @@ -105,7 +105,9 @@ static void pipeser (int); int main (int argc, char **argv) { - int sizesw = 1, headsw = 1, autosw = 0; + bool sizesw = true; + bool headsw = true; + int autosw = 0; int msgnum, *icachesw; char *cp, *file = NULL, *folder = NULL; char *maildir, buf[100], **argp; @@ -186,38 +188,38 @@ do_cache: continue; case HEADSW: - headsw = 1; + headsw = true; continue; case NHEADSW: - headsw = 0; + headsw = false; continue; case LISTSW: - listsw = 1; + listsw = true; continue; case NLISTSW: - listsw = 0; + listsw = false; continue; case SHOWSW: - showsw = 1; + showsw = true; continue; case NSHOWSW: - showsw = 0; + showsw = false; continue; case SIZESW: - sizesw = 1; + sizesw = true; continue; case NSIZESW: - sizesw = 0; + sizesw = false; continue; case STORESW: - storesw = 1; + storesw = true; continue; case NSTORESW: - storesw = 0; + storesw = false; continue; case PARTSW: @@ -272,10 +274,10 @@ do_cache: * Switches for mhbuild */ case BUILDSW: - buildsw = 1; + buildsw = true; continue; case NBUILDSW: - buildsw = 0; + buildsw = false; continue; case RFC934SW: rfc934sw = 1; @@ -466,7 +468,7 @@ do_cache: /* If no action is specified, assume -show */ if (!listsw && !showsw && !storesw && !cachesw) - showsw = 1; + showsw = true; userrs = 1; SIGNAL (SIGQUIT, quitser); diff --git a/uip/mhparam.c b/uip/mhparam.c index ad41ad3f..21804f4c 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -38,7 +38,7 @@ static char *sbackup = BACKUP_PREFIX; static char *datalocking = "fcntl"; static char *localmbox = ""; -static int localmbox_primed = 0; +static bool localmbox_primed; extern char *spoollocking; @@ -140,7 +140,8 @@ main(int argc, char **argv) { int i, compp = 0; bool missed; - int all = 0, debug = 0; + bool all = false; + bool debug = false; int components = -1; char *cp, buf[BUFSIZ], **argp; char **arguments, *comps[MAXARGS]; @@ -176,18 +177,18 @@ main(int argc, char **argv) break; case ALLSW: - all = 1; + all = true; break; case DEBUGSW: - debug = 1; + debug = true; break; } } else { comps[compp++] = cp; if (strcmp("localmbox", cp) == 0 && ! localmbox_primed) { localmbox = getlocalmbox(); - localmbox_primed = 1; + localmbox_primed = true; } } } @@ -221,7 +222,7 @@ main(int argc, char **argv) /* Also set localmbox here */ if (! localmbox_primed) { localmbox = getlocalmbox(); - localmbox_primed = 1; + localmbox_primed = true; } /* diff --git a/uip/mhparse.c b/uip/mhparse.c index d634a06a..4a5f8055 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -1082,7 +1082,7 @@ InitText (CT ct) static int InitMultiPart (CT ct) { - int inout; + bool inout; long last, pos; char *cp, *dp; PM pm; @@ -1175,7 +1175,7 @@ InitMultiPart (CT ct) last = ct->c_end; next = &m->mp_parts; part = NULL; - inout = 1; + inout = true; while ((gotlen = getline(&bufp, &buflen, fp)) != -1) { if (pos > last) @@ -1202,10 +1202,10 @@ next_part: part->mp_part = p; pos = p->c_begin; fseek (fp, pos, SEEK_SET); - inout = 0; + inout = false; } else { if (strcmp (bufp + 2, m->mp_start) == 0) { - inout = 1; + inout = true; end_part: p = part->mp_part; p->c_end = ftell(fp) - (gotlen + 1); @@ -1745,7 +1745,8 @@ static int openBase64 (CT ct, char **file) { ssize_t cc, len; - int fd, own_ct_fp = 0; + int fd; + bool own_ct_fp = false; char *cp, *buffer = NULL; /* sbeck -- handle suffixes */ CI ci; @@ -1810,7 +1811,7 @@ openBase64 (CT ct, char **file) content_error (ct->c_file, ct, "unable to open for reading"); return NOTOK; } - own_ct_fp = 1; + own_ct_fp = true; } lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET); @@ -1928,7 +1929,8 @@ InitQuoted (CT ct) static int openQuoted (CT ct, char **file) { - int cc, digested, len, quoted, own_ct_fp = 0; + int cc, digested, len, quoted; + bool own_ct_fp = false; char *cp, *ep; char *bufp = NULL; size_t buflen; @@ -1993,7 +1995,7 @@ openQuoted (CT ct, char **file) content_error (ct->c_file, ct, "unable to open for reading"); return NOTOK; } - own_ct_fp = 1; + own_ct_fp = true; } if ((digested = ct->c_digested)) @@ -2148,7 +2150,8 @@ Init7Bit (CT ct) int open7Bit (CT ct, char **file) { - int cc, fd, len, own_ct_fp = 0; + int cc, fd, len; + bool own_ct_fp = false; char buffer[BUFSIZ]; /* sbeck -- handle suffixes */ char *cp; @@ -2246,7 +2249,7 @@ open7Bit (CT ct, char **file) content_error (ct->c_file, ct, "unable to open for reading"); return NOTOK; } - own_ct_fp = 1; + own_ct_fp = true; } lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET); @@ -2437,7 +2440,9 @@ InitFTP (CT ct) static int openFTP (CT ct, char **file) { - int cachetype, caching, fd; + int cachetype; + bool caching; + int fd; int len, buflen; char *bp, *ftp, *user, *pass; char buffer[BUFSIZ], cachefile[BUFSIZ]; @@ -2522,14 +2527,14 @@ openFTP (CT ct, char **file) } ce->ce_unlink = (*file == NULL); - caching = 0; + caching = false; cachefile[0] = '\0'; if ((!e->eb_permission || strcasecmp (e->eb_permission, "read-write")) && find_cache (NULL, wcachesw, &cachetype, e->eb_content->c_id, cachefile, sizeof(cachefile)) != NOTOK) { if (*file == NULL) { ce->ce_unlink = 0; - caching = 1; + caching = true; } } @@ -2769,7 +2774,9 @@ openURL (CT ct, char **file) CE ce = &ct->c_cefile; char *urlprog, *program; char buffer[BUFSIZ], cachefile[BUFSIZ]; - int fd, caching, cachetype; + int fd; + bool caching; + int cachetype; struct msgs_array args = { 0, 0, NULL}; pid_t child_id; @@ -2798,14 +2805,14 @@ openURL (CT ct, char **file) } ce->ce_unlink = (*file == NULL); - caching = 0; + caching = false; cachefile[0] = '\0'; if (find_cache(NULL, wcachesw, &cachetype, e->eb_content->c_id, cachefile, sizeof(cachefile)) != NOTOK) { if (*file == NULL) { ce->ce_unlink = 0; - caching = 1; + caching = true; } } @@ -2936,7 +2943,7 @@ get_leftover_mp_content (CT ct, int before /* or after */) { struct multipart *m = (struct multipart *) ct->c_ctparams; char *boundary; - int found_boundary = 0; + bool found_boundary = false; int max = BUFSIZ; char *bufp = NULL; size_t buflen; @@ -2981,11 +2988,11 @@ get_leftover_mp_content (CT ct, int before /* or after */) if (before) { if (! strcmp (bufp, boundary)) { - found_boundary = 1; + found_boundary = true; } } else { if (! found_boundary && ! strcmp (bufp, boundary)) { - found_boundary = 1; + found_boundary = true; continue; } } @@ -3266,7 +3273,9 @@ parse_header_attrs (const char *filename, const char *fieldname, while (*cp == ';') { char *dp, *vp, *up, *nameptr, *valptr, *charset = NULL, *lang = NULL; - int encoded = 0, partial = 0, len = 0, index = 0; + bool encoded = false; + bool partial = false; + int len = 0, index = 0; cp++; while (isspace ((unsigned char) *cp)) @@ -3316,11 +3325,11 @@ parse_header_attrs (const char *filename, const char *fieldname, for (vp = cp; vp < up; vp++) { if (*vp == '*' && vp < up - 1) { - partial = 1; + partial = true; continue; } if (*vp == '*' && vp == up - 1) { - encoded = 1; + encoded = true; } else if (partial) { if (isdigit((unsigned char) *vp)) index = *vp - '0' + index * 10; diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 5d664090..bbad9f08 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -582,9 +582,9 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, int alternating, nowalternate, result; struct multipart *m = (struct multipart *) ct->c_ctparams; struct part *part; - int request_matched; - int display_success; - int mult_alt_done; + bool request_matched; + bool display_success; + bool mult_alt_done; int ret; CT p; @@ -602,9 +602,9 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, */ result = NOTOK; - request_matched = 0; - display_success = 0; - mult_alt_done = 0; + request_matched = false; + display_success = false; + mult_alt_done = false; for (part = m->mp_parts; part; part = part->mp_next) { p = part->mp_part; @@ -625,7 +625,7 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, inlineonly, fmt); switch (inneresult) { case NOTOK: /* hard display error */ - request_matched = 1; + request_matched = true; if (alternate && !alternating) { result = NOTOK; goto out; @@ -636,8 +636,8 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, continue; case OK: /* display successful */ - request_matched = 1; - display_success = 1; + request_matched = true; + display_success = true; result = OK; /* if we got success on a sub-part of @@ -645,7 +645,7 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, * there's a chance an explicit part should be * matched later in the alternatives. */ if (alternating) { - mult_alt_done = 1; + mult_alt_done = true; } else if (alternate) { alternate = nowalternate = 0; } @@ -792,7 +792,8 @@ static int parse_display_string (CT ct, char *cp, int *xstdin, int *xlist, char *file, char *buffer, size_t buflen, int multipart) { - int len, quoted = 0; + int len; + bool quoted = false; char *bp = buffer, *pp; CI ci = &ct->c_ctinfo; @@ -963,7 +964,7 @@ parse_display_string (CT ct, char *cp, int *xstdin, int *xlist, *pp++ = '\''; buflen--; bp++; - quoted = 1; + quoted = true; } /* Escape existing quotes */ while ((pp = strchr (pp, '\'')) && buflen > 3) { @@ -978,7 +979,7 @@ parse_display_string (CT ct, char *cp, int *xstdin, int *xlist, *pp++ = '\''; buflen -= 2; bp += 2; - quoted = 0; + quoted = false; } else { /* Not quoted. This should not be reached with the current code, but handle the condition @@ -1017,7 +1018,7 @@ parse_display_string (CT ct, char *cp, int *xstdin, int *xlist, if (! found_quote) { *bp++ = '\''; buflen--; - quoted = 0; + quoted = false; } } } @@ -1068,7 +1069,7 @@ convert_charset (CT ct, char *dest_charset, int *message_mods) { FILE **fp = NULL; size_t begin; size_t end; - int opened_input_file = 0; + bool opened_input_file = false; char src_buffer[BUFSIZ]; size_t dest_buffer_size = BUFSIZ; char *dest_buffer = mh_xmalloc(dest_buffer_size); @@ -1106,7 +1107,7 @@ convert_charset (CT ct, char *dest_charset, int *message_mods) { advise (*file, "unable to open for reading"); status = NOTOK; } else { - opened_input_file = 1; + opened_input_file = true; } } } diff --git a/uip/mhstore.c b/uip/mhstore.c index e09be9de..3c7866c5 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -63,8 +63,9 @@ static void pipeser (int); int main (int argc, char **argv) { + int msgnum, *icachesw, autosw = 0; /* verbosw defaults to 1 for backward compatibility. */ - int msgnum, *icachesw, autosw = 0, verbosw = 1; + bool verbosw = true; const char *clobbersw = "always"; char *cp, *file = NULL, *outfile = NULL, *folder = NULL; char *maildir, buf[100], **argp; @@ -185,10 +186,10 @@ do_cache: continue; case VERBSW: - verbosw = 1; + verbosw = true; continue; case NVERBSW: - verbosw = 0; + verbosw = false; continue; case CLOBBERSW: if (!(cp = *argp++) || *cp == '-') diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index f579fcd9..2b944843 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -228,12 +228,14 @@ store_application (CT ct, mhstoreinfo_t info) * attribute/value pairs which specify if this a tar file. */ if (!ct->c_storeproc && ct->c_subtype == APPLICATION_OCTETS) { - int tarP = 0, zP = 0, gzP = 0; + bool tarP = false; + bool zP = false; + bool gzP = false; char *cp; if ((cp = get_param(ci->ci_first_pm, "type", ' ', 1))) { if (strcasecmp (cp, "tar") == 0) - tarP = 1; + tarP = true; } /* check for "conversions=compress" attribute */ @@ -241,11 +243,11 @@ store_application (CT ct, mhstoreinfo_t info) (cp = get_param(ci->ci_first_pm, "x-conversions", ' ', 1))) { if (strcasecmp (cp, "compress") == 0 || strcasecmp (cp, "x-compress") == 0) { - zP = 1; + zP = true; } if (strcasecmp (cp, "gzip") == 0 || strcasecmp (cp, "x-gzip") == 0) { - gzP = 1; + gzP = true; } } @@ -488,9 +490,11 @@ ct_compar (CT *a, CT *b) static int store_content (CT ct, CT p, mhstoreinfo_t info) { - int appending = 0, msgnum = 0; - int is_partial = 0, first_partial = 0; - int last_partial = 0; + bool appending = false; + int msgnum = 0; + bool is_partial = false; + bool first_partial = false; + bool last_partial = false; char *cp, buffer[BUFSIZ]; /* @@ -510,13 +514,13 @@ store_content (CT ct, CT p, mhstoreinfo_t info) struct partial *pm = (struct partial *) ct->c_ctparams; /* Yep, it's a message/partial */ - is_partial = 1; + is_partial = true; /* But is it the first and/or last in the collection? */ if (pm->pm_partno == 1) - first_partial = 1; + first_partial = true; if (pm->pm_maxno && pm->pm_partno == pm->pm_maxno) - last_partial = 1; + last_partial = true; /* * If "p" is a valid pointer, then it points to the @@ -525,7 +529,7 @@ store_content (CT ct, CT p, mhstoreinfo_t info) * from the previous iteration of this function. */ if (p) { - appending = 1; + appending = true; if (! ct->c_storage) { ct->c_storage = mh_xstrdup(FENDNULL(p->c_storage)); @@ -1217,7 +1221,7 @@ clobber_check (char *original_file, mhstoreinfo_t info) { char *file; char *cwd = NULL; - int check_again; + bool check_again; if (! strcmp (original_file, "-")) { return original_file; @@ -1244,7 +1248,7 @@ clobber_check (char *original_file, mhstoreinfo_t info) { struct stat st; file = original_file; - check_again = 0; + check_again = false; switch (info->clobber_policy) { case NMH_CLOBBER_ALWAYS: @@ -1310,7 +1314,7 @@ clobber_check (char *original_file, mhstoreinfo_t info) { file = cwd ? concat (cwd, "/", buf, NULL) : mh_xstrdup(buf); } - check_again = 1; + check_again = true; break; } } diff --git a/uip/msgchk.c b/uip/msgchk.c index a553300f..21aca33b 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -344,7 +344,8 @@ remotemail (char *host, char *port, char *user, char *proxy, int notifysw, int personal, int snoop, int sasl, char *saslmech, int tls, const char *auth_svc) { - int nmsgs, nbytes, status; + int nmsgs, nbytes; + bool status; if (auth_svc == NULL) { if (saslmech && ! strcasecmp(saslmech, "xoauth2")) { @@ -378,14 +379,14 @@ remotemail (char *host, char *port, char *user, char *proxy, int notifysw, else notifysw = 0; - status = 0; + status = false; } else { if (notifysw & NT_NMAI) printf (personal ? "You don't %s%s" : "%s doesn't %s", personal ? "" : user, "have any mail waiting"); else notifysw = 0; - status = 1; + status = true; } if (notifysw) printf (" on %s\n", host); diff --git a/uip/pick.c b/uip/pick.c index 4bfc17a6..01e2081a 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -68,7 +68,7 @@ main (int argc, char **argv) struct msgs *mp, *mp2; FILE *fp; int debug = 0; - int reverse = 0; + bool reverse = false; int start, end, inc; if (nmh_init(argv[0], true, true)) { return 1; } @@ -104,7 +104,7 @@ main (int argc, char **argv) done (0); case REVSW: - reverse = 1; + reverse = true; continue; case CCSW: diff --git a/uip/post.c b/uip/post.c index ee0d380b..2917945b 100644 --- a/uip/post.c +++ b/uip/post.c @@ -230,7 +230,7 @@ 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 int format = 1; /* format addresses */ +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 */ @@ -390,10 +390,10 @@ main (int argc, char **argv) continue; case FRMTSW: - format++; + format = true; continue; case NFRMTSW: - format = 0; + format = false; continue; case BITSTUFFSW: @@ -1234,7 +1234,8 @@ static int putadr (char *name, char *aka, struct mailname *mp, FILE *out, unsigned int flags, char *savehdr, unsigned int savehdrsize) { - int len, saveappend = 0; + int len; + bool saveappend = false; unsigned int shlen; char *cp; char buffer[BUFSIZ]; @@ -1252,7 +1253,7 @@ putadr (char *name, char *aka, struct mailname *mp, FILE *out, if (savehdr) { shlen = strlen(savehdr); - saveappend = 1; + saveappend = true; } if (*aka && mp->m_type != UUCPHOST && !mp->m_pers) @@ -1274,7 +1275,7 @@ putadr (char *name, char *aka, struct mailname *mp, FILE *out, fprintf (out, ",\n%*s", linepos = nameoutput, ""); if (saveappend) { if (shlen + 2 + nameoutput + len >= savehdrsize) { - saveappend = 0; + saveappend = false; } else { snprintf(savehdr + shlen, savehdrsize - shlen, ",\n%*s", linepos, ""); @@ -1285,7 +1286,7 @@ putadr (char *name, char *aka, struct mailname *mp, FILE *out, linepos += 2; if (saveappend) { if (shlen + 2 + len >= savehdrsize) { - saveappend = 0; + saveappend = false; } else { strncat(savehdr, ", ", savehdrsize - shlen); } diff --git a/uip/prompter.c b/uip/prompter.c index 6dcf3bb0..1564852d 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -41,7 +41,7 @@ DEFINE_SWITCH_ARRAY(PROMPTER, switches); static struct termios tio; -static int wtuser = 0; +static bool wtuser; static int sigint = 0; static jmp_buf sigenv; @@ -318,21 +318,21 @@ getln (char *buffer, int n) { int c; char *cp; - static int quoting = 0; + static bool quoting; *buffer = 0; switch (setjmp (sigenv)) { case OK: - wtuser = 1; + wtuser = true; break; case DONE: - wtuser = 0; + wtuser = false; return 0; default: - wtuser = 0; + wtuser = false; return NOTOK; } @@ -342,27 +342,27 @@ getln (char *buffer, int n) for (;;) { switch (c = getchar ()) { case EOF: - quoting = 0; + quoting = false; clearerr (stdin); longjmp (sigenv, DONE); case '\n': if (quoting) { *(cp - 1) = c; - quoting = 0; - wtuser = 0; + quoting = false; + wtuser = false; return 1; } *cp++ = c; *cp = 0; - wtuser = 0; + wtuser = false; return 0; default: if (c == QUOTE) { - quoting = 1; + quoting = true; } else { - quoting = 0; + quoting = false; } if (cp < buffer + n) *cp++ = c; diff --git a/uip/rcvstore.c b/uip/rcvstore.c index fb0a8b94..d952a3a2 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -48,7 +48,8 @@ int main (int argc, char **argv) { int publicsw = -1, zerosw = 0; - int create = 1, unseensw = 1; + int create = 1; + bool unseensw = true; int fd, msgnum; size_t seqp = 0; char *cp, *maildir, *folder = NULL, buf[BUFSIZ]; @@ -93,10 +94,10 @@ main (int argc, char **argv) continue; case UNSEENSW: - unseensw = 1; + unseensw = true; continue; case NUNSEENSW: - unseensw = 0; + unseensw = false; continue; case PUBSW: diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 693cd814..0e6944ec 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -52,9 +52,9 @@ DEFINE_SWITCH_ARRAY(RCVTTY, switches); #undef X static jmp_buf myctx; -static int bell = 1; -static int newline = 1; -static int biff = 0; +static bool bell = true; +static bool newline = true; +static bool biff; static int width = -1; static char *form = NULL; static char *format = NULL; @@ -103,7 +103,7 @@ main (int argc, char **argv) done (0); case BIFFSW: - biff = 1; + biff = true; continue; case FORMSW: @@ -123,16 +123,16 @@ main (int argc, char **argv) width = atoi(cp); continue; case NLSW: - newline = 1; + newline = true; continue; case NNLSW: - newline = 0; + newline = false; continue; case BELSW: - bell = 1; + bell = true; continue; case NBELSW: - bell = 0; + bell = false; continue; } diff --git a/uip/refile.c b/uip/refile.c index f9d3b54f..9ee6dab4 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -58,7 +58,9 @@ static void copy_seqs (struct msgs *, int, struct msgs *, int); int main (int argc, char **argv) { - int linkf = 0, preserve = 0, retainseqs = 0, filep = 0; + int linkf = 0, preserve = 0; + bool retainseqs = false; + int filep = 0; int foldp = 0, isdf = 0, unlink_msgs = 0; int i, msgnum; char *cp, *folder = NULL, buf[BUFSIZ]; @@ -110,10 +112,10 @@ main (int argc, char **argv) continue; case RETAINSEQSSW: - retainseqs = 1; + retainseqs = true; continue; case NRETAINSEQSSW: - retainseqs = 0; + retainseqs = false; continue; case UNLINKSW: diff --git a/uip/repl.c b/uip/repl.c index 83e64a5b..e114273d 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -117,7 +117,8 @@ int main (int argc, char **argv) { int i, isdf = 0; - int anot = 0, inplace = 1; + int anot = 0; + bool inplace = true; int nedit = 0, nwhat = 0; int atfile = 0; int fmtproc = -1; @@ -270,10 +271,10 @@ main (int argc, char **argv) continue; case INPLSW: - inplace++; + inplace = true; continue; case NINPLSW: - inplace = 0; + inplace = false; continue; case MIMESW: diff --git a/uip/replsbr.c b/uip/replsbr.c index 966744c0..46742e66 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -23,7 +23,7 @@ static char *badaddrs = NULL; static char *dfhost = NULL; static struct mailname mq; -static int nodupcheck = 0; /* If set, no check for duplicates */ +static bool nodupcheck; /* If set, no check for duplicates */ static char *addrcomps[] = { "from", @@ -367,9 +367,9 @@ replconcataddr(char *orig, char *str) { char *cp; - nodupcheck = 1; + nodupcheck = true; cp = replformataddr(orig, str); - nodupcheck = 0; + nodupcheck = false; return cp; } @@ -487,7 +487,7 @@ static char * fix_addresses (char *str) { char *fixed_str = NULL; - int fixed_address = 0; + bool fixed_address = false; if (str) { /* @@ -564,7 +564,7 @@ fix_addresses (char *str) { adr = getname (new_adr); if (adr != NULL && (mp = getm (adr, dfhost, dftype, NULL, 0)) != NULL) { - fixed_address = 1; + fixed_address = true; mnfree (mp); } free (angle_addr); diff --git a/uip/scan.c b/uip/scan.c index 7fd636a7..ba238d9c 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -45,7 +45,8 @@ main (int argc, char **argv) int width = -1, revflag = 0; int i, state, msgnum; ivector_t seqnum = ivector_create (0); - int unseen, num_unseen_seq = 0; + bool unseen; + int num_unseen_seq = 0; char *cp, *maildir, *file = NULL, *folder = NULL; char *form = NULL, *format = NULL, buf[BUFSIZ]; char **argp, *nfs, **arguments; @@ -246,10 +247,10 @@ main (int argc, char **argv) * Check if message is in any sequence given * by Unseen-Sequence profile entry. */ - unseen = 0; + unseen = false; for (i = 0; i < num_unseen_seq; i++) { if (in_sequence(mp, ivector_at (seqnum, i), msgnum)) { - unseen = 1; + unseen = true; break; } } diff --git a/uip/sendsbr.c b/uip/sendsbr.c index cc00e0ce..f2c2762f 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -906,7 +906,7 @@ get_message_header_info(FILE *in, char *format) { int dat[5]; struct format *fmt; struct stat st; - int parsing_header; + bool parsing_header; m_getfld_state_t gstate; charstring_t buffer = charstring_create(0); char *retval; @@ -922,7 +922,7 @@ get_message_header_info(FILE *in, char *format) { * Read in the message and process the header. */ rewind (in); - parsing_header = 1; + parsing_header = true; gstate = m_getfld_state_init(in); do { char name[NAMESZ], rbuf[NMH_BUFSIZ]; @@ -949,7 +949,7 @@ get_message_header_info(FILE *in, char *format) { break; } default: - parsing_header = 0; + parsing_header = false; } } while (parsing_header); m_getfld_state_destroy(&gstate); diff --git a/uip/show.c b/uip/show.c index 25ede029..3943118a 100644 --- a/uip/show.c +++ b/uip/show.c @@ -66,8 +66,10 @@ static int is_nontext(char *); int main (int argc, char **argv) { - int draftsw = 0, headersw = 1; - int nshow = 0, checkmime = 1, mime = 0; + int draftsw = 0; + bool headersw = true; + int nshow = 0, checkmime = 1; + bool mime = false; int isdf = 0, mode = SHOW, msgnum; char *cp, *maildir, *file = NULL, *folder = NULL, *proc, *program; char buf[BUFSIZ], **argp, **arguments; @@ -93,10 +95,10 @@ main (int argc, char **argv) done (1); case HEADSW: - headersw = 1; + headersw = true; goto non_mhl_switches; case NHEADSW: - headersw = 0; + headersw = false; /* FALLTHRU */ case CONCATSW: case NCONCATSW: @@ -206,7 +208,7 @@ usage: app_msgarg(&vec, mh_xstrdup(m_draft(folder, NULL, 1, &isdf))); else app_msgarg(&vec, file); - headersw = 0; + headersw = false; goto go_to_it; } @@ -279,13 +281,13 @@ go_to_it: ; /* loop through selected messages and check for MIME */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected (mp, msgnum) && is_nontext (m_name (msgnum))) { - mime = 1; + mime = true; break; } } else { /* check the file or draft for MIME */ if (is_nontext (vec.msgs[vec.size - 1])) - mime = 1; + mime = true; } } diff --git a/uip/slocal.c b/uip/slocal.c index 98c1af16..b3f0aa23 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -421,7 +421,10 @@ localmail (int fd, char *mdlvr) static int usr_delivery (int fd, char *delivery, int su) { - int i, accept, status=1, won, vecp, next; + int i; + bool accept; + int status=1, won, vecp; + bool next; char *field, *pattern, *action, *result, *string; char buffer[BUFSIZ], tmpbuf[BUFSIZ]; char *vec[NVEC]; @@ -445,7 +448,7 @@ usr_delivery (int fd, char *delivery, int su) } won = 0; - next = 1; + next = true; /* read and process delivery file */ while (fgets (buffer, sizeof(buffer), fp)) { @@ -503,7 +506,7 @@ usr_delivery (int fd, char *delivery, int su) * Take action, and consider delivered if * action is successful. */ - accept = 1; + accept = true; break; case 'R': @@ -513,7 +516,7 @@ usr_delivery (int fd, char *delivery, int su) * Take action, but don't consider delivered, even * if action is successful */ - accept = 0; + accept = false; break; } @@ -556,9 +559,9 @@ usr_delivery (int fd, char *delivery, int su) */ if ((p = lookup (hdrs, field)) && (p->p_value != NULL) && matches (p->p_value, pattern)) { - next = 1; + next = true; } else { - next = 0; + next = false; continue; } break; @@ -630,7 +633,7 @@ usr_delivery (int fd, char *delivery, int su) break; } - if (status) next = 0; /* action failed, mark for 'N' result */ + if (status) next = false; /* action failed, mark for 'N' result */ if (accept && status == 0) won++; diff --git a/uip/sortm.c b/uip/sortm.c index 9807a02b..a47eb9e4 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -76,7 +76,7 @@ main (int argc, char **argv) struct msgs_array msgs = { 0, 0, NULL }; struct msgs *mp; struct smsg **dlist; - int checksw = 0; + bool checksw = false; if (nmh_init(argv[0], true, true)) { return 1; } @@ -158,10 +158,10 @@ main (int argc, char **argv) continue; case CHECKSW: - checksw = 1; + checksw = true; continue; case NCHECKSW: - checksw = 0; + checksw = false; continue; } } diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 8b0b2ac7..50001f17 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -386,7 +386,7 @@ WhatNow (int argc, char **argv) * Attach files to current draft. */ - int verbose = 0; + bool verbose = false; char **ap; if (checkmimeheader(drft)) @@ -395,7 +395,7 @@ WhatNow (int argc, char **argv) for (ap = argp+1; *ap; ++ap) { if (strcmp(*ap, "-v") == 0) { ++argp; - verbose = 1; + verbose = true; } else if (*ap[0] != '-') { break; } @@ -647,7 +647,7 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, char *cp, *prog, **vec; struct stat st; - int slinked = 0; + bool slinked = false; /* Was there a previous edit session? */ if (reedit && (*ed || edsave)) { @@ -683,9 +683,9 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, if (symlink (altpath, linkpath) < 0) { adios (linkpath, "symlink"); } - slinked = 1; + slinked = true; } else { - slinked = 0; + slinked = false; } } } @@ -1305,7 +1305,8 @@ checkmimeheader (char *drft) FILE *f; m_getfld_state_t gstate; char buf[NMH_BUFSIZ], name[NAMESZ]; - int state, retval = 0; + int state; + bool retval = false; if ((f = fopen(drft, "r")) == NULL) { admonish(drft, "unable to read draft"); @@ -1321,7 +1322,7 @@ checkmimeheader (char *drft) if (strcasecmp(name, VRSN_FIELD) == 0) { inform("Cannot use attach commands with already-" "formatted MIME message \"%s\"", drft); - retval = 1; + retval = true; break; } continue;