Allow MENU EXIT to specify a menu tag syslinux-3.62-pre15
authorH. Peter Anvin <hpa@zytor.com>
Fri, 22 Feb 2008 19:16:45 +0000 (11:16 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 22 Feb 2008 19:16:45 +0000 (11:16 -0800)
Allow MENU EXIT to "exit" to an arbitrary menu.  This is really just a
variant of "MENU GOTO", but it allows displaying an exit marker.

com32/menu/menu.h
com32/menu/readconfig.c
doc/menu.doc

index b1a98a2..b8c2868 100644 (file)
@@ -34,6 +34,8 @@
 
 struct menu;
 
+/* Note: the _UNRES variants must always be immediately after their
+   "normal" versions. */
 enum menu_action {
   MA_NONE,                     /* Undefined value */
   MA_CMD,                      /* Execute a command */
@@ -43,6 +45,7 @@ enum menu_action {
   MA_GOTO_UNRES,               /* Unresolved go to */
   MA_QUIT,                     /* Quit to CLI */
   MA_EXIT,                     /* Exit to higher-level menu */
+  MA_EXIT_UNRES,               /* Unresolved exit */
 };
 
 struct menu_entry {
index 65e230d..1020193 100644 (file)
@@ -348,6 +348,7 @@ record(struct menu *m, struct labeldata *ld, const char *append)
       break;
 
     case MA_GOTO_UNRES:
+    case MA_EXIT_UNRES:
       me->cmdline = refstr_get(ld->kernel);
       break;
 
@@ -763,9 +764,17 @@ static void parse_config_file(FILE *f)
          ld.kernel = refstrdup(skipspace(p+4));
        }
       } else if ( looking_at(p, "exit") ) {
+       p = skipspace(p+4);
        if (ld.label && m->parent) {
-         ld.action = MA_EXIT;
-         ld.submenu = m->parent;
+         if (*p) {
+           /* This is really just a goto, except for the marker */
+           ld.action = MA_EXIT_UNRES;
+           refstr_put(ld.kernel);
+           ld.kernel = refstrdup(p);
+         } else {
+           ld.action = MA_EXIT;
+           ld.submenu = m->parent;
+         }
        }
       } else if ( looking_at(p, "start") ) {
        start_menu = m;
@@ -912,13 +921,14 @@ static void resolve_gotos(void)
   struct menu *m;
 
   for (me = all_entries; me; me = me->next) {
-    if (me->action == MA_GOTO_UNRES) {
+    if (me->action == MA_GOTO_UNRES ||
+       me->action == MA_EXIT_UNRES) {
       m = find_menu(me->cmdline);
       refstr_put(me->cmdline);
       me->cmdline = NULL;
       if (m) {
        me->submenu = m;
-       me->action = MA_GOTO;
+       me->action--;           /* Drop the _UNRES */
       } else {
        me->action = MA_DISABLED;
       }
index fefd92c..aa161bc 100644 (file)
@@ -214,12 +214,13 @@ MENU GOTO tagname
        "menu goto .top".
 
 
-MENU EXIT
+MENU EXIT [tagname]
 
        (Only valid after a label statement inside MENU BEGIN ...
        MENU END)
 
-       Exit to the next higher menu.
+       Exit to the next higher menu, or, if tagname is specified, to
+       the named menu.
 
 
 MENU QUIT