From f2f56ec6fefdca92665644b693f4af1e5693757a Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Mon, 5 Oct 1998 20:25:40 +0000 Subject: [PATCH] Make exec grok >= 1 parameters; fix double ops problem in index_menu(). --- curs_lib.c | 2 +- curs_main.c | 14 +++++++++++++- keymap.c | 53 ++++++++++++++++++++++++++--------------------------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/curs_lib.c b/curs_lib.c index cc07bcc1e..fe1533986 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -48,7 +48,7 @@ void mutt_refresh (void) event_t mutt_getch (void) { int ch; - event_t err = {-1,0}, ret; + event_t err = {-1, OP_NULL }, ret; if (UngetCount) return (KeyEvent[--UngetCount]); diff --git a/curs_main.c b/curs_main.c index 3175c432e..0927d3753 100644 --- a/curs_main.c +++ b/curs_main.c @@ -242,7 +242,7 @@ int mutt_index_menu (void) { char buf[LONG_STRING], helpstr[SHORT_STRING]; int op = OP_NULL; - event_t event = {OP_NULL, 0}; + event_t event = {-1, 0}; int done = 0; /* controls when to exit the "event" loop */ int i = 0, j; int tag = 0; /* has the tag-prefix command been pressed? */ @@ -477,15 +477,27 @@ int mutt_index_menu (void) { timeout (Timeout * 1000); /* milliseconds */ event = mutt_getch (); + dprint(1, (debugfile, "mutt_index_menu[%d]: Got event (%d, %d)\n", __LINE__, + event.ch, event.op)); timeout (-1); /* restore blocking operation */ if (event.ch != -1) { + dprint(1, (debugfile, "mutt_index_menu[%d]: Pushing event (%d, %d)\n", __LINE__, + event.ch, event.op)); mutt_ungetch (event.ch, event.op); op = km_dokey (MENU_MAIN); + dprint(1, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, + op)); } + else + op = -1; } else + { op = km_dokey (MENU_MAIN); + dprint(1, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, + op)); + } mutt_curs_set (1); diff --git a/keymap.c b/keymap.c index 29fb1b0a0..c72213f54 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; } -- 2.40.0