summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-06-15 22:09:30 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-06-16 09:50:36 +0300
commitc1f2442cd53e43cf11cc8f5b649b454b3f2cb03f (patch)
tree6ef0b4a8d01cb81d8f4f1ae2757ad4047ebb03f5
parent8b5715db380634336a231b0c8573c350992c8dce (diff)
parentfe90e86dac8c9c91a35347ee5bb4513195263ee2 (diff)
downloadmailutils-c1f2442cd53e43cf11cc8f5b649b454b3f2cb03f.tar.gz
mailutils-c1f2442cd53e43cf11cc8f5b649b454b3f2cb03f.tar.bz2
Merge branch 'master' into locus
-rw-r--r--NEWS9
-rw-r--r--mh/comp.c13
-rw-r--r--mh/forw.c14
-rw-r--r--mh/mh.h6
-rw-r--r--mh/mh_alias_gram.y3
-rw-r--r--mh/mh_getopt.c44
-rw-r--r--mh/mh_getopt.h13
-rw-r--r--mh/mh_whatnow.c7
-rw-r--r--mh/mh_whom.c86
-rw-r--r--mh/repl.c16
-rw-r--r--mh/tests/comp.at43
-rw-r--r--mh/tests/forw.at123
-rw-r--r--mh/tests/repl.at64
-rw-r--r--mh/whom.c63
14 files changed, 431 insertions, 73 deletions
diff --git a/NEWS b/NEWS
index 266a99912..e35169161 100644
--- a/NEWS
+++ b/NEWS
@@ -1,2 +1,2 @@
1GNU mailutils NEWS -- history of user-visible changes. 2017-06-01 1GNU mailutils NEWS -- history of user-visible changes. 2017-06-16
2Copyright (C) 2002-2017 Free Software Foundation, Inc. 2Copyright (C) 2002-2017 Free Software Foundation, Inc.
@@ -77,2 +77,9 @@ section is not defined.
77 77
78* Source location API
79
80Libmailutils provides functions for keeping track of locations in
81source files for diagnostic purposes.
82
83* Improve error reporting
84
78* AM_GNU_MAILUTILS autoconf macro 85* AM_GNU_MAILUTILS autoconf macro
diff --git a/mh/comp.c b/mh/comp.c
index 075bb4516..29389c69e 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -129,2 +129,8 @@ copy_message (mu_mailbox_t mbox, size_t n, const char *file)
129 129
130static struct mh_optinit optinit[] = {
131 { "draftfolder", "Draft-Folder" },
132 { "whatnowproc", "whatnowproc" },
133 { NULL }
134};
135
130int 136int
@@ -132,8 +138,3 @@ 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
diff --git a/mh/forw.c b/mh/forw.c
index 5e0e08b97..016ac84bc 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -379,2 +379,8 @@ finish_draft ()
379 379
380static struct mh_optinit optinit[] = {
381 { "draftfolder", "Draft-Folder" },
382 { "whatnowproc", "whatnowproc" },
383 { NULL }
384};
385
380int 386int
@@ -384,8 +390,4 @@ main (int argc, char **argv)
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)
diff --git a/mh/mh.h b/mh/mh.h
index 69be72de2..76bc85e37 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -344,3 +344,7 @@ char *mh_draft_name (void);
344char *mh_create_message_id (int); 344char *mh_create_message_id (int);
345int mh_whom (const char *filename, int check); 345
346int mh_whom_header (mu_header_t hdr);
347int mh_whom_file (const char *filename, int check);
348int mh_whom_message (mu_message_t msg, int check);
349
346void mh_set_reply_regex (const char *str); 350void mh_set_reply_regex (const char *str);
diff --git a/mh/mh_alias_gram.y b/mh/mh_alias_gram.y
index d7229983a..26b13ec83 100644
--- a/mh/mh_alias_gram.y
+++ b/mh/mh_alias_gram.y
@@ -504,2 +504,5 @@ mh_read_aliases (void)
504 const char *p; 504 const char *p;
505
506 if (alias_list)
507 return 0;
505 508
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
@@ -181,6 +181,35 @@ has_folder_option (struct mu_option *opt)
181 181
182static void
183opt_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
182void 211void
183mh_getopt (int *pargc, char ***pargv, struct mu_option *options, 212mh_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{
@@ -258,2 +287,3 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
258 optv[i] = NULL; 287 optv[i] = NULL;
288 opt_init (&po, optv, optinit);
259 289
@@ -287,2 +317,10 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
287void 317void
318mh_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
325void
288mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg) 326mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
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
@@ -22,5 +22,14 @@
22 22
23struct mh_optinit
24{
25 char const *opt; /* Option name */
26 char const *var; /* mh_property name */
27};
28
29void 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
23void mh_getopt (int *pargc, char ***pargv, struct mu_option *options, 33void 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
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
@@ -546,5 +546,6 @@ whom (struct mh_whatnow_env *wh, int argc, char **argv, int *status)
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[1], "-check") == 0
550 || strcmp (argv[1], "--check") == 0)));
550 return 0; 551 return 0;
diff --git a/mh/mh_whom.c b/mh/mh_whom.c
index bbdef7ac5..f3067d1ab 100644
--- a/mh/mh_whom.c
+++ b/mh/mh_whom.c
@@ -263,3 +263,42 @@ read_header (mu_stream_t stream)
263int 263int
264mh_whom (const char *filename, int check) 264mh_whom_header (mu_header_t hdr)
265{
266 size_t count = 0;
267 int rc;
268 const char *val;
269
270 mh_read_aliases ();
271
272 if (mu_header_sget_value (hdr, MU_HEADER_TO, &val) == 0)
273 scan_addrs (val, 0);
274 if (mu_header_sget_value (hdr, MU_HEADER_CC, &val) == 0)
275 scan_addrs (val, 0);
276 if (mu_header_sget_value (hdr, MU_HEADER_BCC, &val) == 0)
277 scan_addrs (val, 1);
278
279 if (local_rcp)
280 {
281 printf (" %s\n", _("-- Local Recipients --"));
282 mu_list_foreach (local_rcp, _print_local_recipient, &count);
283 }
284
285 if (network_rcp)
286 {
287 printf (" %s\n", _("-- Network Recipients --"));
288 mu_list_foreach (network_rcp, _print_recipient, &count);
289 }
290
291 if (count == 0)
292 {
293 mu_error(_("no recipients"));
294 rc = -1;
295 }
296
297 destroy_addrs (&network_rcp);
298 destroy_addrs (&local_rcp);
299 return rc;
300}
301
302int
303mh_whom_file (const char *filename, int check)
265{ 304{
@@ -274,3 +313,2 @@ mh_whom (const char *filename, int check)
274 { 313 {
275 size_t count = 0;
276 mu_header_t hdr; 314 mu_header_t hdr;