Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NOys3-0000fV-Kv for mharc-grub-devel@gnu.org; Sun, 27 Dec 2009 14:33:43 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NOys0-0000ei-PJ for grub-devel@gnu.org; Sun, 27 Dec 2009 14:33:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NOyru-0000cm-K0 for grub-devel@gnu.org; Sun, 27 Dec 2009 14:33:39 -0500 Received: from [199.232.76.173] (port=47324 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOyru-0000cW-Co for grub-devel@gnu.org; Sun, 27 Dec 2009 14:33:34 -0500 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:34622 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NOyrt-0005fr-UD for grub-devel@gnu.org; Sun, 27 Dec 2009 14:33:34 -0500 Received: from pinux (unknown [192.168.0.78]) by mail.pina.cat (Postfix) with ESMTPA id F39A22894B244 for ; Sun, 27 Dec 2009 20:33:32 +0100 (CET) Received: by pinux (Postfix, from userid 1000) id 81D8F9147; Sun, 27 Dec 2009 20:33:32 +0100 (CET) Date: Sun, 27 Dec 2009 20:33:32 +0100 From: Carles Pina i Estany To: grub-devel@gnu.org Message-ID: <20091227193332.GA3907@pina.cat> References: <20091227190627.GA11737@pina.cat> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" Content-Disposition: inline In-Reply-To: <20091227190627.GA11737@pina.cat> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: help command X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Dec 2009 19:33:41 -0000 --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Dec/27/2009, Carles Pina i Estany wrote: > I'll fix soon (tonight / tomorrow). a patch idea is attached. Before all summaries was: COMMAND_NAME COMMAND_SUMMARY r1992 removed COMMAND_NAME from the COMMAND_SUMMARY (smaller, not redundant, etc.). But help without arguments was showing only COMMAND_SUMMARY. Now it shows the COMMAND_NAME concatenated with the summary. proposed patch is my natural approach. Alternatively one (tell me if you want) is using grub_memcpy two times (for cmd->name and summary_translated). I just like more the idea to format everything correctly and then copy checking the number of characters used. -- Carles Pina i Estany http://pinux.info --azLHFNyN32YCQGCU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="help.patch" === modified file 'ChangeLog' --- ChangeLog 2009-12-26 23:43:21 +0000 +++ ChangeLog 2009-12-27 19:30:55 +0000 @@ -1,5 +1,10 @@ 2009-12-27 Carles Pina i Estany + * commands/help.c: Inclue `grub/mm.h'. + (grub_cmd_help): Prepends cmd->name before cmd->summary. + +2009-12-27 Carles Pina i Estany + * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. * normal/main.c (grub_normal_read_line): Remove a space from the default prompt. === modified file 'commands/help.c' --- commands/help.c 2009-12-25 23:50:59 +0000 +++ commands/help.c 2009-12-27 19:28:44 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include static grub_err_t grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, @@ -40,15 +41,22 @@ grub_cmd_help (grub_extcmd_t ext __attri { char description[GRUB_TERM_WIDTH / 2]; const char* summary_translated = _(cmd->summary); - int desclen = grub_strlen (summary_translated); + int desclen = grub_strlen (cmd->name) + grub_strlen (" ") + + grub_strlen (summary_translated) + 1; + + char* help_line = grub_malloc (desclen); + grub_sprintf (help_line, "%s %s", cmd->name, summary_translated); + help_line[desclen-1] = ' '; /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled with the description followed by spaces. */ grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1); description[GRUB_TERM_WIDTH / 2 - 1] = '\0'; - grub_memcpy (description, summary_translated, + grub_memcpy (description, help_line, (desclen < GRUB_TERM_WIDTH / 2 - 1 ? desclen : GRUB_TERM_WIDTH / 2 - 1)); + + grub_free (help_line); grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " "); } --azLHFNyN32YCQGCU--