[syslinux:master] menu: allow "menu hiddenkey" to take multiple keys; run unlabel
syslinux-bot for H. Peter Anvin
hpa at linux.intel.com
Mon Apr 18 14:09:02 PDT 2011
Commit-ID: 830dd5801d9ab9347576ec7ab5c7427b247b67e4
Gitweb: http://syslinux.zytor.com/commit/830dd5801d9ab9347576ec7ab5c7427b247b67e4
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Mon, 18 Apr 2011 14:06:54 -0700
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Mon, 18 Apr 2011 14:06:54 -0700
menu: allow "menu hiddenkey" to take multiple keys; run unlabel
- Allow "menu hiddenkey" to take a comma-separated list of keys.
- Run unlabel() on the commands passed to menu hiddenkey.
XXX: Consider moving unlabelling to post-menu instead.
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
---
com32/menu/readconfig.c | 34 ++++++++++++++++++++++++++--------
doc/menu.txt | 9 ++++++---
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index fdf2e27..0ac2564 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -143,7 +143,7 @@ static char *looking_at(char *line, const char *kwd)
}
/* Get a single word into a new refstr; advances the input pointer */
-static char *get_word(char *str, const char **word)
+static char *get_word(char *str, char **word)
{
char *p = str;
char *q;
@@ -721,16 +721,27 @@ static void parse_config_file(FILE * f)
} else if ((ep = looking_at(p, "hidden"))) {
hiddenmenu = 1;
} else if (looking_at(p, "hiddenkey")) {
- const char *key_name;
+ char *key_name, *k, *ek;
+ const char *command;
int key;
p = get_word(skipspace(p + 9), &key_name);
- p = skipspace(p);
- key = key_name_to_code(key_name);
- refstr_put(key_name);
- if (key >= 0) {
- refstr_put(hide_key[key]);
- hide_key[key] = refstrdup(skipspace(p));
+ command = refstrdup(skipspace(p));
+ k = key_name;
+ for (;;) {
+ ek = strchr(k+1, ',');
+ if (ek)
+ *ek = '\0';
+ key = key_name_to_code(k);
+ if (key >= 0) {
+ refstr_put(hide_key[key]);
+ hide_key[key] = refstr_get(command);
+ }
+ if (!ek)
+ break;
+ k = ek+1;
}
+ refstr_put(key_name);
+ refstr_put(command);
} else if ((ep = looking_at(p, "clear"))) {
clearmenu = 1;
} else if ((ep = is_message_name(p, &msgnr))) {
@@ -1064,6 +1075,7 @@ void parse_configs(char **argv)
const char *filename;
struct menu *m;
struct menu_entry *me;
+ int k;
empty_string = refstrdup("");
@@ -1125,4 +1137,10 @@ void parse_configs(char **argv)
if (m->onerror)
m->onerror = unlabel(m->onerror);
}
+
+ /* Final global initialization, with all labels known */
+ for (k = 0; k < KEY_MAX; k++) {
+ if (hide_key[k])
+ hide_key[k] = unlabel(hide_key[k]);
+ }
}
diff --git a/doc/menu.txt b/doc/menu.txt
index 892de48..620527e 100644
--- a/doc/menu.txt
+++ b/doc/menu.txt
@@ -48,7 +48,7 @@ MENU HIDDEN
All that is displayed is a timeout message.
-MENU HIDDENKEY key command...
+MENU HIDDENKEY key[,key...] command...
If they key used to interrupt MENU HIDDEN is <key>, then
execute the specified command instead of displaying the menu.
@@ -61,8 +61,11 @@ MENU HIDDENKEY key command...
... in addition to all single characters plus the syntax ^X
for Ctrl-X. Note that single characters are treated as case
sensitive, so a different command can be bound to "A" than
- "a".
-
+ "a". One can bind the same command to multiple keys by giving
+ a comma-separated list of keys:
+
+ menu hiddenkey A,a key_a_command
+
MENU CLEAR
More information about the Syslinux-commits
mailing list