From ab14a5821210215ae91cad02ca547062efd8b5b0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 28 Feb 2013 11:00:59 +0100 Subject: [PATCH 169/482] * grub-core/lib/arg.c (grub_arg_show_help): Move showargs out of its parent. --- ChangeLog | 5 +++ grub-core/lib/arg.c | 99 +++++++++++++++++++++++++++-------------------------- 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6601c42..21ec9a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2013-02-28 Vladimir Serbinenko + * grub-core/lib/arg.c (grub_arg_show_help): Move showargs + out of its parent. + +2013-02-28 Vladimir Serbinenko + * grub-core/fs/jfs.c: Remove nested functions. 2013-02-28 Vladimir Serbinenko diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c index a2d9416..da44e30 100644 --- a/grub-core/lib/arg.c +++ b/grub-core/lib/arg.c @@ -109,69 +109,70 @@ show_usage (grub_extcmd_t cmd) grub_printf ("%s %s %s\n", _("Usage:"), cmd->cmd->name, _(cmd->cmd->summary)); } -void -grub_arg_show_help (grub_extcmd_t cmd) +static void +showargs (const struct grub_arg_option *opt, + int h_is_used, int u_is_used) { - auto void showargs (const struct grub_arg_option *opt); - int h_is_used = 0; - int u_is_used = 0; - - auto void showargs (const struct grub_arg_option *opt) + for (; opt->doc; opt++) { - for (; opt->doc; opt++) + int spacing = 20; + + if (opt->shortarg && grub_isgraph (opt->shortarg)) + grub_printf ("-%c%c ", opt->shortarg, opt->longarg ? ',':' '); + else if (opt == help_options && ! h_is_used) + grub_printf ("-h, "); + else if (opt == help_options + 1 && ! u_is_used) + grub_printf ("-u, "); + else + grub_printf (" "); + + if (opt->longarg) { - int spacing = 20; - - if (opt->shortarg && grub_isgraph (opt->shortarg)) - grub_printf ("-%c%c ", opt->shortarg, opt->longarg ? ',':' '); - else if (opt == help_options && ! h_is_used) - grub_printf ("-h, "); - else if (opt == help_options + 1 && ! u_is_used) - grub_printf ("-u, "); - else - grub_printf (" "); + grub_printf ("--%s", opt->longarg); + spacing -= grub_strlen (opt->longarg) + 2; - if (opt->longarg) + if (opt->arg) { - grub_printf ("--%s", opt->longarg); - spacing -= grub_strlen (opt->longarg) + 2; - - if (opt->arg) - { - grub_printf ("=%s", opt->arg); - spacing -= grub_strlen (opt->arg) + 1; - } + grub_printf ("=%s", opt->arg); + spacing -= grub_strlen (opt->arg) + 1; } + } - if (spacing < 0) - spacing = 3; - - while (spacing--) - grub_xputs (" "); - - grub_printf ("%s\n", _(opt->doc)); - - switch (opt->shortarg) - { - case 'h': - h_is_used = 1; - break; + if (spacing < 0) + spacing = 3; - case 'u': - u_is_used = 1; - break; + while (spacing--) + grub_xputs (" "); - default: - break; - } - } + grub_printf ("%s\n", _(opt->doc)); } +} + +void +grub_arg_show_help (grub_extcmd_t cmd) +{ + int h_is_used = 0; + int u_is_used = 0; + const struct grub_arg_option *opt; show_usage (cmd); grub_printf ("%s\n\n", _(cmd->cmd->description)); + + for (opt = cmd->options; opt->doc; opt++) + switch (opt->shortarg) + { + case 'h': + h_is_used = 1; + break; + + case 'u': + u_is_used = 1; + break; + } + if (cmd->options) - showargs (cmd->options); - showargs (help_options); + showargs (cmd->options, h_is_used, u_is_used); + showargs (help_options, h_is_used, u_is_used); #if 0 grub_printf ("\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT); #endif -- 1.8.2.1