]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/lib/arg.c (grub_arg_show_help): Move showargs
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 28 Feb 2013 10:00:59 +0000 (11:00 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 28 Feb 2013 10:00:59 +0000 (11:00 +0100)
out of its parent.

ChangeLog
grub-core/lib/arg.c

index 6601c421b21548ff48b06b9ac023faacabcdb257..21ec9a9a610ca1e58331b6e424a3f2f365794c8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/lib/arg.c (grub_arg_show_help): Move showargs
+       out of its parent.
+
 2013-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/jfs.c: Remove nested functions.
index a2d94165e119d2e3a685bebbfdfc5155a825e5a8..da44e3025d14ec2193a67a4ed6f532f2b4348dda 100644 (file)
@@ -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