[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Mailutils branch, master, updated. release-3.1.1-8-gfb8195c
From: |
Sergey Poznyakoff |
Subject: |
[SCM] GNU Mailutils branch, master, updated. release-3.1.1-8-gfb8195c |
Date: |
Mon, 19 Dec 2016 14:23:08 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".
http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=fb8195c07ba6c6a3afa7da1f028410723e9073a4
The branch, master has been updated
via fb8195c07ba6c6a3afa7da1f028410723e9073a4 (commit)
from 8ce3063351c0139d8f1fa1c30d5c8de28050883e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fb8195c07ba6c6a3afa7da1f028410723e9073a4
Author: Sergey Poznyakoff <address@hidden>
Date: Mon Dec 19 16:13:02 2016 +0200
Fix fb84d1e3
The commit didn't take into account all possible option/argument
combinations.
* mh/pick.c (main): Preprocess command line prior to parsing it,
expanding --COMP NAME in -component COMP -pattern NAME.
* mh/mh_getopt.c: Revert fb84d1e3
* mh/mh_getopt.h: Likewise.
-----------------------------------------------------------------------
Summary of changes:
mh/mh_getopt.c | 47 ++++++++---------------------------------------
mh/mh_getopt.h | 5 -----
mh/pick.c | 50 +++++++++++++++++++++++++++++++++-----------------
3 files changed, 41 insertions(+), 61 deletions(-)
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c
index 211f57f..0e7ec3c 100644
--- a/mh/mh_getopt.c
+++ b/mh/mh_getopt.c
@@ -178,11 +178,9 @@ has_folder_option (struct mu_option *opt)
}
void
-mh_getopt0 (int *pargc, char ***pargv, struct mu_option *options,
- int mhflags,
- char *argdoc, char *progdoc, char *extradoc,
- int (*eatarg) (int argc, char **argv, void *data),
- void *data)
+mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
+ int mhflags,
+ char *argdoc, char *progdoc, char *extradoc)
{
int argc = *pargc;
char **argv = *pargv;
@@ -199,9 +197,6 @@ mh_getopt0 (int *pargc, char ***pargv, struct mu_option
*options,
po.po_negation = "no";
flags |= MU_PARSEOPT_NEGATION;
- if (eatarg)
- flags |= MU_PARSEOPT_IN_ORDER;
-
if ((mhflags & MH_GETOPT_DEFAULT_FOLDER) || has_folder_option (options))
{
po.po_special_args = N_("[+FOLDER]");
@@ -259,29 +254,12 @@ mh_getopt0 (int *pargc, char ***pargv, struct mu_option
*options,
if (options)
optv[i++] = options;
optv[i] = NULL;
+
+ if (mu_parseopt (&po, argc, argv, optv, flags))
+ exit (po.po_exit_error);
- do
- {
- if (mu_parseopt (&po, argc, argv, optv, flags))
- exit (po.po_exit_error);
- argc -= po.po_arg_start;
- argv += po.po_arg_start;
- if (eatarg)
- {
- int consumed = eatarg (argc, argv, data);
- if (consumed == 0)
- break;
- else
- {
- argc -= consumed;
- argv += consumed;
- }
- flags |= MU_PARSEOPT_ARGV0;
- }
- else
- break;
- }
- while (argc > 0);
+ argc -= po.po_arg_start;
+ argv += po.po_arg_start;
process_std_options (argc, argv, &po);
@@ -305,15 +283,6 @@ mh_getopt0 (int *pargc, char ***pargv, struct mu_option
*options,
}
void
-mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
- int mhflags,
- char *argdoc, char *progdoc, char *extradoc)
-{
- return mh_getopt0 (pargc, pargv, options, mhflags, argdoc, progdoc, extradoc,
- NULL, NULL);
-}
-
-void
mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
{
mu_error (_("option is not yet implemented: %s"), opt->opt_long);
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index 93d1d34..2dcd57a 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -23,11 +23,6 @@
void mh_getopt (int *pargc, char ***pargv, struct mu_option *options,
int flags,
char *argdoc, char *progdoc, char *extradoc);
-void mh_getopt0 (int *pargc, char ***pargv, struct mu_option *options,
- int mhflags,
- char *argdoc, char *progdoc, char *extradoc,
- int (*eatarg) (int argc, char **argv, void *data),
- void *data);
void mh_opt_notimpl (struct mu_parseopt *po, struct mu_option *opt,
char const *arg);
diff --git a/mh/pick.c b/mh/pick.c
index baf1ff8..37fa0da 100644
--- a/mh/pick.c
+++ b/mh/pick.c
@@ -260,28 +260,44 @@ parse_comp_match (int *pargc, char **argv)
*pargc = j;
}
-static int
-comp_match_arg (int argc, char **argv, void *data)
-{
- if (argc >= 2 && strncmp (argv[0], "--", 2) == 0)
- {
- mu_list_t *lp = data;
- pick_add_token (lp, T_COMP, argv[0] + 2);
- pick_add_token (lp, T_STRING, argv[1]);
- return 2;
- }
- return 0;
-}
-
int
main (int argc, char **argv)
{
- int status;
+ int i, status;
mu_mailbox_t mbox;
mu_msgset_t msgset;
-
- mh_getopt0 (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER,
- args_doc, prog_doc, NULL, comp_match_arg, &lexlist);
+ int argv_alloc = 0;
+
+ for (i = 1; i < argc;)
+ {
+ if (strncmp (argv[i], "--", 2) == 0 && argv[i][3] && i + 1 < argc)
+ {
+ size_t n = argc + 2;
+ if (argv_alloc)
+ argv = mu_realloc (argv, (n + 1) * sizeof (argv[0]));
+ else
+ {
+ char **p = mu_calloc (n + 1, sizeof p[0]);
+ memcpy (p, argv, (argc + 1) * sizeof argv[0]);
+ argv = p;
+ argv_alloc = 1;
+ }
+
+ memmove (argv + i + 4, argv + i + 2,
+ (argc - i - 1) * sizeof argv[0]);
+ argv[i + 3] = argv[i + 1];
+ argv[i + 2] = mu_strdup ("-pattern");
+ argv[i + 1] = mu_strdup (argv[i] + 2);
+ argv[i] = mu_strdup ("-component");
+ argc = n;
+ i += 4;
+ }
+ else
+ i++;
+ }
+
+ mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER,
+ args_doc, prog_doc, NULL);
parse_comp_match (&argc, argv);
hooks/post-receive
--
GNU Mailutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Mailutils branch, master, updated. release-3.1.1-8-gfb8195c,
Sergey Poznyakoff <=