X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bacd74669e1b6614519259f7eaba98da54f9c97c..07916b2ff:/sbr/folder_delmsgs.c?ds=inline diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index 7431b62e..e5b6ae28 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -1,6 +1,4 @@ - -/* - * folder_delmsgs.c -- "remove" SELECTED messages from a folder +/* folder_delmsgs.c -- "remove" SELECTED messages from a folder * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -8,6 +6,8 @@ */ #include +#include +#include "m_mktemp.h" /* * 1) If we are using an external rmmproc, then exec it. @@ -40,6 +40,14 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; + /* + * Write out the sequence and context files; this will release + * any locks before the rmmproc is called. + */ + + seq_save (mp); + context_save (); + vec = argsplit(rmmproc, &prog, &vecp); /* @@ -48,10 +56,7 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) */ if (mp->numsel + vecp + 1 > MAXARGS) - vec = (char **) realloc (vec, (size_t) ((mp->numsel + vecp + 1) * - sizeof(*vec))); - if (vec == NULL) - adios (NULL, "unable to allocate exec vector"); + vec = mh_xrealloc(vec, (mp->numsel + vecp + 1) * sizeof *vec); for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected (mp, msgnum) && !(vec[vecp++] = strdup (m_name (msgnum)))) @@ -97,14 +102,14 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) if (!nohook) { (void)snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum); - (void)ext_hook("del-hook", msgpath, (char *)0); + (void)ext_hook("del-hook", msgpath, NULL); } dp = m_name (msgnum); if (unlink_msgs) { /* just unlink the messages */ - if (unlink (dp) == -1) { + if (m_unlink (dp) == -1) { admonish (dp, "unable to unlink"); retval = -1; continue; @@ -132,5 +137,12 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; + /* + * Write out sequence and context files + */ + + seq_save (mp); + context_save (); + return retval; }