From 7af26a5bed6efce10f3e5dd8cd7520420453c4f2 Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Sun, 8 Dec 2019 17:54:29 +0100 Subject: [PATCH] remove Previus-Sequence support The Previus-Sequence was racy and introduce a lot of write accesses. Also most use cases can solved better with shell history and command line editing. --- config/config.c | 1 - h/mh.h | 1 - man/mh-profile.man5 | 14 ------------ man/mh-sequence.man7 | 60 +++++++++++++------------------------------------- man/refile.man1 | 8 ------- sbr/Makefile.in | 2 +- sbr/m_draft.c | 1 - sbr/seq_setprev.c | 44 ------------------------------------ uip/burst.c | 1 - uip/comp.c | 1 - uip/dist.c | 1 - uip/folder.c | 1 - uip/forw.c | 1 - uip/mhlist.c | 1 - uip/mhparam.c | 2 -- uip/mhpath.c | 2 -- uip/mhshow.c | 1 - uip/mhstore.c | 1 - uip/mhtest.c | 1 - uip/packf.c | 1 - uip/pick.c | 1 - uip/refile.c | 2 -- uip/repl.c | 1 - uip/rmm.c | 1 - uip/send.c | 1 - uip/sortm.c | 1 - 26 files changed, 16 insertions(+), 136 deletions(-) delete mode 100644 sbr/seq_setprev.c diff --git a/config/config.c b/config/config.c index 5e25041..0a63912 100644 --- a/config/config.c +++ b/config/config.c @@ -89,7 +89,6 @@ char *seq_unseen = "u"; char *seq_neg = "!"; char *usequence = "Unseen-Sequence"; -char *psequence = "Previous-Sequence"; char *nsequence = "Sequence-Negation"; /* profile entries for storage locations */ diff --git a/h/mh.h b/h/mh.h index 6337a0c..649582d 100644 --- a/h/mh.h +++ b/h/mh.h @@ -288,7 +288,6 @@ extern char *msgprot; extern char *nmhstorage; extern char *nsequence; extern char *profile; -extern char *psequence; extern char *rcvdistcomps; extern char *replcomps; extern char *replgroupcomps; diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index 3b692ee..3c59e62 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -65,20 +65,6 @@ Defines the name of your default inbox. (profile, default: inbox) .RE .PP -.BR Previous\-Sequence : -.I pseq -.RS 5 -Names the sequence or sequences which should be defined as the `msgs' or -`msg' argument given to any -.B mmh -command. If not present or empty, -no such sequences are defined. Otherwise, for each name given, the -sequence is first zero'd and then each message is added to the sequence. -Read the -.BR mh\-sequence (7) -man page for the details about this sequence. (profile, no default) -.RE -.PP .BR Sequence\-Negation : \&! .RS 5 diff --git a/man/mh-sequence.man7 b/man/mh-sequence.man7 index 0ad2c4a..c793d7e 100644 --- a/man/mh-sequence.man7 +++ b/man/mh-sequence.man7 @@ -197,47 +197,6 @@ you might need to quote the exlamation mark (prefix it with a backslash). To deactivate the negation mechanism, define Sequence\-Negation in your profile to an empty value. -.SS "The Previous Sequence" -.B Mmh -provides the ability to remember the `msgs' or `msg' argument -last given to an -.B mmh -command. The entry `Previous\-Sequence' -should be defined in the -.B mmh -profile; its value should be a sequence -name or multiple sequence names separated by spaces. If this entry -is defined, when an -.B mmh -command finishes, it will define the -sequence(s) named in the value of this entry to be those messages that -were specified to the command. Hence, a profile entry of -.PP -.RS 5 -Previous\-Sequence: pseq -.RE -.PP -directs any -.B mmh -command that accepts a `msg' or `msgs' argument to -define the sequence `pseq' as those messages when it finishes. -.PP -.BR Note : -there can be a performance penalty in using the -`Previous\-Sequence' facility. If it is used, -.B all -.B mmh -programs have to write the sequence information to the -.I \&.mh_sequences -file for the folder each time they run. If the -`Previous\-Sequence' profile entry is not included, only -.B pick -and -.B mark -will write to the -.B \&.mh_sequences -file. - .SS "The Unseen Sequence" Finally, the unseen sequence indicates which messages have not been previously seen by the user. @@ -258,13 +217,12 @@ the new messages will also be added to the unseen sequence. .BR inc , for example, adds new messages to the unseen sequence. -Unlike the behavior of the previous sequence, however, -the unseen sequence will +The unseen sequence will .B not be zeroed by .BR inc . .PP -Similarly, whenever +Whenever .BR show , .BR next , or @@ -299,12 +257,24 @@ in your profile with an empty value. .ta \w'ExtraBigProfileName 'u ^Mh-Sequences:~^Name of file to store public sequences ^Sequence\-Negation:~^To designate messages not in a sequence -^Previous\-Sequence:~^The last message specification given ^Unseen\-Sequence:~^Those messages not yet seen by the user .fi .SH "SEE ALSO" flist(1), mark(1), pick(1), mh-profile(5) +.SH "HISTORY" +.SS Previous\-Sequence +This sequence stored the selected messages for the previous +.B mmh +command. +It was disabled by default because it introduced a lot of extra writes to the +.IR \&.mh_sequences +file. +Additionally, it introduced possible race conditions when running multiple +.B mmh +commands in parallel. +As this feature was rarely used, it was removed. + .SH DEFAULTS None diff --git a/man/refile.man1 b/man/refile.man1 index 2909230..37a6f0f 100644 --- a/man/refile.man1 +++ b/man/refile.man1 @@ -130,14 +130,6 @@ If is specified, the current message in the source folder will be set to the last message specified; otherwise, the current message won't be changed. -.PP -If the `Previous\-Sequence' profile entry is set, in addition to defining -the named sequences from the source folder, -.B refile -will also define -those sequences for the destination folders. See -.B mh\-sequence (7) -for information concerning the previous sequence. .SH HISTORY Since mmh-0.3, diff --git a/sbr/Makefile.in b/sbr/Makefile.in index f2310fb..142a7f2 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -68,7 +68,7 @@ SRCS = addrsbr.c ambigsw.c brkstring.c \ readconfig.c seq_add.c seq_bits.c \ seq_del.c seq_getnum.c seq_list.c seq_nameok.c \ seq_print.c seq_read.c seq_save.c seq_setcur.c \ - seq_setprev.c seq_setunseen.c signals.c \ + seq_setunseen.c signals.c \ smatch.c snprintb.c strcasecmp.c \ strindex.c trim.c trimcpy.c uprf.c vfgets.c fmt_def.c \ mf.c utils.c m_mktemp.c seq_msgstats.c \ diff --git a/sbr/m_draft.c b/sbr/m_draft.c index ee85790..050c7e5 100644 --- a/sbr/m_draft.c +++ b/sbr/m_draft.c @@ -53,7 +53,6 @@ m_draft(char *which) */ if (!m_convert(mp, which)) exit(EX_SOFTWARE); - seq_setprev(mp); snprintf(buffer, sizeof(buffer), "%s/%s", mp->foldpath, m_name(mp->lowsel)); diff --git a/sbr/seq_setprev.c b/sbr/seq_setprev.c deleted file mode 100644 index f4304cc..0000000 --- a/sbr/seq_setprev.c +++ /dev/null @@ -1,44 +0,0 @@ -/* -** seq_setprev.c -- set the Previous-Sequence -** -** 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 -#include - -/* -** Add all the messages currently SELECTED to -** the Previous-Sequence. This way, when the next -** command is given, there is a convenient way to -** selected all the messages used in the previous -** command. -*/ - -void -seq_setprev(struct msgs *mp) -{ - char **ap, *cp, *dp; - - /* - ** Get the list of sequences for Previous-Sequence - ** and split them. - */ - if ((cp = context_find(psequence))) { - dp = mh_xstrdup(cp); - if (!(ap = brkstring(dp, " ", "\n")) || !*ap) { - mh_free0(&dp); - return; - } - } else { - return; - } - - /* Now add all SELECTED messages to each sequence */ - for (; *ap; ap++) - seq_addsel(mp, *ap, -1, 1); - - mh_free0(&dp); -} diff --git a/uip/burst.c b/uip/burst.c index 12d1f9d..09a60d9 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -117,7 +117,6 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgp; msgnum++) if (!m_convert(mp, msgs[msgnum])) exit(EX_SOFTWARE); - seq_setprev(mp); /* set the previous-sequence */ smsgs = mh_xcalloc(MAXFOLDER + 2, sizeof(*smsgs)); diff --git a/uip/comp.c b/uip/comp.c index 75bbf86..907bbf3 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -148,7 +148,6 @@ main(int argc, char **argv) if (!m_convert(mp, msg)) { exit(EX_SOFTWARE); } - seq_setprev(mp); /* set the previous-sequence */ if (mp->numsel > 1) { adios(EX_USAGE, NULL, "only one message at a time!"); } diff --git a/uip/dist.c b/uip/dist.c index 1d5c3aa..66539e6 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -153,7 +153,6 @@ main(int argc, char **argv) if (!m_convert(mp, msg)) { exit(EX_USAGE); } - seq_setprev(mp); if (mp->numsel > 1) { adios(EX_USAGE, NULL, "only one message at a time!"); diff --git a/uip/folder.c b/uip/folder.c index b7cdfe5..945e4fc 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -615,7 +615,6 @@ sfold(struct msgs *mp, char *msg) admonish(NULL, "only one message at a time!"); return 0; } - seq_setprev(mp); /* set the previous-sequence */ seq_setcur(mp, mp->lowsel); /* set current message */ seq_save(mp); /* synchronize message sequences */ context_save(); /* save the context file */ diff --git a/uip/forw.c b/uip/forw.c index e00ae0e..d6ded24 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -197,7 +197,6 @@ main(int argc, char **argv) exit(EX_SOFTWARE); } } - seq_setprev(mp); /* set the previous sequence */ if ((out = creat(drft, m_gmprot())) == NOTOK) adios(EX_CANTCREAT, drft, "unable to create"); diff --git a/uip/mhlist.c b/uip/mhlist.c index 7056db5..169ca50 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -230,7 +230,6 @@ main(int argc, char **argv) exit(EX_SOFTWARE); } } - seq_setprev(mp); /* set the previous-sequence */ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; diff --git a/uip/mhparam.c b/uip/mhparam.c index 2c61e60..e02bf49 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -78,7 +78,6 @@ static struct proc procs [] = { { "mimetypequery-component", &mimetypequery }, { "nmhstorage-component", &nmhstorage }, { "nsequence-component", &nsequence }, - { "psequence-component", &psequence }, { "usequence-component", &usequence }, { "#--Mmh-specific-Mail-Header-Names--", &empty }, @@ -109,7 +108,6 @@ static struct proc procs [] = { { "seq-first", &seq_first }, { "seq-last", &seq_last }, { "seq-next", &seq_next }, - { "previous-sequence", &seq_prev }, { "unseen-sequence", &seq_unseen }, { "sequence-negation", &seq_neg }, diff --git a/uip/mhpath.c b/uip/mhpath.c index 31e0722..df4e140 100644 --- a/uip/mhpath.c +++ b/uip/mhpath.c @@ -123,8 +123,6 @@ main(int argc, char **argv) } } - seq_setprev(mp); /* set the previous-sequence */ - /* print the path of all selected messages */ for (i = mp->lowsel; i <= mp->hghsel; i++) if (is_selected(mp, i)) diff --git a/uip/mhshow.c b/uip/mhshow.c index be9cd45..6978454 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -301,7 +301,6 @@ main(int argc, char **argv) if (is_selected(mp, msgnum)) set_unseen(mp, msgnum); - seq_setprev(mp); /* set the Previous-Sequence */ seq_setunseen(mp, 0); /* unset unseen seqs for shown msgs */ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); diff --git a/uip/mhstore.c b/uip/mhstore.c index 47b7c02..971ee7e 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -292,7 +292,6 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) exit(EX_USAGE); - seq_setprev(mp); /* set the previous-sequence */ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; diff --git a/uip/mhtest.c b/uip/mhtest.c index d4bf6a6..71787af 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -240,7 +240,6 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) exit(EX_USAGE); - seq_setprev(mp); /* set the previous-sequence */ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; diff --git a/uip/packf.c b/uip/packf.c index fe1102c..b2726f4 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -95,7 +95,6 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) exit(EX_USAGE); - seq_setprev(mp); /* set the previous-sequence */ /* copy all the SELECTED messages to stdout */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { diff --git a/uip/pick.c b/uip/pick.c index 8f28f35..0b9205b 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -340,7 +340,6 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) exit(EX_USAGE); - seq_setprev(mp); /* set the previous-sequence */ /* ** If we aren't saving the results to a sequence, diff --git a/uip/refile.c b/uip/refile.c index 682f66a..663936b 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -188,7 +188,6 @@ main(int argc, char **argv) exit(EX_SOFTWARE); } } - seq_setprev(mp); /* create folder structures for each destination folder */ opnfolds(folders, foldp); @@ -277,7 +276,6 @@ clsfolds(struct st_fold *folders, int nfolders) for (fp = folders, ep = folders + nfolders; fp < ep; fp++) { mp = fp->f_mp; - seq_setprev(mp); seq_save(mp); } } diff --git a/uip/repl.c b/uip/repl.c index b2adebf..438d854 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -311,7 +311,6 @@ main(int argc, char **argv) /* parse the message range/sequence/name and set SELECTED */ if (!m_convert(mp, msg)) exit(EX_SOFTWARE); - seq_setprev(mp); /* set the previous-sequence */ if (mp->numsel > 1) adios(EX_USAGE, NULL, "only one message at a time!"); diff --git a/uip/rmm.c b/uip/rmm.c index 5059383..7258327 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -117,7 +117,6 @@ main(int argc, char **argv) if (unlink_msgs) { /* "remove" the SELECTED messages */ folder_delmsgs(mp, 1); - seq_setprev(mp); seq_save(mp); folder_free(mp); return 0; diff --git a/uip/send.c b/uip/send.c index d7691db..148c05b 100644 --- a/uip/send.c +++ b/uip/send.c @@ -165,7 +165,6 @@ main(int argc, char **argv) exit(EX_USAGE); } } - seq_setprev(mp); for (nmsgs = 0, msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { diff --git a/uip/sortm.c b/uip/sortm.c index c56a401..740e692 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -191,7 +191,6 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) exit(EX_USAGE); - seq_setprev(mp); /* set the previous sequence */ if ((nmsgs = read_hdrs(mp, datesw)) <= 0) adios(EX_DATAERR, NULL, "no messages to sort"); -- 1.7.10.4