]> diplodocus.org Git - nmh/blobdiff - uip/repl.c
Revised expected output with -prefer in test/mhlist/test-mhlist.
[nmh] / uip / repl.c
index ebe72ff2bbd1cb2d3f8e8c1b4d4a05c7ff55d03a..2707b3682e4022dcb5816b56065e78aa27880c7a 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * repl.c -- reply to a message
+/* repl.c -- reply to a message
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +8,7 @@
 #include <h/mh.h>
 #include <h/mime.h>
 #include <h/utils.h>
 #include <h/mh.h>
 #include <h/mime.h>
 #include <h/utils.h>
+#include "../sbr/m_maildir.h"
 
 #define REPL_SWITCHES \
     X("group", 0, GROUPSW) \
 
 #define REPL_SWITCHES \
     X("group", 0, GROUPSW) \
@@ -40,7 +39,7 @@
     X("width columns", 0, WIDTHSW) \
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
     X("width columns", 0, WIDTHSW) \
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
-    X("file file", 4, FILESW) /* interface from msh */ \
+    X("file file", 4, FILESW) \
     X("build", 5, BILDSW) /* interface from mhe */ \
     X("atfile", 0, ATFILESW) \
     X("noatfile", 0, NOATFILESW) \
     X("build", 5, BILDSW) /* interface from mhe */ \
     X("atfile", 0, ATFILESW) \
     X("noatfile", 0, NOATFILESW) \
@@ -225,7 +224,8 @@ main (int argc, char **argv)
                    nwhat = 0;
                    continue;
                case BILDSW: 
                    nwhat = 0;
                    continue;
                case BILDSW: 
-                   buildsw++;  /* fall... */
+                   buildsw++;
+                   /* FALLTHRU */
                case NWHATSW: 
                    nwhat++;
                    continue;
                case NWHATSW: 
                    nwhat++;
                    continue;
@@ -239,8 +239,7 @@ main (int argc, char **argv)
                    if (fcc)
                        fcc = add (", ", fcc);
                    fcc = add (cp, fcc);
                    if (fcc)
                        fcc = add (", ", fcc);
                    fcc = add (cp, fcc);
-                   if (dp)
-                       free (dp);
+                    mh_xfree(dp);
                    continue;
 
                case FILESW: 
                    continue;
 
                case FILESW: 
@@ -337,13 +336,11 @@ main (int argc, char **argv)
        if (*cp == '+' || *cp == '@') {
            if (folder)
                adios (NULL, "only one folder at a time!");
        if (*cp == '+' || *cp == '@') {
            if (folder)
                adios (NULL, "only one folder at a time!");
-           else
-               folder = pluspath (cp);
+            folder = pluspath (cp);
        } else {
            if (msg)
                adios (NULL, "only one message at a time!");
        } else {
            if (msg)
                adios (NULL, "only one message at a time!");
-           else
-               msg = cp;
+            msg = cp;
        }
     }
 
        }
     }
 
@@ -354,7 +351,7 @@ main (int argc, char **argv)
     if (ccme == -1)
        ccme = groupreply;
 
     if (ccme == -1)
        ccme = groupreply;
 
-    cwd = getcpy (pwd ());
+    cwd = mh_xstrdup(pwd ());
 
     if (!context_find ("path"))
        free (path ("./", TFOLDER));
 
     if (!context_find ("path"))
        free (path ("./", TFOLDER));
@@ -370,7 +367,8 @@ try_it_again:
     if (!buildsw && stat (drft, &st) != NOTOK) {
        printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
        for (i = LISTDSW; i != YESW;) {
     if (!buildsw && stat (drft, &st) != NOTOK) {
        printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
        for (i = LISTDSW; i != YESW;) {
-           if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
+           if (!(argp = read_switch_multiword ("\nDisposition? ",
+                                               isdf ? aqrnl : aqrl)))
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
@@ -388,7 +386,7 @@ try_it_again:
                        i = YESW;
                    break;
                default: 
                        i = YESW;
                    break;
                default: 
-                   advise (NULL, "say what?");
+                   inform("say what?");
                    break;
            }
        }
                    break;
            }
        }
@@ -434,7 +432,7 @@ try_it_again:
        context_save ();                        /* save the context file   */
     }
 
        context_save ();                        /* save the context file   */
     }
 
-    msg = file ? file : getcpy (m_name (mp->lowsel));
+    msg = file ? file : mh_xstrdup(m_name (mp->lowsel));
 
     if ((in = fopen (msg, "r")) == NULL)
        adios (msg, "unable to open");
 
     if ((in = fopen (msg, "r")) == NULL)
        adios (msg, "unable to open");
@@ -452,14 +450,16 @@ try_it_again:
     fclose (in);
 
     {
     fclose (in);
 
     {
-       char *filename = concat (mp->foldpath, "/", msg, NULL);
+        char *filename = file ? file : concat (mp->foldpath, "/", msg, NULL);
 
         for (n = 0; n < svector_size (convert_types); ++n) {
             add_convert_header (svector_at (convert_types, n),
                                 svector_at (convert_args, n),
                                 filename, drft);
         }
 
         for (n = 0; n < svector_size (convert_types); ++n) {
             add_convert_header (svector_at (convert_types, n),
                                 svector_at (convert_args, n),
                                 filename, drft);
         }
-       free (filename);
+        if (! file) {
+            free (filename);
+        }
     }
 
     if (nwhat)
     }
 
     if (nwhat)