]> granicus.if.org Git - neomutt/commitdiff
Make exec grok >= 1 parameters; fix double ops problem in
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 5 Oct 1998 20:25:40 +0000 (20:25 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 5 Oct 1998 20:25:40 +0000 (20:25 +0000)
index_menu().

curs_lib.c
curs_main.c
keymap.c

index cc07bcc1eebf3bdd2c74910bcd83849fb6be91a5..fe1533986001a715c2be46be833b707f2f6eb6a9 100644 (file)
@@ -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]);
index 3175c432e1f61efd94b8eb7380745f3db36948cd..0927d3753e2565df9e256cd85e2a376675800ad2 100644 (file)
@@ -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);
       
index 29fb1b0a03151277b33eea2e04b85a0449ddef4b..c72213f541709d6504040c25391e6407803e0747 100644 (file)
--- 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;
 }