From 30292c537fe4eab052f303f1d3179c0e2fd037d8 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Tue, 1 May 2012 17:16:34 +0200 Subject: [PATCH] Removed the altmsglink (named `@') and env var `$editalt' for repl and dist. The env var $mhaltmsg already provides everything. We just get rid of compat redundancy. We also dropped the lstat() check. lstat() is POSIX and we assume any modern Unix system to support symbolic links. Also, there's only one invocation of lstat() left in uip/flist.c. --- config/config.c | 6 --- configure.ac | 2 +- h/mh.h | 1 - man/dist.man1 | 9 ++-- man/mh-profile.man5 | 31 ++++---------- man/repl.man1 | 11 ++--- sbr/folder_read.c | 4 -- sbr/readconfig.c | 1 - uip/mhparam.c | 1 - uip/rmf.c | 4 +- uip/whatnow.c | 115 ++++----------------------------------------------- uip/whatnowproc.c | 2 - 12 files changed, 23 insertions(+), 164 deletions(-) diff --git a/config/config.c b/config/config.c index d6677d2..cfd5fe5 100644 --- a/config/config.c +++ b/config/config.c @@ -158,12 +158,6 @@ char *mailspool = MAILSPOOL; char *backup_prefix = ","; /* -** Name of link to file to which you are replying or which you are -** redistributing. See `$mhaltmsg' in the mh-profile(5) man page. -*/ -char *altmsglink = "@"; - -/* ** Folders (directories) are created with this protection (mode) */ char *foldprot = "0700"; diff --git a/configure.ac b/configure.ac index 3df3d8b..f757b3f 100644 --- a/configure.ac +++ b/configure.ac @@ -348,7 +348,7 @@ AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1, dnl --------------- dnl CHECK FUNCTIONS dnl --------------- -AC_CHECK_FUNCS(lstat nl_langinfo mbtowc wcwidth) +AC_CHECK_FUNCS(nl_langinfo mbtowc wcwidth) dnl Look for the initgroups() declaration. On AIX 4.[13], Solaris 4.1.3, and dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in diff --git a/h/mh.h b/h/mh.h index 9eed2d0..37678db 100644 --- a/h/mh.h +++ b/h/mh.h @@ -274,7 +274,6 @@ extern char *mailstore; /* name of mail storage directory */ */ extern char *attach_hdr; extern char *backup_prefix; -extern char *altmsglink; extern char *components; extern char *context; extern char *curfolder; diff --git a/man/dist.man1 b/man/dist.man1 index 87b8676..8e27f66 100644 --- a/man/dist.man1 +++ b/man/dist.man1 @@ -83,12 +83,9 @@ See .BR comp (1) for a description of the .B \-editor -switch. Note that while in the editor, the message being resent -is available through a link named `@' (assuming the default -.IR whatnowproc ). -In addition, the actual pathname of the message is -stored in the environment variable -.BR $editalt , +switch. Note that while in the editor, the actual pathname of the +message being resent is stored in the environment variable +.BR $mhaltmsg , and the pathname of the folder containing the message is stored in the environment variable .BR $mhfolder . diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index 19250b3..095a0f3 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -185,14 +185,6 @@ It should typically be set to `,' or `#'. (profile, default: `,') .RE .PP -.BR AltMsg-Link : -@ -.RS 5 -Name of the link to the file to which you are replying or which you are -redistributing. See `$mhaltmsg' below. -(profile, default: `@') -.RE -.PP .BR Attachment-Header : Attach .RS 5 @@ -597,22 +589,6 @@ how many lines long your terminal screen is. .RE .PP -.B $editalt -.RS 5 -This is the alternate message. -.PP -This is set by -.B dist -and -.B repl -during edit sessions so you can peruse the message being distributed or -replied to. The message is also available through a link called -`@' (if not changed by -.BR altmsg-link ) -in the current directory if your current working directory -and the message's folder are on the same UNIX filesystem. -.RE -.PP .B $mhdraft .RS 5 This is the path to the working draft. @@ -640,6 +616,13 @@ to tell the .I whatnowproc about an alternate message associated with the draft (the message being distributed or replied to). +It is also set during edit sessions so you can peruse the +message being distributed or replied to. +This variable replaces the older +.B $editalt +variable. +There used to be a link named `@' in the working directory, pointing +to the alternate message, there is no such link anymore. .RE .PP .B $mhdist diff --git a/man/repl.man1 b/man/repl.man1 index 18e02a2..26fd094 100644 --- a/man/repl.man1 +++ b/man/repl.man1 @@ -177,12 +177,10 @@ See .BR comp (1) for a description of the .B \-editor -switch. Note that while in the editor, the message being replied -to is available through a link named `@' (assuming the default -.IR whatnowproc ). -In addition, the actual pathname of the message is +switch. Note that while in the editor, +the actual pathname of the message being replied to is stored in the environment variable -.BR $editalt , +.BR $mhaltmsg , and the pathname of the folder containing the message is stored in the environment variable .BR $mhfolder . @@ -404,7 +402,4 @@ uses the sender's host. Moral of the story: if you're going to include addresses in a reply template, include the host portion of the address. .PP -If your current working directory is not writable, the link named -`@' is not available. -.PP The quotation of the original message does not get transfer-decoded, yet. diff --git a/sbr/folder_read.c b/sbr/folder_read.c index 53ee8a4..35dc195 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -113,10 +113,6 @@ folder_read(char *name) prefix_len)==0) continue; - /* skip the altmsg link file */ - if (strcmp(dp->d_name, altmsglink)==0) - continue; - /* ** indicate that there are other ** files in folder diff --git a/sbr/readconfig.c b/sbr/readconfig.c index c238a26..fe7b486 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -21,7 +21,6 @@ static struct procstr procs[] = { { "mh-sequences", &mh_seq }, { "backup-prefix", &backup_prefix }, { "draft-folder", &draftfolder }, - { "altmsg-link", &altmsglink }, { "listproc", &listproc }, { "sendmail", &sendmail }, { "trash-folder", &trashfolder }, diff --git a/uip/mhparam.c b/uip/mhparam.c index 6c6fedb..fe98461 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -47,7 +47,6 @@ static struct proc procs [] = { { "whatnowproc", &whatnowproc }, { "etcdir", &mhetcdir }, { "backup-prefix", &backup_prefix }, - { "altmsg-link", &altmsglink }, { "draft-folder", &draftfolder }, { "trash-folder", &trashfolder }, { NULL, NULL }, diff --git a/uip/rmf.c b/uip/rmf.c index b9c1969..096a9bf 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -175,9 +175,7 @@ rmf(char *folder) default: if (m_atoi(dp->d_name)) break; - if (strcmp(dp->d_name, altmsglink) == 0 || - strncmp(dp->d_name, - backup_prefix, j) == 0) + if (strncmp(dp->d_name, backup_prefix, j) == 0) break; admonish(NULL, "file \"%s/%s\" not deleted", diff --git a/uip/whatnow.c b/uip/whatnow.c index 7217096..e3a411a 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -92,8 +92,7 @@ static char *myprompt = "\nWhat now? "; /* ** static prototypes */ -static int editfile(char **, char **, char *, int, struct msgs *, - char *, char *); +static int editfile(char **, char **, char *, int); static int sendfile(char **, char *); static int refile(char **, char *); static int removefile(char *); @@ -103,17 +102,12 @@ static FILE* popen_in_dir(const char *dir, const char *cmd, const char *type); static int system_in_dir(const char *dir, const char *cmd); -#ifdef HAVE_LSTAT -static int copyf(char *, char *); -#endif - - int main(int argc, char **argv) { int use = 0; char *cp; - char *ed = NULL, *drft = NULL, *msgnam = NULL; + char *ed = NULL, *drft = NULL; char buf[BUFSIZ], prompt[BUFSIZ]; char **argp, **arguments; struct stat st; @@ -185,8 +179,6 @@ main(int argc, char **argv) if ((!drft && !(drft = getenv("mhdraft"))) || !*drft) drft = getcpy(m_draft(seq_cur)); - msgnam = (cp = getenv("mhaltmsg")) && *cp ? getcpy(cp) : NULL; - if ((cp = getenv("mhuse")) && *cp) use = atoi(cp); @@ -196,7 +188,7 @@ main(int argc, char **argv) /* start editing the draft, unless editor is the empty string */ if (*ed) { - if (editfile(&ed, NULL, drft, use, NULL, msgnam, NULL) <0) { + if (editfile(&ed, NULL, drft, use) <0) { if (!use) { unlink(drft); } @@ -208,15 +200,14 @@ main(int argc, char **argv) snprintf(prompt, sizeof(prompt), myprompt, invo_name); for (;;) { if (!(argp = getans(prompt, aleqs))) { - unlink(altmsglink); done(1); } switch (smatch(*argp, aleqs)) { case DISPSW: /* display the msg being replied to or distributed */ - if (msgnam) { + if ((cp = getenv("mhaltmsg")) && *cp) { snprintf(buf, sizeof buf, "%s '%s'", - listproc, msgnam); + listproc, cp); system(buf); } else { advise(NULL, "no alternate message to display"); @@ -227,7 +218,7 @@ main(int argc, char **argv) /* Call an editor on the draft file */ if (*++argp) ed = *argp++; - editfile(&ed, argp, drft, NOUSE, NULL, msgnam, NULL); + editfile(&ed, argp, drft, NOUSE); break; case LISTSW: @@ -575,17 +566,10 @@ 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) +editfile(char **ed, char **arg, char *file, int use) { int pid, status, vecp; - char altpath[BUFSIZ], linkpath[BUFSIZ]; char *cp, *vec[MAXARGS]; - struct stat st; - -#ifdef HAVE_LSTAT - int slinked = 0; -#endif /* HAVE_LSTAT */ if (!*ed || !**ed) { /* We have no explicit editor. */ @@ -605,31 +589,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, } } - if (altmsg) { - if (!mp || *altmsg == '/' || !cwd) - strncpy(altpath, altmsg, sizeof(altpath)); - else - snprintf(altpath, sizeof(altpath), "%s/%s", - mp->foldpath, altmsg); - if (!cwd) - strncpy(linkpath, altmsglink, sizeof(linkpath)); - else - snprintf(linkpath, sizeof(linkpath), "%s/%s", - cwd, altmsglink); - unlink(linkpath); -#ifdef HAVE_LSTAT - if (link(altpath, linkpath) == NOTOK) { - symlink(altpath, linkpath); - slinked = 1; - } else { - slinked = 0; - } -#else /* not HAVE_LSTAT */ - link(altpath, linkpath); -#endif /* not HAVE_LSTAT */ - } - - context_save(); /* save the context file */ + context_save(); fflush(stdout); switch (pid = fork()) { @@ -639,14 +599,6 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, break; case OK: - if (cwd) - chdir(cwd); - if (altmsg) { - if (mp) - m_putenv("mhfolder", mp->foldpath); - m_putenv("editalt", altpath); - } - vecp = 0; vec[vecp++] = mhbasename(*ed); if (arg) @@ -679,68 +631,17 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, status = -1; break; } - -#ifdef HAVE_LSTAT - if (altmsg && mp && !is_readonly(mp) && (slinked ? - lstat (linkpath, &st) != NOTOK && - S_ISREG(st.st_mode) && - copyf(linkpath, altpath) == NOTOK : - stat(linkpath, &st) != NOTOK && - st.st_nlink == 1 && - (unlink(altpath) == NOTOK || - link(linkpath, altpath) == NOTOK))) - advise(linkpath, "unable to update %s from", altmsg); -#else /* HAVE_LSTAT */ - if (altmsg && mp && !is_readonly(mp) && - stat(linkpath, &st) != NOTOK && - st.st_nlink == 1 && - (unlink(altpath) == NOTOK || - link(linkpath, altpath) == NOTOK)) - advise(linkpath, "unable to update %s from", altmsg); -#endif /* HAVE_LSTAT */ } /* remember which editor we used */ edsave = getcpy(*ed); *ed = NULL; - if (altmsg) { - unlink(linkpath); - } return status; } -#ifdef HAVE_LSTAT -static int -copyf(char *ifile, char *ofile) -{ - int i, in, out; - char buffer[BUFSIZ]; - - if ((in = open(ifile, O_RDONLY)) == NOTOK) - return NOTOK; - if ((out = open(ofile, O_WRONLY | O_TRUNC)) == NOTOK) { - admonish(ofile, "unable to open and truncate"); - close(in); - return NOTOK; - } - - while ((i = read(in, buffer, sizeof(buffer))) > OK) - if (write(out, buffer, i) != i) { - advise(ofile, "may have damaged"); - i = NOTOK; - break; - } - - close(in); - close(out); - return i; -} -#endif /* HAVE_LSTAT */ - - /* ** SEND */ diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index f3c46f8..e20df68 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -44,8 +44,6 @@ what_now(char *ed, int use, char *file, char *altmsg, int dist, } else { unputenv("mhaltmsg"); } - if ((bp = getenv("mhaltmsg")))/* XXX */ - m_putenv("editalt", bp); snprintf(buffer, sizeof(buffer), "%d", dist); m_putenv("mhdist", buffer); if (!ed) { -- 1.7.10.4