aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/cli.c
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-29 16:55:33 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-29 16:58:02 +0000
commit2080029baa13b5b8d8b94ae1dc27ce4ea82b5397 (patch)
tree4540faf18f93443dff70fc9e9fe47fd4a4d4d830 /com32/elflink/ldlinux/cli.c
parent8f1c64acf9c60d184fef37f373737895468c0771 (diff)
downloadsyslinux-2080029baa13b5b8d8b94ae1dc27ce4ea82b5397.tar.gz
syslinux-2080029baa13b5b8d8b94ae1dc27ce4ea82b5397.tar.xz
syslinux-2080029baa13b5b8d8b94ae1dc27ce4ea82b5397.zip
CLI: Delete 'temp_cmdline' and put 'cmdline' on the stack
We don't need to preserve the contents of 'cmdline' across calls to edit_cmdline(). In fact, doing so causes things like the TAB key to not function properly because the previous command is used as a prefix to print_labels(), as though the user had typed it explicitly before hitting TAB. Delete 'temp_cmdline' because it no longer serves a purpose. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink/ldlinux/cli.c')
-rw-r--r--com32/elflink/ldlinux/cli.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index 6d03f16b..472eb2f7 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -121,8 +121,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
int (*pDraw_Menu) (int, int, int),
void (*show_fkey) (int), bool *timedout)
{
- static char cmdline[MAX_CMDLINE_LEN];
- char temp_cmdline[MAX_CMDLINE_LEN] = { };
+ char cmdline[MAX_CMDLINE_LEN] = { };
int key, len, prev_len, cursor;
int redraw = 1; /* We enter with the menu already drawn */
int x, y;
@@ -139,8 +138,6 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
width = 80;
}
- cmdline[MAX_CMDLINE_LEN - 1] = '\0';
-
len = cursor = 0;
prev_len = 0;
x = y = 0;
@@ -346,11 +343,9 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
comm_counter =
list_entry(next, typeof(*comm_counter), list);
- if (&comm_counter->list == &cli_history_head) {
- strcpy(cmdline, temp_cmdline);
- } else {
+ if (&comm_counter->list != &cli_history_head)
strcpy(cmdline, comm_counter->command);
- }
+
cursor = len = strlen(cmdline);
redraw = 1;
}
@@ -370,11 +365,9 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
comm_counter =
list_entry(prev, typeof(*comm_counter), list);
- if (&comm_counter->list == &cli_history_head) {
- strcpy(cmdline, temp_cmdline);
- } else {
+ if (&comm_counter->list != &cli_history_head)
strcpy(cmdline, comm_counter->command);
- }
+
cursor = len = strlen(cmdline);
redraw = 1;
}
@@ -430,9 +423,8 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
default:
if (key >= ' ' && key <= 0xFF && len < MAX_CMDLINE_LEN - 1) {
if (cursor == len) {
- temp_cmdline[len] = key;
cmdline[len++] = key;
- temp_cmdline[len] = cmdline[len] = '\0';
+ cmdline[len] = '\0';
putchar(key);
cursor++;
x++;
@@ -445,9 +437,6 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
} else {
memmove(cmdline + cursor + 1, cmdline + cursor,
len - cursor + 1);
- memmove(temp_cmdline + cursor + 1, temp_cmdline + cursor,
- len - cursor + 1);
- temp_cmdline[cursor] = key;
cmdline[cursor++] = key;
len++;
redraw = 1;