]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2004-12-29 Marco Gerards <metgerards@student.han.nl>
authormarco_g <marco_g@localhost>
Wed, 29 Dec 2004 22:43:48 +0000 (22:43 +0000)
committermarco_g <marco_g@localhost>
Wed, 29 Dec 2004 22:43:48 +0000 (22:43 +0000)
* normal/cmdline.c (grub_cmdline_get): Redone logic so no empty
lines are inserted and make it work like readline.  Reported by
Vincent Pelletier <subdino2004@yahoo.fr>.

ChangeLog
normal/cmdline.c

index d8121eff4ad9d53dc46f29e22ff22957f0339c2c..230814114f50544f0ff5cd9a47543f5b7bbc7832 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-29  Marco Gerards  <metgerards@student.han.nl>
+
+       * normal/cmdline.c (grub_cmdline_get): Redone logic so no empty
+       lines are inserted and make it work like readline.  Reported by
+       Vincent Pelletier <subdino2004@yahoo.fr>.
+
 2004-12-28  Marco Gerards  <metgerards@student.han.nl>
 
        * boot/powerpc/ieee1275/crt0.S (_start): Don't set up the stack.
index dc9d68bc38be955fe5b96ee0cd199bf3530b065c..5088532ad562e2833da5cc01961b7b9820603660 100644 (file)
@@ -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;