Fixed make_bcc_file () to use contents of From: in draft, if draft_from masquerade...
[mmh] / uip / mhlsbr.c
index 18617d3..31c24bb 100644 (file)
@@ -3,13 +3,18 @@
  * mhlsbr.c -- main routines for nmh message lister
  *
  * $Id$
+ *
+ * This code is Copyright (c) 2002, by the authors of nmh.  See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
  */
 
 #include <h/mh.h>
 #include <h/signals.h>
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
-#include <zotnet/tws/tws.h>
+#include <h/tws.h>
+#include <h/utils.h>
 #include <setjmp.h>
 #include <signal.h>
 
@@ -72,7 +77,7 @@ static struct swit mhlswitches[] = {
 #define VERSIONSW     15
     { "version", 0 },
 #define        HELPSW        16
-    { "help", 4 },
+    { "help", 0 },
 #define        FORW1SW       17
     { "forward", -7 },         /* interface from forw */
 #define        FORW2SW       18
@@ -434,6 +439,7 @@ mhl (int argc, char **argv)
                SIGNAL (SIGINT, SIG_IGN);
                SIGNAL2 (SIGQUIT, quitser);
            }
+           SIGNAL2 (SIGPIPE, pipeser);
            m_popen (moreproc);
            ontty = PITTY;
        } else {
@@ -475,6 +481,11 @@ mhl (int argc, char **argv)
                    vecp > 1 ? "s" : "");
     }
 
+    fflush(stdout);
+    if(ferror(stdout)){
+           adios("output", "error writing");
+    }
+    
     if (clearflg > 0 && ontty == NOTTY)
        clear_screen ();
 
@@ -498,7 +509,7 @@ mhl_format (char *file, int length, int width)
     static ino_t ino = 0;
     static time_t mtime = 0;
 
-    if (fmthd != NULL)
+    if (fmthd != NULL) {
        if (stat (etcpath (file), &st) != NOTOK
                && mtime == st.st_mtime
                && dev == st.st_dev
@@ -506,6 +517,7 @@ mhl_format (char *file, int length, int width)
            goto out;
        else
            free_queue (&fmthd, &fmttl);
+    }
 
     if ((fp = fopen (etcpath (file), "r")) == NULL)
        adios (file, "unable to open format file");
@@ -584,7 +596,7 @@ mhl_format (char *file, int length, int width)
                    if (evalvar (c1))
                        adios (NULL, "format file syntax error: %s", bp);
                }
-               if (!c1->c_nfs && global.c_nfs)
+               if (!c1->c_nfs && global.c_nfs) {
                    if (c1->c_flags & DATEFMT) {
                        if (global.c_flags & DATEFMT)
                            c1->c_nfs = getcpy (global.c_nfs);
@@ -594,6 +606,7 @@ mhl_format (char *file, int length, int width)
                            if (global.c_flags & ADDRFMT)
                                c1->c_nfs = getcpy (global.c_nfs);
                        }
+               }
                continue;
 
            default: 
@@ -943,8 +956,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec)
                        continue;
                    }
                    if (dobody && !strcasecmp (c1->c_name, "body")) {
-                       if ((holder.c_text = malloc (sizeof(buf))) == NULL)
-                           adios (NULL, "unable to allocate buffer memory");
+                       holder.c_text = mh_xmalloc (sizeof(buf));
                        strncpy (holder.c_text, buf, sizeof(buf));
                        while (state == BODY) {
                            putcomp (c1, &holder, BODYCOMP);
@@ -1262,13 +1274,14 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
                *cp = toupper (*cp);
 
     count = 0;
-    if (cchdr)
+    if (cchdr) {
        if (flag == TWOCOMP)
            count = (c1->c_cwidth >= 0) ? c1->c_cwidth
                        : strlen (c2->c_name) + 2;
        else
            count = (c1->c_cwidth >= 0) ? c1->c_cwidth
                        : strlen (c1->c_text ? c1->c_text : c1->c_name) + 2;
+    }
     count += c1->c_offset;
 
     if ((cp = oneline (c2->c_text, c1->c_flags)))
@@ -1343,7 +1356,7 @@ oneline (char *stuff, long flags)
 static void
 putstr (char *string)
 {
-    if (!column && lm > 0)
+    if (!column && lm > 0) {
        while (lm > 0)
            if (lm >= 8) {
                putch ('\t');
@@ -1353,6 +1366,7 @@ putstr (char *string)
                putch (' ');
                lm--;
            }
+    }
     lm = 0;
     while (*string)
        putch (*string++);
@@ -1630,14 +1644,12 @@ doface (struct mcomp *c1)
                if (cp) {
                    int j;
                    char *dp;
-                   if ((dp = realloc (cp, (unsigned) (j = len + i))) == NULL)
-                       adios (NULL, "unable to allocate face storage");
+                   dp = mh_xrealloc (cp, (unsigned) (j = len + i));
                    memcpy(dp + len, buffer, i);
                    cp = dp, len = j;
                }
                else {
-                   if ((cp = malloc ((unsigned) i)) == NULL)
-                       adios (NULL, "unable to allocate face storage");
+                   cp = mh_xmalloc ((unsigned) i);
                    memcpy(cp, buffer, i);
                    len = i;
                }