help command
Hi,
help command (without any argument) is broken since r1992.
I'll fix soon (tonight / tomorrow).
Signature · 2 lines
Carles Pina i Estany http://pinux.info
Hi,
Quoted 1 line · Carles Pina i Estany
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.
Signature · 2 lines
Carles Pina i Estany http://pinux.info
=== modified file 'ChangeLog'
ChangeLog +5 -0
@@ -1,5 +1,10 @@ 2009-12-27 Carles Pina i Estany <[email protected]> + * commands/help.c: Inclue `grub/mm.h'. + (grub_cmd_help): Prepends cmd->name before cmd->summary. + +2009-12-27 Carles Pina i Estany <[email protected]> + * 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'
help.c +10 -2
@@ -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" :" " ); }