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