summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,4 +1,4 @@
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.
3See the end of file for copying conditions. 3See the end of file for copying conditions.
4 4
@@ -75,6 +75,13 @@ value is anything but "no", the settings from the global "tls" section
75will be used. In this case, it is an error if the global "tls" 75will be used. In this case, it is an error if the global "tls"
76section is not defined. 76section 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
79 86
80Required version must be literal string. 87Required version must be literal string.
diff --git a/mh/comp.c b/mh/comp.c
index 075bb4516..29389c69e 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -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
130static struct mh_optinit optinit[] = {
131 { "draftfolder", "Draft-Folder" },
132 { "whatnowproc", "whatnowproc" },
133 { NULL }
134};
135
130int 136int
131main (int argc, char **argv) 137main (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";
diff --git a/mh/forw.c b/mh/forw.c
index 5e0e08b97..016ac84bc 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -377,17 +377,19 @@ finish_draft ()
377 mu_stream_destroy (&stream); 377 mu_stream_destroy (&stream);
378} 378}
379 379
380static struct mh_optinit optinit[] = {
381 { "draftfolder", "Draft-Folder" },
382 { "whatnowproc", "whatnowproc" },
383 { NULL }
384};
385
380int 386int
381main (int argc, char **argv) 387main (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
diff --git a/mh/mh.h b/mh/mh.h
index 69be72de2..76bc85e37 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -342,7 +342,11 @@ int mh_usedraft (const char *filename);
342int mh_file_copy (const char *from, const char *to); 342int mh_file_copy (const char *from, const char *to);
343char *mh_draft_name (void); 343char *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);
347int mh_decode_2047 (char *text, char **decoded_text); 351int mh_decode_2047 (char *text, char **decoded_text);
348const char *mh_charset (const char *); 352const char *mh_charset (const char *);
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
@@ -502,6 +502,9 @@ int
502mh_read_aliases (void) 502mh_read_aliases (void)
503{ 503{
504 const char *p; 504 const char *p;
505
506 if (alias_list)
507 return 0;
505 508
506 p = mh_global_profile_get ("Aliasfile", NULL); 509 p = mh_global_profile_get ("Aliasfile", NULL);
507 if (p) 510 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
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{
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
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)
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
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
27void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, 36void 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,