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
=== 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  <car...@pina.cat>
 
+	* commands/help.c: Inclue `grub/mm.h'.
+	(grub_cmd_help): Prepends cmd->name before cmd->summary.
+
+2009-12-27  Carles Pina i Estany  <car...@pina.cat>
+
 	* 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 <grub/term.h>
 #include <grub/extcmd.h>
 #include <grub/i18n.h>
+#include <grub/mm.h>
 
 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" : " ");
 	}

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel
  • help command Carles Pina i Estany
    • Re: help command Carles Pina i Estany

Reply via email to