summaryrefslogtreecommitdiffstats
path: root/keymap.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-10-05 20:25:40 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-10-05 20:25:40 +0000
commit04a38530367ac964b340b402d7672aea415c32d0 (patch)
tree6b01ce4a4eee4786b96a26c3b067d565e9d937ca /keymap.c
parent7d17a26a61d921b3cd788da01101dbcf4fecbe92 (diff)
Make exec grok >= 1 parameters; fix double ops problem in
index_menu().
Diffstat (limited to 'keymap.c')
-rw-r--r--keymap.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/keymap.c b/keymap.c
index 29fb1b0a..c72213f5 100644
--- a/keymap.c
+++ b/keymap.c
@@ -790,41 +790,40 @@ int mutt_parse_macro (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
/* exec command-name */
int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
- int op = OP_NULL;
- char *command = NULL;
+ int ops[128];
+ int nops = 0;
struct binding_t *bindings = NULL;
-
+ char *command;
+
if (!MoreArgs (s))
{
strfcpy (err->data, _("exec: too few arguments"), err->dsize);
return (-1);
}
- mutt_extract_token (buf, s, 0);
- command = safe_strdup (buf->data);
-
- if (MoreArgs (s))
- {
- strfcpy (err->data, _("too many arguments"), err->dsize);
- return (-1);
- }
-
- if ((bindings = km_get_table (CurrentMenu)) == NULL)
- bindings = OpGeneric;
-
- op = get_op (bindings, command, strlen(command));
- if (op == OP_NULL)
- op = get_op (OpGeneric, command, strlen(command));
-
- if (op == OP_NULL)
+ do
{
- mutt_flushinp ();
- mutt_error (_("%s: no such command"), command);
- FREE (&command);
- return (-1);
+ mutt_extract_token (buf, s, 0);
+ command = buf->data;
+
+ if ((bindings = km_get_table (CurrentMenu)) == NULL)
+ bindings = OpGeneric;
+
+ ops[nops] = get_op (bindings, command, strlen(command));
+ if (ops[nops] == OP_NULL)
+ ops[nops] = get_op (OpGeneric, command, strlen(command));
+
+ if (ops[nops] == OP_NULL)
+ {
+ mutt_flushinp ();
+ mutt_error (_("%s: no such command"), command);
+ return (-1);
+ }
}
-
- mutt_ungetch (0, op);
- FREE (&command);
+ while(MoreArgs(s) && ++nops < sizeof(ops)/sizeof(ops[0]));
+
+ while(nops)
+ mutt_ungetch(0, ops[--nops]);
+
return 0;
}