From 6b8fd1c42890aac0d8e8ba6a477ab3a32aa8a890 Mon Sep 17 00:00:00 2001 From: marco_g Date: Wed, 29 Dec 2004 22:43:48 +0000 Subject: [PATCH] 2004-12-29 Marco Gerards * normal/cmdline.c (grub_cmdline_get): Redone logic so no empty lines are inserted and make it work like readline. Reported by Vincent Pelletier . --- ChangeLog | 6 ++++++ normal/cmdline.c | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8121eff4..230814114 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-29 Marco Gerards + + * normal/cmdline.c (grub_cmdline_get): Redone logic so no empty + lines are inserted and make it work like readline. Reported by + Vincent Pelletier . + 2004-12-28 Marco Gerards * boot/powerpc/ieee1275/crt0.S (_start): Don't set up the stack. diff --git a/normal/cmdline.c b/normal/cmdline.c index dc9d68bc3..5088532ad 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -556,7 +556,8 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, cl_insert (cmdline); - grub_history_add (buf); + if (hist_used == 0) + grub_history_add (buf); while ((key = GRUB_TERM_ASCII_CHAR (grub_getkey ())) != '\n' && key != '\r') { @@ -641,7 +642,10 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, lpos = 0; if (histpos > 0) - histpos--; + { + grub_history_replace (histpos, buf); + histpos--; + } cl_delete (llen); hist = grub_history_get (histpos); @@ -656,7 +660,10 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, lpos = 0; if (histpos < hist_used - 1) - histpos++; + { + grub_history_replace (histpos, buf); + histpos++; + } cl_delete (llen); hist = grub_history_get (histpos); @@ -723,8 +730,6 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, } break; } - - grub_history_replace (histpos, buf); } grub_putchar ('\n'); @@ -736,6 +741,13 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, while (buf[lpos] == ' ') lpos++; + histpos = 0; + if (grub_strlen (buf) > 0) + { + grub_history_replace (histpos, buf); + grub_history_add (""); + } + grub_memcpy (cmdline, buf + lpos, llen - lpos + 1); return 1;