diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2017-06-11 00:29:06 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2017-06-11 00:29:06 +0300 |
commit | fe90e86dac8c9c91a35347ee5bb4513195263ee2 (patch) | |
tree | 2fdb185baa9e0807641147881adf302e5aa39ea6 | |
parent | 263e2e9f9fcf721c11a61a16dca4cb38d6385fe9 (diff) | |
download | mailutils-fe90e86dac8c9c91a35347ee5bb4513195263ee2.tar.gz mailutils-fe90e86dac8c9c91a35347ee5bb4513195263ee2.tar.bz2 |
Fix the -nodraftfolder and -nowhatnowproc options.
The commit 744c4a9c didn't take into account the -nodraftfolder
and -nowhatnowproc options, which can be used to cancel the
effect of the corresponding facilities. This commit fixes it.
* mh/mh_getopt.c (mh_getopt_ext): New function.
* mh/mh_getopt.h (mh_getopt_ext): New prototype.
(mh_optinit): New struct.
* mh/tests/comp.at: Test the use of Draft-Folder
* mh/tests/forw.at: Likewise.
* mh/tests/repl.at: Likewise.
* mh/comp.c (main): use mh_getopt_ext to properly process draftfolder
and whatnowproc.
* mh/forw.c: Likewise.
* mh/repl.c: Likewise.
* mh/mh.h (mh_whom): Remove.
(mh_whom_header, mh_whom_file, mh_whom_message): New protos.
* mh/mh_alias.y (mh_read_aliases): Don't read aliases twice.
* mh/mh_whatnow.c (whom): Use mh_whom_file.
* mh/mh_whom.c (mh_whom): Rewrite and rename to mh_whom_file.
(mh_whom_header, mh_whom_message): New functions.
* mh/whom.c: Use mh_getopt_ext. Interpret command line
arguments, depending on whether the draftfile facility is in use.
-rw-r--r-- | mh/comp.c | 13 | ||||
-rw-r--r-- | mh/forw.c | 14 | ||||
-rw-r--r-- | mh/mh.h | 6 | ||||
-rw-r--r-- | mh/mh_alias.l | 2 | ||||
-rw-r--r-- | mh/mh_alias.y | 3 | ||||
-rw-r--r-- | mh/mh_getopt.c | 44 | ||||
-rw-r--r-- | mh/mh_getopt.h | 13 | ||||
-rw-r--r-- | mh/mh_whatnow.c | 7 | ||||
-rw-r--r-- | mh/mh_whom.c | 86 | ||||
-rw-r--r-- | mh/repl.c | 16 | ||||
-rw-r--r-- | mh/tests/comp.at | 43 | ||||
-rw-r--r-- | mh/tests/forw.at | 123 | ||||
-rw-r--r-- | mh/tests/repl.at | 64 | ||||
-rw-r--r-- | mh/whom.c | 63 |
14 files changed, 424 insertions, 73 deletions
@@ -127,15 +127,16 @@ copy_message (mu_mailbox_t mbox, size_t n, const char *file) | |||
127 | return rc; | 127 | return rc; |
128 | } | 128 | } |
129 | 129 | ||
130 | static struct mh_optinit optinit[] = { | ||
131 | { "draftfolder", "Draft-Folder" }, | ||
132 | { "whatnowproc", "whatnowproc" }, | ||
133 | { NULL } | ||
134 | }; | ||
135 | |||
130 | int | 136 | int |
131 | main (int argc, char **argv) | 137 | main (int argc, char **argv) |
132 | { | 138 | { |
133 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); | 139 | mh_getopt_ext (&argc, &argv, options, 0, optinit, args_doc, prog_doc, NULL); |
134 | |||
135 | if (!draftfolder) | ||
136 | draftfolder = mh_global_profile_get ("Draft-Folder", NULL); | ||
137 | if (!whatnowproc) | ||
138 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); | ||
139 | 140 | ||
140 | if (use_draft) | 141 | if (use_draft) |
141 | draftmessage = "cur"; | 142 | draftmessage = "cur"; |
@@ -377,17 +377,19 @@ finish_draft () | |||
377 | mu_stream_destroy (&stream); | 377 | mu_stream_destroy (&stream); |
378 | } | 378 | } |
379 | 379 | ||
380 | static struct mh_optinit optinit[] = { | ||
381 | { "draftfolder", "Draft-Folder" }, | ||
382 | { "whatnowproc", "whatnowproc" }, | ||
383 | { NULL } | ||
384 | }; | ||
385 | |||
380 | int | 386 | int |
381 | main (int argc, char **argv) | 387 | main (int argc, char **argv) |
382 | { | 388 | { |
383 | int rc; | 389 | int rc; |
384 | 390 | ||
385 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, | 391 | mh_getopt_ext (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, optinit, |
386 | args_doc, prog_doc, NULL); | 392 | args_doc, prog_doc, NULL); |
387 | if (!draftfolder) | ||
388 | draftfolder = mh_global_profile_get ("Draft-Folder", NULL); | ||
389 | if (!whatnowproc) | ||
390 | whatnowproc = mh_global_profile_get ("whatnowproc", NULL); | ||
391 | if (!formfile) | 393 | if (!formfile) |
392 | mh_find_file ("forwcomps", &formfile); | 394 | mh_find_file ("forwcomps", &formfile); |
393 | 395 | ||
@@ -342,7 +342,11 @@ int mh_usedraft (const char *filename); | |||
342 | int mh_file_copy (const char *from, const char *to); | 342 | int mh_file_copy (const char *from, const char *to); |
343 | char *mh_draft_name (void); | 343 | char *mh_draft_name (void); |
344 | char *mh_create_message_id (int); | 344 | char *mh_create_message_id (int); |
345 | int mh_whom (const char *filename, int check); | 345 | |
346 | int mh_whom_header (mu_header_t hdr); | ||
347 | int mh_whom_file (const char *filename, int check); | ||
348 | int mh_whom_message (mu_message_t msg, int check); | ||
349 | |||
346 | void mh_set_reply_regex (const char *str); | 350 | void mh_set_reply_regex (const char *str); |
347 | int mh_decode_2047 (char *text, char **decoded_text); | 351 | int mh_decode_2047 (char *text, char **decoded_text); |
348 | const char *mh_charset (const char *); | 352 | const char *mh_charset (const char *); |
diff --git a/mh/mh_alias.l b/mh/mh_alias.l index df81ce30f..0deb7c99b 100644 --- a/mh/mh_alias.l +++ b/mh/mh_alias.l | |||
@@ -422,7 +422,7 @@ int | |||
422 | mh_alias_read (char const *name, int fail) | 422 | mh_alias_read (char const *name, int fail) |
423 | { | 423 | { |
424 | extern int yydebug; | 424 | extern int yydebug; |
425 | char *p = getenv("ALI_YYDEBUG"); | 425 | char *p = getenv ("ALI_YYDEBUG"); |
426 | 426 | ||
427 | if (p && *p > '0' && *p < '9') | 427 | if (p && *p > '0' && *p < '9') |
428 | yydebug = 1; | 428 | yydebug = 1; |
diff --git a/mh/mh_alias.y b/mh/mh_alias.y index 0d6bffcc2..54e3cd1c6 100644 --- a/mh/mh_alias.y +++ b/mh/mh_alias.y | |||
@@ -492,6 +492,9 @@ int | |||
492 | mh_read_aliases () | 492 | mh_read_aliases () |
493 | { | 493 | { |
494 | const char *p; | 494 | const char *p; |
495 | |||
496 | if (alias_list) | ||
497 | return 0; | ||
495 | 498 | ||
496 | p = mh_global_profile_get ("Aliasfile", NULL); | 499 | p = mh_global_profile_get ("Aliasfile", NULL); |
497 | if (p) | 500 | if (p) |
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c index 65fe3e8c7..16a6e5c55 100644 --- a/mh/mh_getopt.c +++ b/mh/mh_getopt.c | |||
@@ -179,10 +179,39 @@ has_folder_option (struct mu_option *opt) | |||
179 | return 0; | 179 | return 0; |
180 | } | 180 | } |
181 | 181 | ||
182 | static void | ||
183 | opt_init (struct mu_parseopt *po, | ||
184 | struct mu_option **optv, struct mh_optinit *optinit) | ||
185 | { | ||
186 | if (!optinit) | ||
187 | return; | ||
188 | for (; optinit->opt; optinit++) | ||
189 | { | ||
190 | size_t i; | ||
191 | for (i = 0; optv[i]; i++) | ||
192 | { | ||
193 | struct mu_option *opt; | ||
194 | for (opt = optv[i]; !MU_OPTION_IS_END (opt); opt++) | ||
195 | { | ||
196 | if (strcmp (opt->opt_long, optinit->opt) == 0) | ||
197 | { | ||
198 | char const *val = mh_global_profile_get (optinit->var, NULL); | ||
199 | if (val) | ||
200 | { | ||
201 | (opt->opt_set ? | ||
202 | opt->opt_set : mu_option_set_value) (po, opt, val); | ||
203 | } | ||
204 | break; | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | |||
182 | void | 211 | void |
183 | mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | 212 | mh_getopt_ext (int *pargc, char ***pargv, struct mu_option *options, |
184 | int mhflags, | 213 | int mhflags, struct mh_optinit *optinit, |
185 | char *argdoc, char *progdoc, char *extradoc) | 214 | char *argdoc, char *progdoc, char *extradoc) |
186 | { | 215 | { |
187 | int argc = *pargc; | 216 | int argc = *pargc; |
188 | char **argv = *pargv; | 217 | char **argv = *pargv; |
@@ -256,6 +285,7 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | |||
256 | if (options) | 285 | if (options) |
257 | optv[i++] = options; | 286 | optv[i++] = options; |
258 | optv[i] = NULL; | 287 | optv[i] = NULL; |
288 | opt_init (&po, optv, optinit); | ||
259 | 289 | ||
260 | if (mu_parseopt (&po, argc, argv, optv, flags)) | 290 | if (mu_parseopt (&po, argc, argv, optv, flags)) |
261 | exit (po.po_exit_error); | 291 | exit (po.po_exit_error); |
@@ -285,6 +315,14 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | |||
285 | } | 315 | } |
286 | 316 | ||
287 | void | 317 | void |
318 | mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ||
319 | int mhflags, char *argdoc, char *progdoc, char *extradoc) | ||
320 | { | ||
321 | mh_getopt_ext (pargc, pargv, options, mhflags, NULL, argdoc, progdoc, | ||
322 | extradoc); | ||
323 | } | ||
324 | |||
325 | void | ||
288 | mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | 326 | mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
289 | { | 327 | { |
290 | mu_error (_("option is not yet implemented: %s"), opt->opt_long); | 328 | mu_error (_("option is not yet implemented: %s"), opt->opt_long); |
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h index 2aa90b669..684ace678 100644 --- a/mh/mh_getopt.h +++ b/mh/mh_getopt.h | |||
@@ -20,9 +20,18 @@ | |||
20 | 20 | ||
21 | #define MH_GETOPT_DEFAULT_FOLDER 0x1 | 21 | #define MH_GETOPT_DEFAULT_FOLDER 0x1 |
22 | 22 | ||
23 | struct mh_optinit | ||
24 | { | ||
25 | char const *opt; /* Option name */ | ||
26 | char const *var; /* mh_property name */ | ||
27 | }; | ||
28 | |||
29 | void mh_getopt_ext (int *pargc, char ***pargv, struct mu_option *options, | ||
30 | int mhflags, struct mh_optinit *optinit, | ||
31 | char *argdoc, char *progdoc, char *extradoc); | ||
32 | |||
23 | void mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | 33 | void mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
24 | int flags, | 34 | int flags, char *argdoc, char *progdoc, char *extradoc); |
25 | char *argdoc, char *progdoc, char *extradoc); | ||
26 | 35 | ||
27 | void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, | 36 | void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, |
28 | char const *arg); | 37 | char const *arg); |
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c index 5dc15b553..0bd2acabe 100644 --- a/mh/mh_whatnow.c +++ b/mh/mh_whatnow.c | |||
@@ -544,9 +544,10 @@ whom (struct mh_whatnow_env *wh, int argc, char **argv, int *status) | |||
544 | if (!wh->file) | 544 | if (!wh->file) |
545 | mu_error (_("no draft file to display")); | 545 | mu_error (_("no draft file to display")); |
546 | else | 546 | else |
547 | mh_whom (wh->file, (argc == 2 | 547 | mh_whom_file (wh->file, |
548 | && (strcmp (argv[1], "-check") == 0 | 548 | (argc == 2 |
549 | || strcmp (argv[1], "--check") == 0))); | 549 | && (strcmp (argv[ |