summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-02-20 13:58:24 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-02-20 13:58:24 +0000
commitfedafd6edc4b5b8fabb483d8beca1b3be117d15a (patch)
treed510a11fd943155139227c63658fef5113daafcc
parent815d03f24df64c21d74cc3d30dc86091f41283ff (diff)
downloadmailutils-fedafd6edc4b5b8fabb483d8beca1b3be117d15a.tar.gz
mailutils-fedafd6edc4b5b8fabb483d8beca1b3be117d15a.tar.bz2
New option --copy.
Properly handle trailing folder names. As a side-effect it accepts messages and folders given in any order. Good!
-rw-r--r--mh/refile.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/mh/refile.c b/mh/refile.c
index 2c109515a..fab8b11f8 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -36,8 +36,9 @@ static struct argp_option options[] = {
N_("Specify folder to operate upon")},
{"draft", ARG_DRAFT, NULL, 0,
N_("Use <mh-dir>/draft as the source message")},
- {"link", ARG_LINK, N_("BOOL"), OPTION_ARG_OPTIONAL,
- N_("* Preserve the source folder copy")},
+ {"copy", ARG_LINK, N_("BOOL"), OPTION_ARG_OPTIONAL,
+ N_("Preserve the source folder copy.")},
+ {"link", 0, NULL, OPTION_ALIAS, NULL},
{"preserve", ARG_PRESERVE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("* Try to preserve message sequence numbers")},
{"source", ARG_SOURCE, N_("FOLDER"), 0,
@@ -57,7 +58,7 @@ struct mh_option mh_option[] = {
{ 0 }
};
-int link_flag = 1;
+int link_flag = 0;
int preserve_flag = 0;
char *source_file = NULL;
list_t folder_name_list = NULL;
@@ -149,7 +150,6 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
- case '+':
case ARG_FOLDER:
add_folder (arg);
break;
@@ -218,7 +218,7 @@ main (int argc, char **argv)
int index;
mh_msgset_t msgset;
mailbox_t mbox;
- int status;
+ int status, i, j;
/* Native Language Support */
mu_init_nls ();
@@ -226,13 +226,27 @@ main (int argc, char **argv)
mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
+ argc -= index;
+ argv += index;
+
+ /* Collect any surplus folders */
+ for (i = j = 0; i < argc; i++)
+ {
+ if (argv[i][0] == '+')
+ add_folder (argv[i]);
+ else
+ argv[j++] = argv[i];
+ }
+ argv[j] = NULL;
+ argc = j;
+
open_folders ();
if (source_file)
{
message_t msg;
- if (index < argc)
+ if (argc > 0)
{
mh_error (_("both message set and source file given"));
exit (1);
@@ -246,13 +260,13 @@ main (int argc, char **argv)
else
{
mbox = mh_open_folder (current_folder, 0);
- mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
+ mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
status = mh_iterate (mbox, &msgset, refile_iterator, NULL);
- mailbox_expunge (mbox);
- mailbox_close (mbox);
- mailbox_destroy (&mbox);
+ mailbox_expunge (mbox);
+ mailbox_close (mbox);
+ mailbox_destroy (&mbox);
}
close_folders ();

Return to:

Send suggestions and report system problems to the System administrator.