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

19 files changed:
sbr/arglist.c
sbr/base64.c
sbr/encode_rfc2047.c
sbr/ext_hook.c
sbr/fdcompare.c
sbr/fmt_compile.c
sbr/fmt_rfc2047.c
sbr/fmt_scan.c
sbr/m_convert.c
sbr/m_getfld.c
sbr/m_mktemp.c
sbr/m_rand.c
sbr/makedir.c
sbr/mime_type.c
sbr/ruserpass.c
sbr/seq_add.c
sbr/seq_del.c
sbr/showfile.c
sbr/utils.c

index 5ede1fa1200f87d0c257d4270ba409bfd8c170ac..716c8be6d31fe80803c299808f7135e15324e343 100644 (file)
@@ -39,13 +39,15 @@ char **
 argsplit(char *command, char **file, int *argp)
 {
     char **argvarray, *p;
 argsplit(char *command, char **file, int *argp)
 {
     char **argvarray, *p;
-    int space = 0, metachar = 0, i;
+    int i;
 
 
+    bool space = false;
+    bool metachar = false;
     for (p = command; *p; p++) {
        if (*p == ' ' || *p == '\t') {
     for (p = command; *p; p++) {
        if (*p == ' ' || *p == '\t') {
-               space = 1;
+               space = true;
        } else if (strchr(METACHARS, *p)) {
        } else if (strchr(METACHARS, *p)) {
-               metachar = 1;
+               metachar = true;
                break;
        }
     }
                break;
        }
     }
index cbd225dee062c60fa42ebb8415350bc17cb4f835..2afad491afbfccb41d404d109adc777feff09b96 100644 (file)
@@ -29,8 +29,8 @@ writeBase64aux (FILE *in, FILE *out, int crlf)
 {
     unsigned int cc, n;
     unsigned char inbuf[3];
 {
     unsigned int cc, n;
     unsigned char inbuf[3];
-    int skipnl = 0;
 
 
+    bool skipnl = false;
     n = BPERLIN;
     while ((cc = fread (inbuf, sizeof(*inbuf), sizeof(inbuf), in)) > 0) {
        unsigned long bits;
     n = BPERLIN;
     while ((cc = fread (inbuf, sizeof(*inbuf), sizeof(inbuf), in)) > 0) {
        unsigned long bits;
@@ -69,7 +69,7 @@ writeBase64aux (FILE *in, FILE *out, int crlf)
                            inbuf[cc++] = '\n';
                        else
                            ungetc('\n', in);
                            inbuf[cc++] = '\n';
                        else
                            ungetc('\n', in);
-                       skipnl = 1;
+                       skipnl = true;
                    } else {
                        /* This only works as long as sizeof(inbuf) == 3 */
                        ungetc(inbuf[cc - 1], in);
                    } else {
                        /* This only works as long as sizeof(inbuf) == 3 */
                        ungetc(inbuf[cc - 1], in);
@@ -78,7 +78,7 @@ writeBase64aux (FILE *in, FILE *out, int crlf)
                        inbuf[++i] = '\n';
                    }
                } else {
                        inbuf[++i] = '\n';
                    }
                } else {
-                   skipnl = 0;
+                   skipnl = false;
                }
            }
        }
                }
            }
        }
@@ -250,7 +250,6 @@ int
 decodeBase64 (const char *encoded, unsigned char **decoded, size_t *len,
              int skip_crs, unsigned char *digest) {
     const char *cp = encoded;
 decodeBase64 (const char *encoded, unsigned char **decoded, size_t *len,
              int skip_crs, unsigned char *digest) {
     const char *cp = encoded;
-    int self_delimiting = 0;
     int bitno, skip;
     uint32_t bits;
     /* Size the decoded string very conservatively. */
     int bitno, skip;
     uint32_t bits;
     /* Size the decoded string very conservatively. */
@@ -264,6 +263,7 @@ decodeBase64 (const char *encoded, unsigned char **decoded, size_t *len,
     bits = 0L;
     skip = 0;
 
     bits = 0L;
     skip = 0;
 
+    bool self_delimiting = false;
     for (; *cp; ++cp) {
         switch (*cp) {
             unsigned char value;
     for (; *cp; ++cp) {
         switch (*cp) {
             unsigned char value;
@@ -318,7 +318,7 @@ test_end:
             case '=':
                 if (++skip <= 3)
                     goto test_end;
             case '=':
                 if (++skip <= 3)
                     goto test_end;
-                self_delimiting = 1;
+                self_delimiting = true;
                 break;
         }
     }
                 break;
         }
     }
index 0ded2e932cfa88fae443df7c9a96c1aa80307a0e..e7ccd308ab0bd962be121558a90948742bb0ddb4 100644 (file)
@@ -160,7 +160,7 @@ static int
 field_encode_quoted(const char *name, char **value, const char *charset,
                    int ascii, int encoded, int phraserules)
 {
 field_encode_quoted(const char *name, char **value, const char *charset,
                    int ascii, int encoded, int phraserules)
 {
-    int prefixlen = name ? strlen(name) + 2: 0, outlen = 0, column, newline = 1;
+    int prefixlen = name ? strlen(name) + 2: 0, outlen = 0, column;
     int charsetlen = strlen(charset), utf8;
     char *output = NULL, *p, *q = NULL;
 
     int charsetlen = strlen(charset), utf8;
     char *output = NULL, *p, *q = NULL;
 
@@ -175,6 +175,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
 
     utf8 = strcasecmp(charset, "UTF-8") == 0;
 
 
     utf8 = strcasecmp(charset, "UTF-8") == 0;
 
+    bool newline = true;
     while (*p != '\0') {
        /*
         * Start a new line, if it's time
     while (*p != '\0') {
        /*
         * Start a new line, if it's time
@@ -225,7 +226,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
            tokenlen = snprintf(q, outlen - (q - output), "=?%s?Q?", charset);
            q += tokenlen;
            column = prefixlen + tokenlen;
            tokenlen = snprintf(q, outlen - (q - output), "=?%s?Q?", charset);
            q += tokenlen;
            column = prefixlen + tokenlen;
-           newline = 0;
+           newline = false;
        }
 
        /*
        }
 
        /*
@@ -266,7 +267,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
            continue;
 
        if (column >= ENCODELINELIMIT - 2) {
            continue;
 
        if (column >= ENCODELINELIMIT - 2) {
-           newline = 1;
+           newline = true;
        } else if (utf8) {
            /*
             * Okay, this is a bit weird, but to explain a bit more ...
        } else if (utf8) {
            /*
             * Okay, this is a bit weird, but to explain a bit more ...
@@ -282,7 +283,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
             * allow for the encoded output.
             */
            if (column + (utf8len(p) * 3) > ENCODELINELIMIT - 2) {
             * allow for the encoded output.
             */
            if (column + (utf8len(p) * 3) > ENCODELINELIMIT - 2) {
-               newline = 1;
+               newline = true;
            }
        }
     }
            }
        }
     }
index df1e7dc4045a4b0ffb04e16197aba32f1ea5cf0a..b88be2db45d63ec9de8f31f7ba5ca2f97d53ed40 100644 (file)
@@ -18,7 +18,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2)
     int                vecp;                   /* Vector index */
     char       *program;               /* Name of program to execute */
 
     int                vecp;                   /* Vector index */
     char       *program;               /* Name of program to execute */
 
-    static  int        did_message = 0;        /* set if we've already output a message */
+    static bool        did_message;            /* set if we've already output a message */
 
     if ((hook = context_find(hook_name)) == NULL)
        return OK;
 
     if ((hook = context_find(hook_name)) == NULL)
        return OK;
@@ -47,7 +47,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2)
     if (status == OK)
        return OK;
 
     if (status == OK)
        return OK;
 
-    if (did_message == 0) {
+    if (!did_message) {
         char *msghook;
         if ((msghook = context_find("msg-hook")) != NULL)
             inform("%s", msghook);
         char *msghook;
         if ((msghook = context_find("msg-hook")) != NULL)
             inform("%s", msghook);
@@ -56,7 +56,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2)
             snprintf(errbuf, sizeof(errbuf), "external hook \"%s\"", hook);
             pidstatus(status, stderr, errbuf);
         }
             snprintf(errbuf, sizeof(errbuf), "external hook \"%s\"", hook);
             pidstatus(status, stderr, errbuf);
         }
-        did_message = 1;
+        did_message = true;
     }
 
     return NOTOK;
     }
 
     return NOTOK;
index 7df9a89a84bfa441f7e135b03555bd054f7e33df..925a026a152b37c2e2dca3039535f629d576122b 100644 (file)
 int
 fdcompare (int fd1, int fd2)
 {
 int
 fdcompare (int fd1, int fd2)
 {
-    int i, n1, n2, resp;
+    int i, n1, n2;
     char *c1, *c2;
     char b1[BUFSIZ], b2[BUFSIZ];
 
     char *c1, *c2;
     char b1[BUFSIZ], b2[BUFSIZ];
 
-    resp = 1;
+    bool resp = true;
     while ((n1 = read (fd1, b1, sizeof(b1))) >= 0
            && (n2 = read (fd2, b2, sizeof(b2))) >= 0
            && n1 == n2) {
     while ((n1 = read (fd1, b1, sizeof(b1))) >= 0
            && (n2 = read (fd2, b2, sizeof(b2))) >= 0
            && n1 == n2) {
@@ -23,13 +23,13 @@ fdcompare (int fd1, int fd2)
        c2 = b2;
        for (i = n1 < (int) sizeof(b1) ? n1 : (int) sizeof(b1); i--;)
            if (*c1++ != *c2++) {
        c2 = b2;
        for (i = n1 < (int) sizeof(b1) ? n1 : (int) sizeof(b1); i--;)
            if (*c1++ != *c2++) {
-               resp = 0;
+               resp = false;
                goto leave;
            }
        if (n1 < (int) sizeof(b1))
            goto leave;
     }
                goto leave;
            }
        if (n1 < (int) sizeof(b1))
            goto leave;
     }
-    resp = 0;
+    resp = false;
 
 leave: ;
     lseek(fd1, 0, SEEK_SET);
 
 leave: ;
     lseek(fd1, 0, SEEK_SET);
index bea76e6c5969a1510998230815053748827520ec..ce32414f13760aeb0f10f3783314314dce0a0994 100644 (file)
@@ -390,14 +390,14 @@ fmt_compile(char *fstring, struct format **fmt, int reset_comptable)
 {
     char *cp;
     size_t i;
 {
     char *cp;
     size_t i;
-    static int comptable_initialized = 0;
+    static bool comptable_initialized;
 
     format_string = mh_xstrdup(fstring);
     usr_fstring = fstring;
 
     if (reset_comptable || !comptable_initialized) {
        free_comptable();
 
     format_string = mh_xstrdup(fstring);
     usr_fstring = fstring;
 
     if (reset_comptable || !comptable_initialized) {
        free_comptable();
-       comptable_initialized = 1;
+       comptable_initialized = true;
     }
 
     /* it takes at least 4 char to generate one format so we
     }
 
     /* it takes at least 4 char to generate one format so we
index 8c799e14c77b1197c684ab446c163df018c31b66..d98b50081ce3dd1abe7e3a870c8241a5264027ab 100644 (file)
@@ -73,11 +73,8 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
     char *startofmime, *endofmime, *endofcharset;
     int c, quoted_printable;
     int encoding_found = 0;    /* did we decode anything?                */
     char *startofmime, *endofmime, *endofcharset;
     int c, quoted_printable;
     int encoding_found = 0;    /* did we decode anything?                */
-    int between_encodings = 0; /* are we between two encodings?          */
-    int equals_pending = 0;    /* is there a '=' pending?                */
     int whitespace = 0;                /* how much whitespace between encodings? */
 #ifdef HAVE_ICONV
     int whitespace = 0;                /* how much whitespace between encodings? */
 #ifdef HAVE_ICONV
-    int use_iconv = 0;          /* are we converting encoding with iconv? */
     iconv_t cd = NULL;
     int fromutf8 = 0;
     char *saveq, *convbuf = NULL;
     iconv_t cd = NULL;
     int fromutf8 = 0;
     char *saveq, *convbuf = NULL;
@@ -94,13 +91,16 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
     if (!strchr (str, '='))
        return 0;
 
     if (!strchr (str, '='))
        return 0;
 
+    bool use_iconv = false; /* are we converting encoding with iconv? */
+    bool between_encodings = false;
+    bool equals_pending = false;
     for (p = str, q = dst; *p; p++) {
 
         /* reset iconv */
 #ifdef HAVE_ICONV
         if (use_iconv) {
            iconv_close(cd);
     for (p = str, q = dst; *p; p++) {
 
         /* reset iconv */
 #ifdef HAVE_ICONV
         if (use_iconv) {
            iconv_close(cd);
-           use_iconv = 0;
+           use_iconv = false;
         }
 #endif
        /*
         }
 #endif
        /*
@@ -109,8 +109,8 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
         */
        if (equals_pending) {
            ADDCHR('=');
         */
        if (equals_pending) {
            ADDCHR('=');
-           equals_pending = 0;
-           between_encodings = 0;      /* we have added non-whitespace text */
+           equals_pending = false;
+           between_encodings = false;  /* we have added non-whitespace text */
        }
 
        if (*p != '=') {
        }
 
        if (*p != '=') {
@@ -118,12 +118,12 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
            if (between_encodings && is_lws(*p))
                whitespace++;
            else
            if (between_encodings && is_lws(*p))
                whitespace++;
            else
-               between_encodings = 0;  /* we have added non-whitespace text */
+               between_encodings = false;      /* we have added non-whitespace text */
            ADDCHR(*p);
            continue;
        }
 
            ADDCHR(*p);
            continue;
        }
 
-       equals_pending = 1;     /* we have a '=' pending */
+       equals_pending = true;
 
        /* Check for initial =? */
        if (*p == '=' && p[1] == '?' && p[2]) {
 
        /* Check for initial =? */
        if (*p == '=' && p[1] == '?' && p[2]) {
@@ -159,7 +159,7 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
                fromutf8 = !strcasecmp(startofmime, "UTF-8");
                *pp = '?';
                 if (cd == (iconv_t)-1) continue;
                fromutf8 = !strcasecmp(startofmime, "UTF-8");
                *pp = '?';
                 if (cd == (iconv_t)-1) continue;
-               use_iconv = 1;
+               use_iconv = true;
 #else
                continue;
 #endif
 #else
                continue;
 #endif
@@ -203,7 +203,7 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
             * We've found an encoded word, so we can drop
             * the '=' that was pending
             */
             * We've found an encoded word, so we can drop
             * the '=' that was pending
             */
-           equals_pending = 0;
+           equals_pending = false;
 
            /*
             * If we are between two encoded words separated only by
 
            /*
             * If we are between two encoded words separated only by
@@ -222,7 +222,7 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
             * malloc 0 bytes but skip on to the end
             */
            if (endofmime == startofmime && use_iconv) {
             * malloc 0 bytes but skip on to the end
             */
            if (endofmime == startofmime && use_iconv) {
-               use_iconv = 0;
+               use_iconv = false;
                iconv_close(cd);
             }
 
                iconv_close(cd);
             }
 
@@ -355,7 +355,7 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
            p = endofmime + 1;
 
            encoding_found = 1;         /* we found (at least 1) encoded word */
            p = endofmime + 1;
 
            encoding_found = 1;         /* we found (at least 1) encoded word */
-           between_encodings = 1;      /* we have just decoded something     */
+           between_encodings = true;   /* we have just decoded something     */
            whitespace = 0;             /* re-initialize amount of whitespace */
        }
     }
            whitespace = 0;             /* re-initialize amount of whitespace */
        }
     }
index 61269b34c0219f93b0cb39e0f0636014fa40cc1e..2e547286fd81e3c1e3771a7806aa710a0167916c 100644 (file)
@@ -132,7 +132,6 @@ cptrimmed(charstring_t dest, char *str, int wid, char fill, size_t max) {
     char *altstr = NULL;
 #endif
     char *sp;          /* current position in source string */
     char *altstr = NULL;
 #endif
     char *sp;          /* current position in source string */
-    int prevCtrl = 1;
 
     /* get alignment */
     rjust = 0;
 
     /* get alignment */
     rjust = 0;
@@ -144,6 +143,7 @@ cptrimmed(charstring_t dest, char *str, int wid, char fill, size_t max) {
 
     trimmed = rjust ? charstring_create(remaining) : dest;
 
 
     trimmed = rjust ? charstring_create(remaining) : dest;
 
+    bool prevCtrl = true;
     if ((sp = str)) {
 #ifdef MULTIBYTE_SUPPORT
        if (mbtowc(NULL, NULL, 0)) {} /* reset shift state */
     if ((sp = str)) {
 #ifdef MULTIBYTE_SUPPORT
        if (mbtowc(NULL, NULL, 0)) {} /* reset shift state */
@@ -193,10 +193,10 @@ cptrimmed(charstring_t dest, char *str, int wid, char fill, size_t max) {
                    remaining--;
                }
 
                    remaining--;
                }
 
-               prevCtrl = 1;
+               prevCtrl = true;
                continue;
            }
                continue;
            }
-           prevCtrl = 0;
+           prevCtrl = false;
 
 #ifdef MULTIBYTE_SUPPORT
            if (w >= 0 && remaining >= w) {
 
 #ifdef MULTIBYTE_SUPPORT
            if (w >= 0 && remaining >= w) {
index 06e31afec898ef028dc114d455f4e75098f60cd3..8a86535f5996b075c932dc46003f1b0ee5c0679c 100644 (file)
@@ -37,7 +37,7 @@ static int attr (struct msgs *, char *);
 int
 m_convert (struct msgs *mp, char *name)
 {
 int
 m_convert (struct msgs *mp, char *name)
 {
-    int first, last, found, count, is_range, err;
+    int first, last, found, count, err;
     char *bp, *cp;
 
     /* check if user defined sequence */
     char *bp, *cp;
 
     /* check if user defined sequence */
@@ -54,7 +54,6 @@ m_convert (struct msgs *mp, char *name)
      */
 
     found = 0;
      */
 
     found = 0;
-    is_range = 1;
 
     /*
      * Check for special "new" sequence, which
 
     /*
      * Check for special "new" sequence, which
@@ -129,9 +128,7 @@ rangerr:
 
     } else if (*cp == ':' || *cp == '=') {
 
 
     } else if (*cp == ':' || *cp == '=') {
 
-       if (*cp == '=')
-           is_range = 0;
-
+        bool is_range = *cp == ':';
        cp++;
 
        if (*cp == '-') {
        cp++;
 
        if (*cp == '-') {
@@ -349,9 +346,7 @@ attr (struct msgs *mp, char *cp)
     char op;
     int i, j;
     int found,
     char op;
     int i, j;
     int found,
-       inverted = 0,
        count = 0,              /* range given?  else use entire sequence */
        count = 0,              /* range given?  else use entire sequence */
-       just_one = 0,           /* want entire sequence or range */
        first = 0,
        start = 0;
 
        first = 0,
        start = 0;
 
@@ -364,8 +359,9 @@ attr (struct msgs *mp, char *cp)
     }
 
     /* Check for sequence negation */
     }
 
     /* Check for sequence negation */
+    bool inverted = false;
     if ((dp = context_find (nsequence)) && *dp != '\0' && ssequal (dp, cp)) {
     if ((dp = context_find (nsequence)) && *dp != '\0' && ssequal (dp, cp)) {
-       inverted = 1;
+       inverted = true;
        cp += strlen (dp);
     }
 
        cp += strlen (dp);
     }
 
@@ -374,6 +370,8 @@ attr (struct msgs *mp, char *cp)
     for (dp = cp; isalnum((unsigned char)*dp); dp++)
        continue;
 
     for (dp = cp; isalnum((unsigned char)*dp); dp++)
        continue;
 
+    bool just_one = *dp == '='; /* want entire sequence or range */
+
     if (*dp == ':') {
        bp = dp++;
        count = 1;
     if (*dp == ':') {
        bp = dp++;
        count = 1;
@@ -454,8 +452,6 @@ attr (struct msgs *mp, char *cp)
        if (count == 0 || *ep)
            return BADLST;
 
        if (count == 0 || *ep)
            return BADLST;
 
-       just_one = 1;
-
        op = *bp;
        *bp = '\0';     /* temporarily terminate sequence name */
     }
        op = *bp;
        *bp = '\0';     /* temporarily terminate sequence name */
     }
index bebcf1b4688679e215be426c8867be0416adb4a8..2b5855419f52c295655338cfb41c6a00e94c7eca 100644 (file)
@@ -691,12 +691,10 @@ m_getfld (m_getfld_state_t *gstate, char name[NAMESZ], char *buf, int *bufsz,
             * characters up to the end of this field (newline
             * followed by non-blank) or bufsz-1 characters.
             */
             * characters up to the end of this field (newline
             * followed by non-blank) or bufsz-1 characters.
             */
-           int finished;
-
            cp = buf;
            max = *bufsz-1;
            n = 0;
            cp = buf;
            max = *bufsz-1;
            n = 0;
-           for (finished = 0; ! finished; ) {
+           for (bool finished = false; !finished; ) {
                while (c != '\n'  &&  c != EOF  &&  n++ < max) {
                    if ((c = Getc (s)) != EOF)
                         *cp++ = c;
                while (c != '\n'  &&  c != EOF  &&  n++ < max) {
                    if ((c = Getc (s)) != EOF)
                         *cp++ = c;
@@ -716,14 +714,14 @@ m_getfld (m_getfld_state_t *gstate, char name[NAMESZ], char *buf, int *bufsz,
                        --s->bytes_read;
                    }
                    s->state = FLDPLUS;
                        --s->bytes_read;
                    }
                    s->state = FLDPLUS;
-                   finished = 1;
+                   finished = true;
                } else if (c != ' '  &&  c != '\t') {
                    /* The next character is not folded whitespace, so
                       prepare to move on to the next field.  It's OK
                       if c is EOF, it will be handled on the next
                       call to m_getfld (). */
                    s->state = FLD;
                } else if (c != ' '  &&  c != '\t') {
                    /* The next character is not folded whitespace, so
                       prepare to move on to the next field.  It's OK
                       if c is EOF, it will be handled on the next
                       call to m_getfld (). */
                    s->state = FLD;
-                   finished = 1;
+                   finished = true;
                } else {
                    /* Folded header field, continues on the next line. */
                }
                } else {
                    /* Folded header field, continues on the next line. */
                }
index d4b8fde05154d28b954463c115697cfb62203339..123da576b556b2d9342b012a2f04822afbbd7491 100644 (file)
@@ -51,7 +51,6 @@ m_mktemp (
 {
     static char tmpfil[BUFSIZ];
     int fd = -1;
 {
     static char tmpfil[BUFSIZ];
     int fd = -1;
-    int keep_open = 0;
     mode_t oldmode = umask(077);
 
     if (pfx_in == NULL) {
     mode_t oldmode = umask(077);
 
     if (pfx_in == NULL) {
@@ -69,9 +68,10 @@ m_mktemp (
 
     register_for_removal(tmpfil);
 
 
     register_for_removal(tmpfil);
 
+    bool keep_open = false;
     if (fd_ret != NULL) {
         *fd_ret = fd;
     if (fd_ret != NULL) {
         *fd_ret = fd;
-        keep_open = 1;
+        keep_open = true;
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
@@ -84,7 +84,7 @@ m_mktemp (
             return NULL;
         }
         *fp_ret = fp;
             return NULL;
         }
         *fp_ret = fp;
-        keep_open = 1;
+        keep_open = true;
     }
     if (!keep_open) {
         close(fd);
     }
     if (!keep_open) {
         close(fd);
@@ -151,7 +151,6 @@ m_mktemps(
 {
     char *tmpfil;
     int fd = -1;
 {
     char *tmpfil;
     int fd = -1;
-    int keep_open = 0;
     mode_t oldmode = umask(077);
 
     if (suffix == NULL) {
     mode_t oldmode = umask(077);
 
     if (suffix == NULL) {
@@ -202,9 +201,10 @@ m_mktemps(
 
     register_for_removal(tmpfil);
 
 
     register_for_removal(tmpfil);
 
+    bool keep_open = false;
     if (fd_ret != NULL) {
         *fd_ret = fd;
     if (fd_ret != NULL) {
         *fd_ret = fd;
-        keep_open = 1;
+        keep_open = true;
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
     }
     if (fp_ret != NULL) {
         FILE *fp = fdopen(fd, "w+");
@@ -218,7 +218,7 @@ m_mktemps(
             return NULL;
         }
         *fp_ret = fp;
             return NULL;
         }
         *fp_ret = fp;
-        keep_open = 1;
+        keep_open = true;
     }
     if (!keep_open) {
         close(fd);
     }
     if (!keep_open) {
         close(fd);
index 3227aef9690088c61d7f5152d400615cbc39e951..76e5e17f3fecca82f2dd9807cf99fa5af0df66cb 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <stdlib.h>  /* for abs(), srand(), rand(), arc4random() */
  */
 
 #include <stdlib.h>  /* for abs(), srand(), rand(), arc4random() */
+#include <stdbool.h>
 #include <stdio.h>   /* for fopen(), fread(), fclose() */
 #include <unistd.h>  /* for getpid() */
 #include <time.h>    /* for time() */
 #include <stdio.h>   /* for fopen(), fread(), fclose() */
 #include <unistd.h>  /* for getpid() */
 #include <time.h>    /* for time() */
@@ -14,7 +15,7 @@
 #include "m_rand.h"
 
 #if !HAVE_ARC4RANDOM
 #include "m_rand.h"
 
 #if !HAVE_ARC4RANDOM
-static int seeded = 0;
+static bool seeded = false;
 #endif
 
 
 #endif
 
 
@@ -26,7 +27,8 @@ m_rand (unsigned char *buf, size_t n) {
     unsigned int seed;
 
     if ((devurandom = fopen ("/dev/urandom", "r"))) {
     unsigned int seed;
 
     if ((devurandom = fopen ("/dev/urandom", "r"))) {
-      if (fread (&seed, sizeof (seed), 1, devurandom) == 1) seeded = 1;
+      if (fread (&seed, sizeof (seed), 1, devurandom) == 1)
+          seeded = true;
       fclose (devurandom);
     }
 
       fclose (devurandom);
     }
 
@@ -36,7 +38,7 @@ m_rand (unsigned char *buf, size_t n) {
          arXiv:1005.4117v1 [physics.comp-ph], 22 May 2010, p. 19.
          time() and getpid() shouldn't fail on POSIX platforms. */
       seed = abs ((int) ((time (0) * 181 * ((getpid ()-83) * 359)) % 104729));
          arXiv:1005.4117v1 [physics.comp-ph], 22 May 2010, p. 19.
          time() and getpid() shouldn't fail on POSIX platforms. */
       seed = abs ((int) ((time (0) * 181 * ((getpid ()-83) * 359)) % 104729));
-      seeded = 1;
+      seeded = true;
     }
 
     srand (seed);
     }
 
     srand (seed);
index 9d5e12e537601cb17ca39334450f2974385f7100..04e5d779f7ae1da40c3d3b3557bb2134e371e5a4 100644 (file)
@@ -18,7 +18,6 @@ makedir (const char *dir)
 {
     char            path[PATH_MAX];
     char*           folder_perms_ASCII;
 {
     char            path[PATH_MAX];
     char*           folder_perms_ASCII;
-    int             had_an_error = 0;
     mode_t          folder_perms, saved_umask;
     char*  c;
 
     mode_t          folder_perms, saved_umask;
     char*  c;
 
@@ -43,17 +42,18 @@ makedir (const char *dir)
 
     c = strncpy(path, dir, sizeof(path));
 
 
     c = strncpy(path, dir, sizeof(path));
 
+    bool had_an_error = false;
     while (!had_an_error && (c = strchr((c + 1), '/')) != NULL) {
         *c = '\0';
         if (access(path, X_OK)) {
             if (errno != ENOENT){
                 advise (dir, "unable to create directory");
     while (!had_an_error && (c = strchr((c + 1), '/')) != NULL) {
         *c = '\0';
         if (access(path, X_OK)) {
             if (errno != ENOENT){
                 advise (dir, "unable to create directory");
-                had_an_error = 1;
+                had_an_error = true;
             }
             /* Create an outer directory. */
             if (mkdir(path, folder_perms)) {
                 advise (dir, "unable to create directory");
             }
             /* Create an outer directory. */
             if (mkdir(path, folder_perms)) {
                 advise (dir, "unable to create directory");
-                had_an_error = 1;
+                had_an_error = true;
             }
         }
         *c = '/';
             }
         }
         *c = '/';
@@ -64,7 +64,7 @@ makedir (const char *dir)
            asked to create. */
         if (mkdir (dir, folder_perms) == -1) {
             advise (dir, "unable to create directory");
            asked to create. */
         if (mkdir (dir, folder_perms) == -1) {
             advise (dir, "unable to create directory");
-            had_an_error = 1;
+            had_an_error = true;
         }
     }
 
         }
     }
 
index cc6b1fbf58b85da7b14d3a97da3628cc547e6cc1..016947aa222ad6bb62d6d75e1c9e6db847a2bb44 100644 (file)
@@ -23,7 +23,6 @@ char *
 mime_type(const char *file_name) {
     char *content_type = NULL;  /* mime content type */
     char *p;
 mime_type(const char *file_name) {
     char *content_type = NULL;  /* mime content type */
     char *p;
-    static int loaded_defaults = 0;
 
 #ifdef MIMETYPEPROC
     char *mimetype;
 
 #ifdef MIMETYPEPROC
     char *mimetype;
@@ -55,9 +54,10 @@ mime_type(const char *file_name) {
        struct node *np;                /* Content scan node pointer */
        FILE *fp;                       /* File pointer for mhn.defaults */
 
        struct node *np;                /* Content scan node pointer */
        FILE *fp;                       /* File pointer for mhn.defaults */
 
+        static bool loaded_defaults;
        if (! loaded_defaults &&
                        (fp = fopen(p = etcpath("mhn.defaults"), "r"))) {
        if (! loaded_defaults &&
                        (fp = fopen(p = etcpath("mhn.defaults"), "r"))) {
-           loaded_defaults = 1;
+           loaded_defaults = true;
            readconfig(NULL, fp, p, 0);
            fclose(fp);
        }
            readconfig(NULL, fp, p, 0);
            fclose(fp);
        }
@@ -80,16 +80,17 @@ mime_type(const char *file_name) {
 
        if (content_type == NULL) {
            FILE *fp;
 
        if (content_type == NULL) {
            FILE *fp;
-           int binary = 0, c;
+            int c;
 
            if (!(fp = fopen(file_name, "r"))) {
                inform("unable to access file \"%s\"", file_name);
                return NULL;
            }
 
 
            if (!(fp = fopen(file_name, "r"))) {
                inform("unable to access file \"%s\"", file_name);
                return NULL;
            }
 
+           bool binary = false;
            while ((c = getc(fp)) != EOF) {
                if (! isascii(c)  ||  c == 0) {
            while ((c = getc(fp)) != EOF) {
                if (! isascii(c)  ||  c == 0) {
-                   binary = 1;
+                   binary = true;
                    break;
                }
            }
                    break;
                }
            }
index 513fb117e091792100a02baef0b1f1b04ffe0494..b6fa63704e2b559be674c7c7847ecb462abcb2d5 100644 (file)
@@ -64,7 +64,7 @@ static int token(char *);
 void
 ruserpass(const char *host, char **aname, char **apass, int flags)
 {
 void
 ruserpass(const char *host, char **aname, char **apass, int flags)
 {
-    int t, usedefault = 0;
+    int t;
     struct stat stb;
 
     init_credentials_file ();
     struct stat stb;
 
     init_credentials_file ();
@@ -77,10 +77,11 @@ ruserpass(const char *host, char **aname, char **apass, int flags)
         char tokval[MAX_TOKVAL_SIZE];
         tokval[0] = '\0';
 
         char tokval[MAX_TOKVAL_SIZE];
         tokval[0] = '\0';
 
+        bool usedefault = false;
        while ((t = token(tokval))) {
            switch(t) {
            case DEFAULT:
        while ((t = token(tokval))) {
            switch(t) {
            case DEFAULT:
-               usedefault = 1;
+               usedefault = true;
                /* FALLTHRU */
 
            case MACH:
                /* FALLTHRU */
 
            case MACH:
index eb51e92790b4712d523bb578a173f2652c84af02..2641ac4e9227794ed6ee4f1831c1071673465c49 100644 (file)
@@ -24,7 +24,7 @@ int
 seq_addsel (struct msgs *mp, char *cp, int public, int zero)
 {
     unsigned int i;
 seq_addsel (struct msgs *mp, char *cp, int public, int zero)
 {
     unsigned int i;
-    int msgnum, new_seq = 1;
+    int msgnum;
 
     if (!seq_nameok (cp))
        return 0;
 
     if (!seq_nameok (cp))
        return 0;
@@ -39,9 +39,10 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero)
     /*
      * Get the number for this sequence
      */
     /*
      * Get the number for this sequence
      */
+    bool new_seq = true;
     for (i = 0; i < svector_size (mp->msgattrs); i++) {
        if (!strcmp (svector_at (mp->msgattrs, i), cp)) {
     for (i = 0; i < svector_size (mp->msgattrs); i++) {
        if (!strcmp (svector_at (mp->msgattrs, i), cp)) {
-           new_seq = 0;
+           new_seq = false;
            break;
        }
     }
            break;
        }
     }
@@ -112,7 +113,7 @@ int
 seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero)
 {
     unsigned int i;
 seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero)
 {
     unsigned int i;
-    int j, new_seq = 1;
+    int j;
 
     if (!seq_nameok (cp))
        return 0;
 
     if (!seq_nameok (cp))
        return 0;
@@ -126,9 +127,10 @@ seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero)
     /*
      * Get the number for this sequence
      */
     /*
      * Get the number for this sequence
      */
+    bool new_seq = true;
     for (i = 0; i < svector_size (mp->msgattrs); i++) {
        if (!strcmp (svector_at (mp->msgattrs, i), cp)) {
     for (i = 0; i < svector_size (mp->msgattrs); i++) {
        if (!strcmp (svector_at (mp->msgattrs, i), cp)) {
-           new_seq = 0;
+           new_seq = false;
            break;
        }
     }
            break;
        }
     }
index 59e4050d3f9a5b20e909d30244734da41e7e0f56..0133592367dd95f2ca62ad543f10a7307fe462c1 100644 (file)
@@ -24,7 +24,7 @@ int
 seq_delsel (struct msgs *mp, char *cp, int public, int zero)
 {
     unsigned int i;
 seq_delsel (struct msgs *mp, char *cp, int public, int zero)
 {
     unsigned int i;
-    int msgnum, new_seq = 1;
+    int msgnum;
 
     if (!seq_nameok (cp))
        return 0;
 
     if (!seq_nameok (cp))
        return 0;
@@ -32,9 +32,10 @@ seq_delsel (struct msgs *mp, char *cp, int public, int zero)
     /*
      * Get the number for this sequence
      */
     /*
      * Get the number for this sequence
      */
+    bool new_seq = true;
     for (i = 0; i < svector_size (mp->msgattrs); i++) {
        if (!strcmp (svector_at (mp->msgattrs, i), cp)) {
     for (i = 0; i < svector_size (mp->msgattrs); i++) {
        if (!strcmp (svector_at (mp->msgattrs, i), cp)) {
-           new_seq = 0;
+           new_seq = false;
            break;
        }
     }
            break;
        }
     }
index 9dfda7b67654c50b7bec4d28d299b59e1bfa83aa..98b22df4f1d62e405c77cbda07d5f536015d089d 100644 (file)
@@ -12,7 +12,7 @@ int
 showfile (char **arg, char *file)
 {
     pid_t pid;
 showfile (char **arg, char *file)
 {
     pid_t pid;
-    int isdraft, vecp;
+    int vecp;
     char **vec, *program;
     int retval = 1;
 
     char **vec, *program;
     int retval = 1;
 
@@ -36,11 +36,11 @@ showfile (char **arg, char *file)
     case 0:
        /* child */
        vec = argsplit(lproc, &program, &vecp);
     case 0:
        /* child */
        vec = argsplit(lproc, &program, &vecp);
-       isdraft = 1;
+       bool isdraft = true;
        if (arg) {
            while (*arg) {
                if (**arg != '-')
        if (arg) {
            while (*arg) {
                if (**arg != '-')
-                   isdraft = 0;
+                   isdraft = false;
                vec[vecp++] = *arg++;
            }
        }
                vec[vecp++] = *arg++;
            }
        }
index efb0cde3c9b6dd185c05b2648f655b7318d18f53..2d0acb3947eaeda9623cd15a7a83c414a194ae85 100644 (file)
@@ -435,20 +435,20 @@ int nmh_init(const char *argv0, bool read_context, bool check_version)
 
     /* Read context, if supposed to. */
     if (read_context) {
 
     /* Read context, if supposed to. */
     if (read_context) {
-        int allow_version_check = 1;
-        int check_older_version = 0;
         char *cp;
 
         context_read();
 
         char *cp;
 
         context_read();
 
+        bool allow_version_check = true;
+        bool check_older_version = false;
         if (!check_version ||
             ((cp = context_find ("Welcome")) && strcasecmp (cp, "disable") == 0)) {
         if (!check_version ||
             ((cp = context_find ("Welcome")) && strcasecmp (cp, "disable") == 0)) {
-            allow_version_check = 0;
+            allow_version_check = false;
         } else if ((cp = getenv ("MHCONTEXT")) != NULL && *cp != '\0') {
             /* Context file comes from $MHCONTEXT, so only print the message
                if the context file has an older version.  If it does, or if it
                doesn't have a version at all, update the version. */
         } else if ((cp = getenv ("MHCONTEXT")) != NULL && *cp != '\0') {
             /* Context file comes from $MHCONTEXT, so only print the message
                if the context file has an older version.  If it does, or if it
                doesn't have a version at all, update the version. */
-            check_older_version = 1;
+            check_older_version = true;
         }
 
         /* Check to see if the user is running a different (or older, if
         }
 
         /* Check to see if the user is running a different (or older, if