Allow more than one line in option help text
PATCH 1/1 Allow more than one line in option help text
This small patch allows '\n' in option help texts, for example:
static const struct grub_arg_option options[] = {
{"very-complex", 'c', 0,
"sorry, but this very complex option requires more\n" "than one line to explain properly.", 0, 0},
...
};
grub> complex -h
...
-c, --very-complex sorry, but this very complex option requires more
. than one line to explain properly.
I need it for a new module :-)
Christian
2009-01-23 Christian Franke <[email protected]>
* normal/arg.c (grub_arg_show_help): Add indentation if '\n' appears in option help text.
normal/arg.c +14 -3
@@ -156,10 +156,21 @@ grub_arg_show_help (grub_command_t cmd) } } -while (spacing-- >0 ) -grub_putchar (' ' ); +const char * doc = opt->doc; +for (;;) + { +while (spacing-- >0 ) +grub_putchar (' ' ); + +const char * nl =grub_strchr (doc,'\n' ); +if (! nl) +break ; -grub_printf ("%s\n" , opt->doc); +while (doc <= nl) +grub_putchar (*doc++); + spacing =4 +20 ; + } +grub_printf ("%s\n" , doc);switch (opt->shortarg) {
Quoted 1 line · Christian Franke
This small patch allows '\n' in option help texts, for example:
Patch simplified & committed.
Christian