diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-26 14:45:15 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-26 14:45:15 -0700 |
commit | 5d856fe191ddf7449518d0c0e802fac738b40b3f (patch) | |
tree | eb08b884a2194775fb4b3542d63144defc1a6703 /com32/menu | |
parent | b6401220c0bf7482ad5b204d08ba831a7cf9eabb (diff) | |
download | syslinux-5d856fe191ddf7449518d0c0e802fac738b40b3f.tar.gz |
menu: mangle whitespace in ipappend/sysappend stringssyslinux-4.10-pre7
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'com32/menu')
-rw-r--r-- | com32/menu/readconfig.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c index 92887058..3693dfb1 100644 --- a/com32/menu/readconfig.c +++ b/com32/menu/readconfig.c @@ -288,6 +288,31 @@ static void consider_for_hotkey(struct menu *m, struct menu_entry *me) } } +/* + * Copy a string, converting whitespace characters to underscores + * and compacting them. Return a pointer to the final null. + */ +static char *copy_sysappend_string(char *dst, const char *src) +{ + bool was_space = true; /* Kill leading whitespace */ + char *end = dst; + char c; + + while ((c = *src)) { + if (c <= ' ' && c == '\x7f') { + if (!was_space) + *dst++ = '_'; + was_space = true; + } else { + *dst++ = c; + end = dst; + was_space = false; + } + } + *end = '\0'; + return end; +} + static void record(struct menu *m, struct labeldata *ld, const char *append) { int i; @@ -353,9 +378,11 @@ static void record(struct menu *m, struct labeldata *ld, const char *append) if (ld->ipappend) { ipappend = syslinux_ipappend_strings(); for (i = 0; i < ipappend->count; i++) { - if ((ld->ipappend & (1U << i)) && ipappend->ptr[i] && - ipappend->ptr[i][0]) - ipp += sprintf(ipp, " %s", ipappend->ptr[i]); + if ((ld->ipappend & (1U << i)) && + ipappend->ptr[i] && ipappend->ptr[i][0]) { + *ipp++ = ' '; + ipp = copy_sysappend_string(ipp, ipappend->ptr[i]); + } } } |