]> diplodocus.org Git - nmh/blobdiff - uip/show.c
lock_file.c: close(2) file descriptor on failure, avoiding leak.
[nmh] / uip / show.c
index 9aa84b3981d26b93db957907029ffe4933b627be..86e8e5b5ae8946a266a774b4e75e9752dca2e6b3 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * show.c -- show/list messages
+/* show.c -- show/list messages
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -9,6 +8,7 @@
 #include <h/mh.h>
 #include <h/mime.h>
 #include <h/utils.h>
+#include "sbr/m_maildir.h"
 
 #define SHOW_SWITCHES \
     X("checkmime", 0, CHECKMIMESW) \
@@ -96,6 +96,7 @@ main (int argc, char **argv)
                    goto non_mhl_switches;
                case NHEADSW:
                    headersw = 0;
+                   /* FALLTHRU */
                case CONCATSW:
                case NCONCATSW:
 non_mhl_switches:
@@ -187,8 +188,7 @@ usage:
        if (*cp == '+' || *cp == '@') {
            if (folder)
                adios (NULL, "only one folder at a time!");
-           else
-               folder = pluspath (cp);
+            folder = pluspath (cp);
        } else {
            if (mode != SHOW)
                goto usage;
@@ -297,7 +297,7 @@ go_to_it: ;
     }
 
     if (folder && !draftsw && !file)
-       m_putenv ("mhfolder", folder);
+       setenv("mhfolder", folder, 1);
 
     if (strcmp (r1bindex (proc, '/'), "cat") == 0) {
 
@@ -367,16 +367,16 @@ is_nontext (char *msgnam)
 {
     int        result, state;
     char *bp, *dp, *cp;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[NMH_BUFSIZ], name[NAMESZ];
     FILE *fp;
-    m_getfld_state_t gstate = 0;
+    m_getfld_state_t gstate;
 
     if ((fp = fopen (msgnam, "r")) == NULL)
        return 0;
-
+    gstate = m_getfld_state_init(fp);
     for (;;) {
        int bufsz = sizeof buf;
-       switch (state = m_getfld (&gstate, name, buf, &bufsz, fp)) {
+       switch (state = m_getfld2(&gstate, name, buf, &bufsz)) {
        case FLD:
        case FLDPLUS:
            /*
@@ -389,7 +389,7 @@ is_nontext (char *msgnam)
                cp = mh_xstrdup(buf);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
-                   state = m_getfld (&gstate, name, buf, &bufsz, fp);
+                   state = m_getfld2(&gstate, name, buf, &bufsz);
                    cp = add (buf, cp);
                }
                bp = cp;
@@ -413,7 +413,7 @@ invalid:
                            continue;
                        case '(':
                            i++;
-                           /* and fall... */
+                           continue;
                        default:
                            continue;
                        case ')':
@@ -494,7 +494,7 @@ out:
                cp = mh_xstrdup(buf);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
-                   state = m_getfld (&gstate, name, buf, &bufsz, fp);
+                   state = m_getfld2(&gstate, name, buf, &bufsz);
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace ((unsigned char) *bp); bp++)
@@ -521,7 +521,7 @@ out:
             */
            while (state == FLDPLUS) {
                bufsz = sizeof buf;
-               state = m_getfld (&gstate, name, buf, &bufsz, fp);
+               state = m_getfld2(&gstate, name, buf, &bufsz);
            }
            break;