Fix uip/whom.c for C89 compatibility
[mmh] / uip / whatnow.c
index 7e54929..be046ac 100644 (file)
@@ -32,6 +32,8 @@ static struct swit switches[] = {
        { NULL, 0 }
 };
 
+char *version=VERSION;
+
 /*
 ** Options at the "whatnow" prompt
 */
@@ -72,7 +74,7 @@ static char *myprompt = "\nWhat now? ";
 /*
 ** static prototypes
 */
-static int editfile(char **, char **, char *, int);
+static int editfile(char **, char **, char *);
 static int sendfile(char **, char *);
 static int refile(char **, char *);
 static int removefile(char *);
@@ -85,7 +87,7 @@ static int system_in_dir(const char *, const char *);
 int
 main(int argc, char **argv)
 {
-       int use = 0;
+       int use = NOUSE;
        char *cp;
        char *ed = NULL, *drft = NULL;
        char buf[BUFSIZ], prompt[BUFSIZ];
@@ -153,7 +155,7 @@ main(int argc, char **argv)
        }
 
        if ((!drft && !(drft = getenv("mhdraft"))) || !*drft)
-               drft = getcpy(m_draft(seq_cur));
+               drft = mh_xstrdup(m_draft(seq_cur));
 
        if ((cp = getenv("mhuse")) && *cp)
                use = atoi(cp);
@@ -164,7 +166,7 @@ main(int argc, char **argv)
 
        /* start editing the draft, unless editor is the empty string */
        if (*ed) {
-               if (editfile(&ed, NULL, drft, use) <0) {
+               if (editfile(&ed, NULL, drft) <0) {
                        if (!use) {
                                unlink(drft);
                        }
@@ -173,10 +175,7 @@ main(int argc, char **argv)
        }
 
        snprintf(prompt, sizeof(prompt), myprompt, invo_name);
-       for (;;) {
-               if (!(argp = getans(prompt, aleqs))) {
-                       exit(EX_IOERR);
-               }
+       while ((argp = getans(prompt, aleqs))) {
                switch (smatch(*argp, aleqs)) {
                case DISPSW:
                        /* display the msg being replied to or distributed */
@@ -192,7 +191,7 @@ main(int argc, char **argv)
                        /* Call an editor on the draft file */
                        if (*++argp)
                                ed = *argp++;
-                       editfile(&ed, argp, drft, NOUSE);
+                       editfile(&ed, argp, drft);
                        break;
 
                case LISTSW:
@@ -381,7 +380,8 @@ main(int argc, char **argv)
                        break;
                }
        }
-       /*NOTREACHED*/
+
+       exit(EX_IOERR);
 }
 
 
@@ -489,7 +489,7 @@ static char *edsave = NULL;  /* the editor we used previously */
 
 
 static int
-editfile(char **ed, char **arg, char *file, int use)
+editfile(char **ed, char **arg, char *file)
 {
        int pid, status, vecp;
        char *cp, *vec[MAXARGS];
@@ -557,7 +557,7 @@ editfile(char **ed, char **arg, char *file, int use)
        }
 
        /* remember which editor we used */
-       edsave = getcpy(*ed);
+       edsave = mh_xstrdup(*ed);
 
        *ed = NULL;