From 358131df8b64ef0c6020dbe9ec61e11cecdef356 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Fri, 20 Apr 2012 14:43:16 -0400 Subject: [PATCH] Implment -noatfile in a different way; it turns out my previous change broke dist with -noatfile. --- h/prototypes.h | 2 +- uip/comp.c | 2 +- uip/dist.c | 4 ++-- uip/forw.c | 2 +- uip/repl.c | 4 ++-- uip/whatnowproc.c | 4 +++- uip/whatnowsbr.c | 23 ++++++++++++++--------- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/h/prototypes.h b/h/prototypes.h index e74f327..5304548 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -163,6 +163,6 @@ int build_form (char *, char *, int *, char *, char *, char *, char *, int sendsbr (char **, int, char *, struct stat *, int, char *, int); int SOprintf (char *, ...); int what_now (char *, int, int, char *, char *, - int, struct msgs *, char *, int, char *); + int, struct msgs *, char *, int, char *, int); int WhatNow(int, char **); int writeBase64aux(FILE *, FILE *); diff --git a/uip/comp.c b/uip/comp.c index 569847c..7c72c7c 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -406,7 +406,7 @@ edit_it: if (nwhat) done (0); - what_now (ed, nedit, use, drft, NULL, 0, NULLMP, NULL, 0, cwd); + what_now (ed, nedit, use, drft, NULL, 0, NULLMP, NULL, 0, cwd, 0); done (1); return 1; } diff --git a/uip/dist.c b/uip/dist.c index 169eacd..39fb07b 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -344,8 +344,8 @@ try_it_again: if (nwhat) done (0); - what_now (ed, nedit, NOUSE, drft, atfile ? msgnam : NULL, 1, mp, - anot ? "Resent" : NULL, inplace, cwd); + what_now (ed, nedit, NOUSE, drft, msgnam, 1, mp, anot ? "Resent" : NULL, + inplace, cwd, atfile); done (1); return 1; } diff --git a/uip/forw.c b/uip/forw.c index 2741f69..cd51fd1 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -499,7 +499,7 @@ try_it_again: if (nwhat) done (0); what_now (ed, nedit, NOUSE, drft, NULL, 0, mp, - anot ? "Forwarded" : NULL, inplace, cwd); + anot ? "Forwarded" : NULL, inplace, cwd, 0); done (1); return 1; } diff --git a/uip/repl.c b/uip/repl.c index f88d0c3..07f25a8 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -451,8 +451,8 @@ try_it_again: if (nwhat) done (0); - what_now (ed, nedit, NOUSE, drft, atfile ? msg : NULL, 0, mp, - anot ? "Replied" : NULL, inplace, cwd); + what_now (ed, nedit, NOUSE, drft, msg, 0, mp, anot ? "Replied" : NULL, + inplace, cwd, atfile); done (1); return 1; } diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index 293d5ce..fc8783d 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -22,7 +22,7 @@ int what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, - struct msgs *mp, char *text, int inplace, char *cwd) + struct msgs *mp, char *text, int inplace, char *cwd, int atfile) { int found, k, msgnum, vecp; int len, buflen; @@ -60,6 +60,8 @@ what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, } snprintf (buffer, sizeof(buffer), "%d", use); m_putenv ("mhuse", buffer); + snprintf (buffer, sizeof(buffer), "%d", atfile); + m_putenv ("mhatfile", buffer); unputenv ("mhmessages"); unputenv ("mhannotate"); diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 6830bfb..ddfc998 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -113,7 +113,7 @@ static char *myprompt = "\nWhat now? "; * static prototypes */ static int editfile (char **, char **, char *, int, struct msgs *, - char *, char *, int); + char *, char *, int, int); static int sendfile (char **, char *, int); static void sendit (char *, char **, char *, int); static int buildfile (char **, char *); @@ -134,7 +134,7 @@ static int copyf (char *, char *); int WhatNow (int argc, char **argv) { - int isdf = 0, nedit = 0, use = 0; + int isdf = 0, nedit = 0, use = 0, atfile = 1; char *cp, *dfolder = NULL, *dmsg = NULL; char *ed = NULL, *drft = NULL, *msgnam = NULL; char buf[BUFSIZ], prompt[BUFSIZ]; @@ -235,6 +235,9 @@ WhatNow (int argc, char **argv) msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL; + if ((cp = getenv ("mhatfile")) && *cp) + atfile = atoi(cp); + if ((cp = getenv ("mhuse")) && *cp) use = atoi (cp); @@ -244,7 +247,8 @@ WhatNow (int argc, char **argv) } /* start editing the draft, unless -noedit was given */ - if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, NULL, 1) < 0) + if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, + NULL, 1, atfile) < 0) done (1); snprintf (prompt, sizeof(prompt), myprompt, invo_name); @@ -275,7 +279,8 @@ WhatNow (int argc, char **argv) /* Call an editor on the draft file */ if (*++argp) ed = *argp++; - if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, NULL, 1) == NOTOK) + if (editfile (&ed, argp, drft, NOUSE, NULL, msgnam, + NULL, 1, atfile) == NOTOK) done (1); break; @@ -637,7 +642,7 @@ static char *edsave = NULL; /* the editor we used previously */ static int editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, - char *altmsg, char *cwd, int save_editor) + char *altmsg, char *cwd, int save_editor, int atfile) { int pid, status, vecp; char altpath[BUFSIZ], linkpath[BUFSIZ]; @@ -666,7 +671,7 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, *ed = defaulteditor; } - if (altmsg) { + if (altmsg && atfile) { if (mp == NULL || *altmsg == '/' || cwd == NULL) strncpy (altpath, altmsg, sizeof(altpath)); else @@ -766,7 +771,7 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp, edsave = getcpy (*ed); *ed = NULL; - if (altmsg) + if (altmsg && atfile) unlink (linkpath); return status; @@ -825,7 +830,7 @@ sendfile (char **arg, char *file, int pushsw) if ((cp = context_find ("automhnproc")) && !getenv ("NOMHNPROC") && check_draft (file) - && (i = editfile (&cp, NULL, file, NOUSE, NULL, NULL, NULL, 0))) + && (i = editfile (&cp, NULL, file, NOUSE, NULL, NULL, NULL, 0, 0))) return 0; /* @@ -904,7 +909,7 @@ buildfile (char **argp, char *file) args[i++] = *argp++; args[i] = NULL; - i = editfile (&ed, args, file, NOUSE, NULL, NULL, NULL, 0); + i = editfile (&ed, args, file, NOUSE, NULL, NULL, NULL, 0, 0); free (args); return (i ? NOTOK : OK); -- 1.7.10.4