Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1Cjjkg-0005aq-HQ for mharc-grub-devel@gnu.org; Wed, 29 Dec 2004 14:44:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Cjjkd-0005Zi-GW for grub-devel@gnu.org; Wed, 29 Dec 2004 14:44:55 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Cjjka-0005YR-OD for grub-devel@gnu.org; Wed, 29 Dec 2004 14:44:52 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Cjjka-0005Y2-IZ for grub-devel@gnu.org; Wed, 29 Dec 2004 14:44:52 -0500 Received: from [145.74.66.11] (helo=mail-cn.han.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CjjY2-0006m1-HF for grub-devel@gnu.org; Wed, 29 Dec 2004 14:31:54 -0500 Received: from vscan-ca.han.nl (mars.han.nl [145.74.129.116]) by mail-cn.han.nl (Postfix) with ESMTP id 151289E99 for ; Wed, 29 Dec 2004 20:31:54 +0100 (CET) Received: from mail-cn.han.nl ([145.74.66.51]) by vscan-ca.han.nl (mars.han.nl [145.74.129.116]) (amavisd-new, port 10024) with LMTP id 16918-01-7 for ; Wed, 29 Dec 2004 20:31:51 +0100 (CET) Received: from mail1.han.nl (mail1.han.nl [145.74.103.11]) by mail-cn.han.nl (Postfix) with ESMTP id 048DD9BA5 for ; Wed, 29 Dec 2004 20:31:51 +0100 (CET) Received: from marco.marco-g.com (mgerards.xs4all.nl [82.92.27.129]) by mail1.han.nl (Postfix) with ESMTP id B81EBC046 for ; Wed, 29 Dec 2004 20:31:50 +0100 (CET) Mail-Copies-To: metgerards@student.han.nl To: The development of GRUB 2 References: <41BE9159.7010500@yahoo.fr> From: Marco Gerards Date: Wed, 29 Dec 2004 19:31:13 +0000 In-Reply-To: <41BE9159.7010500@yahoo.fr> (Vincent Pelletier's message of "Tue, 14 Dec 2004 08:08:09 +0100") Message-ID: <87wtv0j3zy.fsf@marco.marco-g.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new (2.2.0) at vscan-ca.han.nl Subject: Re: [PATCH] normal/cmdline.c : history contains empty lines X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2004 19:44:56 -0000 Vincent Pelletier writes: > Hi. > Here is my first patch to grub2 :) . Thanks. :) > Changelog : > > 2004-12-13 Vincent Pelletier > * 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 * normal/cmdline.c (grub_cmdline_get): Redone logic so no empty lines are inserted and make it work like readline. Reported by Vincent Pelletier . 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;