summaryrefslogtreecommitdiff
path: root/mh
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-12-12 11:02:26 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-12-12 13:10:32 +0200
commitd8896b0e5fbd5628b54b7704ab6cb64560caa3b5 (patch)
tree2022fe586a2826c67e057739d47a64dc8489ac40 /mh
parent0f705faa6c5079c03319a49f37912f7f49bce6e1 (diff)
downloadmailutils-d8896b0e5fbd5628b54b7704ab6cb64560caa3b5.tar.gz
mailutils-d8896b0e5fbd5628b54b7704ab6cb64560caa3b5.tar.bz2
Fix -nowhatnow proc in mh
* mh/mh.h (mh_whatnow_env) <nowhatnowproc>: New member. * mh/compcommon.c (check_draft_disposition): Return DISP_REPLACE if nowhatnowproc is set. * mh/mh_whatnow.c (mh_whatnowproc): Return 0 if nowhatnowproc is set. * mh/comp.c: Fix -nowhatnowproc * mh/forw.c: Likewise. * mh/repl.c: Likewise.
Diffstat (limited to 'mh')
-rw-r--r--mh/comp.c5
-rw-r--r--mh/compcommon.c3
-rw-r--r--mh/forw.c5
-rw-r--r--mh/mh.h1
-rw-r--r--mh/mh_whatnow.c3
-rw-r--r--mh/repl.c23
6 files changed, 16 insertions, 24 deletions
diff --git a/mh/comp.c b/mh/comp.c
index 8a9df01c7..16d24daef 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -27,7 +27,6 @@ static char args_doc[] = N_("[MSG]");
struct mh_whatnow_env wh_env = { 0 };
static int initial_edit = 1;
static const char *whatnowproc;
-static int nowhatnowproc;
char *formfile;
static int build_only = 0; /* -build flag */
static int use_draft = 0; /* -use flag */
@@ -81,7 +80,7 @@ static struct mu_option options[] = {
mu_c_string, &whatnowproc },
{ "nowhatnowproc", 0, NULL, MU_OPTION_DEFAULT,
N_("don't run whatnowproc"),
- mu_c_string, &nowhatnowproc, NULL, "1" },
+ mu_c_int, &wh_env.nowhatnowproc, NULL, "1" },
{ "use", 0, NULL, MU_OPTION_DEFAULT,
N_("use draft file preserved after the last session"),
mu_c_bool, &use_draft },
@@ -235,7 +234,7 @@ main (int argc, char **argv)
}
/* Exit immediately if -build is given */
- if (build_only || nowhatnowproc)
+ if (build_only || wh_env.nowhatnowproc)
return 0;
return mh_whatnowproc (&wh_env, initial_edit, whatnowproc);
diff --git a/mh/compcommon.c b/mh/compcommon.c
index 1298d1f46..d6e55559e 100644
--- a/mh/compcommon.c
+++ b/mh/compcommon.c
@@ -74,6 +74,9 @@ check_draft_disposition (struct mh_whatnow_env *wh, int use_draft)
struct stat st;
int disp = DISP_REPLACE;
+ if (wh->nowhatnowproc)
+ return disp;
+
/* First check if the draft exists */
if (stat (wh->draftfile, &st) == 0)
{
diff --git a/mh/forw.c b/mh/forw.c
index 5c9fd934a..33d120f07 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -37,7 +37,6 @@ static const char *whatnowproc;
static char *mhl_filter_file = NULL; /* --filter flag */
static int build_only = 0; /* --build flag */
-static int nowhatnowproc = 0; /* --nowhatnowproc */
static int annotate = 0; /* --annotate flag */
static enum encap_type encap = encap_clear; /* controlled by --format, --form
and --mime flags */
@@ -136,7 +135,7 @@ static struct mu_option options[] = {
mu_c_string, &whatnowproc },
{ "nowhatnowproc", 0, NULL, MU_OPTION_DEFAULT,
N_("don't run whatnowproc"),
- mu_c_int, &nowhatnowproc, NULL, "1" },
+ mu_c_int, &wh_env.nowhatnowproc, NULL, "1" },
{ "use", 0, NULL, MU_OPTION_DEFAULT,
N_("use draft file preserved after the last session"),
mu_c_bool, &use_draft },
@@ -434,7 +433,7 @@ main (int argc, char **argv)
}
/* Exit immediately if --build is given */
- if (build_only || nowhatnowproc)
+ if (build_only || wh_env.nowhatnowproc)
{
if (strcmp (wh_env.file, wh_env.draftfile))
rename (wh_env.file, wh_env.draftfile);
diff --git a/mh/mh.h b/mh/mh.h
index 7d3ea0bd9..578a065cd 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -215,6 +215,7 @@ struct mh_whatnow_env /* whatnow shell environment */
char *anno_field; /* Annotate field to be used */
mu_list_t anno_list; /* List of messages (mu_message_t) to annotate */
mu_mailbox_t mbox;
+ int nowhatnowproc;
};
#define DISP_QUIT 0
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c
index 53eafb426..95a403a83 100644
--- a/mh/mh_whatnow.c
+++ b/mh/mh_whatnow.c
@@ -582,6 +582,9 @@ mh_whatnowproc (struct mh_whatnow_env *wh, int initial_edit, const char *prog)
{
int rc;
pid_t pid;
+
+ if (wh->nowhatnowproc)
+ return 0;
if (!prog)
return mh_whatnow (wh, initial_edit);
diff --git a/mh/repl.c b/mh/repl.c
index 2d27ab58e..e3467f8a8 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -35,7 +35,6 @@ static const char *whatnowproc;
static mu_msgset_t msgset;
static mu_mailbox_t mbox;
static int build_only = 0; /* -build flag */
-static int nowhatnowproc = 0; /* -nowhatnowproc */
static int use_draft = 0; /* -use flag */
static char *mhl_filter = NULL; /* -filter flag */
static int annotate; /* -annotate flag */
@@ -86,7 +85,7 @@ set_whatnowproc (struct mu_parseopt *po, struct mu_option *opt,
char const *arg)
{
whatnowproc = mu_strdup (arg);
- nowhatnowproc = 0;
+ wh_env.nowhatnowproc = 0;
}
static void
@@ -165,7 +164,7 @@ static struct mu_option options[] = {
mu_c_string, NULL, set_whatnowproc },
{ "nowhatnowproc", 0, NULL, MU_OPTION_DEFAULT,
N_("don't run whatnowproc"),
- mu_c_int, &nowhatnowproc, NULL, "1" },
+ mu_c_int, &wh_env.nowhatnowproc, NULL, "1" },
{ "use", 0, NULL, MU_OPTION_DEFAULT,
N_("use draft file preserved after the last session"),
mu_c_bool, &use_draft },
@@ -190,23 +189,11 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
{
int rc;
mu_message_t msg;
- struct stat st;
size_t msgno;
/* First check if the draft exists */
- if (!build_only && stat (wh->draftfile, &st) == 0)
- {
- if (use_draft)
- disp = DISP_USE;
- else
- {
- printf (ngettext ("Draft \"%s\" exists (%s byte).\n",
- "Draft \"%s\" exists (%s bytes).\n",
- (unsigned long) st.st_size),
- wh->draftfile, mu_umaxtostr (0, st.st_size));
- disp = mh_disposition (wh->draftfile);
- }
- }
+ if (!build_only)
+ disp = check_draft_disposition (wh, use_draft);
switch (disp)
{
@@ -344,7 +331,7 @@ main (int argc, char **argv)
make_draft (mbox, DISP_REPLACE, &wh_env);
/* Exit immediately if --build is given */
- if (build_only || nowhatnowproc)
+ if (build_only || wh_env.nowhatnowproc)
return 0;
rc = mh_whatnowproc (&wh_env, initial_edit, whatnowproc);

Return to:

Send suggestions and report system problems to the System administrator.