All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marco Gerards <metgerards@student.han.nl>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] normal/cmdline.c : history contains empty lines
Date: Wed, 29 Dec 2004 19:31:13 +0000	[thread overview]
Message-ID: <87wtv0j3zy.fsf@marco.marco-g.com> (raw)
In-Reply-To: <41BE9159.7010500@yahoo.fr> (Vincent Pelletier's message of "Tue, 14 Dec 2004 08:08:09 +0100")

Vincent Pelletier <subdino2004@yahoo.fr> writes:

> Hi.
> Here is my first patch to grub2 :) .

Thanks. :)

> Changelog :
>
> 2004-12-13 Vincent Pelletier <subdino2004@yahoo.fr>
> * grub_history_get : doesn't add empty lines, exits if called with NULL
> argument
> * grub_cmdline_get : command is added to history after user hit
> "return", when pressing "down" arrow when on the most recent item in
> history an empty line is shown
>
> Vincent "Subdino" Pelletier

Your patch was kinda hard to comprehend, especially because you
rewrote grub_history_add.  And unfortunately it caused a segfault
here. :/

The main problem was in the logic of the history code.  I should be
terribly ashamed for doing it wrong like this in the first place.  I
made a fix to change the logic there, instead of in grub_history_add.
In the meanwhile I made it work just like bash, like Okuji requested.

Vincent, does this patch solve your problem?  I will commit it soon.

Thanks,
Marco



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>.


Index: normal/cmdline.c
===================================================================
RCS file: /cvsroot/grub/grub2/normal/cmdline.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 cmdline.c
--- normal/cmdline.c	13 Dec 2004 17:26:17 -0000	1.10
+++ normal/cmdline.c	29 Dec 2004 19:19:03 -0000
@@ -556,7 +556,8 @@ grub_cmdline_get (const char *prompt, ch
   
   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, ch
 		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, ch
 		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, ch
 	    }
 	  break;
 	}
-
-      grub_history_replace (histpos, buf);
     }
 
   grub_putchar ('\n');
@@ -736,6 +741,13 @@ grub_cmdline_get (const char *prompt, ch
     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;




  parent reply	other threads:[~2004-12-29 19:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-14  7:08 [PATCH] normal/cmdline.c : history contains empty lines Vincent Pelletier
2004-12-19 15:15 ` Yoshinori K. Okuji
2004-12-19 15:46   ` Vincent Pelletier
2004-12-19 15:59     ` Yoshinori K. Okuji
2004-12-29 19:31 ` Marco Gerards [this message]
2004-12-29 19:49   ` Vincent Pelletier
2004-12-29 21:06     ` Marco Gerards

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wtv0j3zy.fsf@marco.marco-g.com \
    --to=metgerards@student.han.nl \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.