Allow an included file to be treated as a submenu.
authorH. Peter Anvin <hpa@zytor.com>
Wed, 20 Feb 2008 00:37:50 +0000 (16:37 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 20 Feb 2008 00:51:24 +0000 (16:51 -0800)
com32/menu/readconfig.c
doc/menu.doc

index c3f2da4..e94fddf 100644 (file)
@@ -599,8 +599,7 @@ static void parse_config_file(FILE *f)
          m->menu_master_passwd = refstrdup(skipspace(p+6));
        }
       } else if ( (ep = looking_at(p, "include")) ) {
-       p = skipspace(ep);
-       parse_one_config(p);
+       goto do_include;
       } else if ( (ep = looking_at(p, "background")) ) {
        p = skipspace(ep);
        refstr_put(m->menu_background);
@@ -781,8 +780,23 @@ static void parse_config_file(FILE *f)
        m->fkeyhelp[fkeyno].background = refdup_word(&p);
       }
     } else if ( (ep = looking_at(p, "include")) ) {
-      p = skipspace(ep);
-      parse_one_config(p);
+    do_include:
+      {
+       const char *file;
+       p = skipspace(ep);
+       file = refdup_word(&p);
+       p = skipspace(p);
+       if (*p) {
+         record(m, &ld, append);
+         m = current_menu = begin_submenu(p);
+         parse_one_config(file);
+         record(m, &ld, append);
+         m = current_menu = end_submenu();
+       } else {
+         parse_one_config(file);
+       }
+       refstr_put(file);
+      }
     } else if ( looking_at(p, "append") ) {
       const char *a = refstrdup(skipspace(p+6));
       if ( ld.label ) {
index d3c211f..3b95a03 100644 (file)
@@ -225,8 +225,8 @@ MENU QUIT
        PASSWD can of course be set for this label.
        
 
-INCLUDE filename
-MENU INCLUDE filename
+INCLUDE filename [tagname]
+MENU INCLUDE filename [tagname]
 
        Include the contents of the configuration file filename at
        this point.
@@ -235,6 +235,10 @@ MENU INCLUDE filename
        the menu system; the core syslinux code does not parse this
        command, so any labels defined in it are unavailable.
 
+       If a tagname is included, the whole file is considered to have
+       been bracketed with a MENU BEGIN tagname ... MENU END pair,
+       and will therefore show up as a submenu.
+
 
 MENU AUTOBOOT message