[syslinux:elflink] CLI: Delete 'temp_cmdline' and put 'cmdline' on the stack

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Nov 29 09:03:04 PST 2012


Commit-ID:  2080029baa13b5b8d8b94ae1dc27ce4ea82b5397
Gitweb:     http://www.syslinux.org/commit/2080029baa13b5b8d8b94ae1dc27ce4ea82b5397
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 29 Nov 2012 16:55:33 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 29 Nov 2012 16:58:02 +0000

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 at intel.com>

---
 com32/elflink/ldlinux/cli.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index 6d03f16..472eb2f 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;


More information about the Syslinux-commits mailing list