a5bd9f6
From a3564dd3f793d2677584a93284966b6b9f14ebdb Mon Sep 17 00:00:00 2001
a5bd9f6
From: Colin Watson <cjwatson@ubuntu.com>
a5bd9f6
Date: Mon, 31 Dec 2012 17:31:38 +0000
a5bd9f6
Subject: [PATCH 074/364] Remove several trivially-unnecessary uses of nested
a5bd9f6
 functions.
a5bd9f6
a5bd9f6
* grub-core/commands/i386/pc/sendkey.c
a5bd9f6
(grub_cmd_sendkey: find_key_code, find_ascii_code): Make static
a5bd9f6
instead of nested.
a5bd9f6
* grub-core/commands/legacycfg.c (legacy_file: getline): Likewise.
a5bd9f6
Rename to ...
a5bd9f6
(legacy_file_getline): ... this.
a5bd9f6
* grub-core/commands/loadenv.c (grub_cmd_load_env: set_var):
a5bd9f6
Likewise.
a5bd9f6
* grub-core/kern/corecmd.c (grub_core_cmd_set: print_env): Likewise.
a5bd9f6
* grub-core/kern/fs.c (grub_fs_probe: dummy_func): Likewise.  Rename
a5bd9f6
to ...
a5bd9f6
(probe_dummy_iter): ... this.
a5bd9f6
* grub-core/kern/i386/coreboot/mmap.c
a5bd9f6
(grub_linuxbios_table_iterate: check_signature): Likewise.
a5bd9f6
* grub-core/kern/parser.c (grub_parser_split_cmdline:
a5bd9f6
check_varstate): Likewise.  Mark inline.
a5bd9f6
* grub-core/lib/arg.c (find_short: fnd_short): Likewise.  Pass
a5bd9f6
an additional parameter.
a5bd9f6
(find_long: fnd_long): Likewise.  Pass two additional parameters.
a5bd9f6
* grub-core/lib/crc.c (init_crc32c_table: reflect): Likewise.
a5bd9f6
* grub-core/lib/crc64.c (init_crc64_table: reflect): Likewise.
a5bd9f6
* grub-core/lib/ieee1275/cmos.c (grub_cmos_find_port: hook):
a5bd9f6
Likewise.  Rename to ...
a5bd9f6
(grub_cmos_find_port_iter): ... this.
a5bd9f6
* grub-core/lib/ieee1275/datetime.c (find_rtc: hook): Likewise.
a5bd9f6
Rename to ...
a5bd9f6
(find_rtc_iter): ... this.
a5bd9f6
a5bd9f6
* grub-core/normal/menu_entry.c (run): Fold nested editor_getsource
a5bd9f6
function directly into the function body, since it is only called
a5bd9f6
once.
a5bd9f6
---
a5bd9f6
 ChangeLog                            | 36 ++++++++++++++++
a5bd9f6
 grub-core/commands/i386/pc/sendkey.c | 65 ++++++++++++++--------------
a5bd9f6
 grub-core/commands/legacycfg.c       | 20 ++++-----
a5bd9f6
 grub-core/commands/loadenv.c         | 15 ++++---
a5bd9f6
 grub-core/kern/corecmd.c             | 16 +++----
a5bd9f6
 grub-core/kern/fs.c                  | 20 ++++-----
a5bd9f6
 grub-core/kern/i386/coreboot/mmap.c  | 19 +++++----
a5bd9f6
 grub-core/kern/parser.c              | 20 ++++-----
a5bd9f6
 grub-core/lib/arg.c                  | 58 +++++++++++++------------
a5bd9f6
 grub-core/lib/crc.c                  | 31 +++++++-------
a5bd9f6
 grub-core/lib/crc64.c                | 31 +++++++-------
a5bd9f6
 grub-core/lib/ieee1275/cmos.c        | 82 ++++++++++++++++++------------------
a5bd9f6
 grub-core/lib/ieee1275/datetime.c    | 27 ++++++------
a5bd9f6
 grub-core/normal/menu_entry.c        | 50 +++++++++-------------
a5bd9f6
 14 files changed, 264 insertions(+), 226 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index 36f1bff..8723bfa 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,39 @@
a5bd9f6
+2012-12-31  Colin Watson  <cjwatson@ubuntu.com>
a5bd9f6
+
a5bd9f6
+	Remove several trivially-unnecessary uses of nested functions.
a5bd9f6
+
a5bd9f6
+	* grub-core/commands/i386/pc/sendkey.c
a5bd9f6
+	(grub_cmd_sendkey: find_key_code, find_ascii_code): Make static
a5bd9f6
+	instead of nested.
a5bd9f6
+	* grub-core/commands/legacycfg.c (legacy_file: getline): Likewise.
a5bd9f6
+	Rename to ...
a5bd9f6
+	(legacy_file_getline): ... this.
a5bd9f6
+	* grub-core/commands/loadenv.c (grub_cmd_load_env: set_var):
a5bd9f6
+	Likewise.
a5bd9f6
+	* grub-core/kern/corecmd.c (grub_core_cmd_set: print_env): Likewise.
a5bd9f6
+	* grub-core/kern/fs.c (grub_fs_probe: dummy_func): Likewise.  Rename
a5bd9f6
+	to ...
a5bd9f6
+	(probe_dummy_iter): ... this.
a5bd9f6
+	* grub-core/kern/i386/coreboot/mmap.c
a5bd9f6
+	(grub_linuxbios_table_iterate: check_signature): Likewise.
a5bd9f6
+	* grub-core/kern/parser.c (grub_parser_split_cmdline:
a5bd9f6
+	check_varstate): Likewise.  Mark inline.
a5bd9f6
+	* grub-core/lib/arg.c (find_short: fnd_short): Likewise.  Pass
a5bd9f6
+	an additional parameter.
a5bd9f6
+	(find_long: fnd_long): Likewise.  Pass two additional parameters.
a5bd9f6
+	* grub-core/lib/crc.c (init_crc32c_table: reflect): Likewise.
a5bd9f6
+	* grub-core/lib/crc64.c (init_crc64_table: reflect): Likewise.
a5bd9f6
+	* grub-core/lib/ieee1275/cmos.c (grub_cmos_find_port: hook):
a5bd9f6
+	Likewise.  Rename to ...
a5bd9f6
+	(grub_cmos_find_port_iter): ... this.
a5bd9f6
+	* grub-core/lib/ieee1275/datetime.c (find_rtc: hook): Likewise.
a5bd9f6
+	Rename to ...
a5bd9f6
+	(find_rtc_iter): ... this.
a5bd9f6
+
a5bd9f6
+	* grub-core/normal/menu_entry.c (run): Fold nested editor_getsource
a5bd9f6
+	function directly into the function body, since it is only called
a5bd9f6
+	once.
a5bd9f6
+
a5bd9f6
 2012-12-30  Colin Watson  <cjwatson@ubuntu.com>
a5bd9f6
 
a5bd9f6
 	* grub-core/bus/usb/ehci.c (grub_ehci_pci_iter): Remove incorrect
a5bd9f6
diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c
a5bd9f6
index 17f648d..d985cb3 100644
a5bd9f6
--- a/grub-core/commands/i386/pc/sendkey.c
a5bd9f6
+++ b/grub-core/commands/i386/pc/sendkey.c
a5bd9f6
@@ -286,47 +286,48 @@ grub_sendkey_preboot (int noret __attribute__ ((unused)))
a5bd9f6
   return GRUB_ERR_NONE;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static grub_err_t
a5bd9f6
-grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
a5bd9f6
+/* Helper for grub_cmd_sendkey.  */
a5bd9f6
+static int
a5bd9f6
+find_key_code (char *key)
a5bd9f6
 {
a5bd9f6
-  struct grub_arg_list *state = ctxt->state;
a5bd9f6
-
a5bd9f6
-  auto int find_key_code (char *key); 
a5bd9f6
-  auto int find_ascii_code (char *key);
a5bd9f6
+  unsigned i;
a5bd9f6
 
a5bd9f6
-  int find_key_code (char *key)
a5bd9f6
+  for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
a5bd9f6
     {
a5bd9f6
-      unsigned i;
a5bd9f6
+      if (keysym_table[i].unshifted_name 
a5bd9f6
+	  && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
a5bd9f6
+	return keysym_table[i].keycode;
a5bd9f6
+      else if (keysym_table[i].shifted_name 
a5bd9f6
+	       && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
a5bd9f6
+	return keysym_table[i].keycode;
a5bd9f6
+    }
a5bd9f6
 
a5bd9f6
-      for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
a5bd9f6
-	{
a5bd9f6
-	  if (keysym_table[i].unshifted_name 
a5bd9f6
-	      && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
a5bd9f6
-	    return keysym_table[i].keycode;
a5bd9f6
-	  else if (keysym_table[i].shifted_name 
a5bd9f6
-		   && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
a5bd9f6
-	    return keysym_table[i].keycode;
a5bd9f6
-	}
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
 
a5bd9f6
-      return 0;
a5bd9f6
-    }
a5bd9f6
+/* Helper for grub_cmd_sendkey.  */
a5bd9f6
+static int
a5bd9f6
+find_ascii_code (char *key)
a5bd9f6
+{
a5bd9f6
+  unsigned i;
a5bd9f6
 
a5bd9f6
-  int find_ascii_code (char *key)
a5bd9f6
+  for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
a5bd9f6
     {
a5bd9f6
-      unsigned i;
a5bd9f6
+      if (keysym_table[i].unshifted_name 
a5bd9f6
+	  && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
a5bd9f6
+	return keysym_table[i].unshifted_ascii;
a5bd9f6
+      else if (keysym_table[i].shifted_name 
a5bd9f6
+	       && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
a5bd9f6
+	return keysym_table[i].shifted_ascii;
a5bd9f6
+    }
a5bd9f6
 
a5bd9f6
-      for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
a5bd9f6
-	{
a5bd9f6
-	  if (keysym_table[i].unshifted_name 
a5bd9f6
-	      && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
a5bd9f6
-	    return keysym_table[i].unshifted_ascii;
a5bd9f6
-	  else if (keysym_table[i].shifted_name 
a5bd9f6
-		   && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
a5bd9f6
-	    return keysym_table[i].shifted_ascii;
a5bd9f6
-	}
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
 
a5bd9f6
-      return 0;
a5bd9f6
-    }
a5bd9f6
+static grub_err_t
a5bd9f6
+grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
a5bd9f6
+{
a5bd9f6
+  struct grub_arg_list *state = ctxt->state;
a5bd9f6
 
a5bd9f6
   andmask = 0xffffffff;
a5bd9f6
   ormask = 0;
a5bd9f6
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
a5bd9f6
index 5293acc..e34eed4 100644
a5bd9f6
--- a/grub-core/commands/legacycfg.c
a5bd9f6
+++ b/grub-core/commands/legacycfg.c
a5bd9f6
@@ -35,6 +35,14 @@
a5bd9f6
 
a5bd9f6
 GRUB_MOD_LICENSE ("GPLv3+");
a5bd9f6
 
a5bd9f6
+/* Helper for legacy_file.  */
a5bd9f6
+static grub_err_t
a5bd9f6
+legacy_file_getline (char **line, int cont __attribute__ ((unused)))
a5bd9f6
+{
a5bd9f6
+  *line = 0;
a5bd9f6
+  return GRUB_ERR_NONE;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 legacy_file (const char *filename)
a5bd9f6
 {
a5bd9f6
@@ -43,14 +51,6 @@ legacy_file (const char *filename)
a5bd9f6
   grub_menu_t menu;
a5bd9f6
   char *suffix = grub_strdup ("");
a5bd9f6
 
a5bd9f6
-  auto grub_err_t getline (char **line, int cont);
a5bd9f6
-  grub_err_t getline (char **line, 
a5bd9f6
-		      int cont __attribute__ ((unused)))
a5bd9f6
-  {
a5bd9f6
-    *line = 0;
a5bd9f6
-    return GRUB_ERR_NONE;
a5bd9f6
-  }
a5bd9f6
-
a5bd9f6
   if (!suffix)
a5bd9f6
     return grub_errno;
a5bd9f6
 
a5bd9f6
@@ -134,7 +134,7 @@ legacy_file (const char *filename)
a5bd9f6
 
a5bd9f6
       if (parsed && !entryname)
a5bd9f6
 	{
a5bd9f6
-	  grub_normal_parse_line (parsed, getline);
a5bd9f6
+	  grub_normal_parse_line (parsed, legacy_file_getline);
a5bd9f6
 	  grub_print_error ();
a5bd9f6
 	  grub_free (parsed);
a5bd9f6
 	  parsed = NULL;
a5bd9f6
@@ -180,7 +180,7 @@ legacy_file (const char *filename)
a5bd9f6
       grub_free (args);
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
-  grub_normal_parse_line (suffix, getline);
a5bd9f6
+  grub_normal_parse_line (suffix, legacy_file_getline);
a5bd9f6
   grub_print_error ();
a5bd9f6
   grub_free (suffix);
a5bd9f6
   grub_free (entrysrc);
a5bd9f6
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
a5bd9f6
index 18ebb7e..9a35550 100644
a5bd9f6
--- a/grub-core/commands/loadenv.c
a5bd9f6
+++ b/grub-core/commands/loadenv.c
a5bd9f6
@@ -114,6 +114,14 @@ read_envblk_file (grub_file_t file)
a5bd9f6
   return envblk;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+/* Helper for grub_cmd_load_env.  */
a5bd9f6
+static int
a5bd9f6
+set_var (const char *name, const char *value)
a5bd9f6
+{
a5bd9f6
+  grub_env_set (name, value);
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_cmd_load_env (grub_extcmd_context_t ctxt,
a5bd9f6
 		   int argc __attribute__ ((unused)),
a5bd9f6
@@ -123,13 +131,6 @@ grub_cmd_load_env (grub_extcmd_context_t ctxt,
a5bd9f6
   grub_file_t file;
a5bd9f6
   grub_envblk_t envblk;
a5bd9f6
 
a5bd9f6
-  auto int set_var (const char *name, const char *value);
a5bd9f6
-  int set_var (const char *name, const char *value)
a5bd9f6
-  {
a5bd9f6
-    grub_env_set (name, value);
a5bd9f6
-    return 0;
a5bd9f6
-  }
a5bd9f6
-
a5bd9f6
   file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
a5bd9f6
   if (! file)
a5bd9f6
     return grub_errno;
a5bd9f6
diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c
a5bd9f6
index eec575c..43240e9 100644
a5bd9f6
--- a/grub-core/kern/corecmd.c
a5bd9f6
+++ b/grub-core/kern/corecmd.c
a5bd9f6
@@ -28,6 +28,14 @@
a5bd9f6
 #include <grub/command.h>
a5bd9f6
 #include <grub/i18n.h>
a5bd9f6
 
a5bd9f6
+/* Helper for grub_core_cmd_set.  */
a5bd9f6
+static int
a5bd9f6
+print_env (struct grub_env_var *env)
a5bd9f6
+{
a5bd9f6
+  grub_printf ("%s=%s\n", env->name, env->value);
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 /* set ENVVAR=VALUE */
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
a5bd9f6
@@ -36,14 +44,6 @@ grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
a5bd9f6
   char *var;
a5bd9f6
   char *val;
a5bd9f6
 
a5bd9f6
-  auto int print_env (struct grub_env_var *env);
a5bd9f6
-
a5bd9f6
-  int print_env (struct grub_env_var *env)
a5bd9f6
-    {
a5bd9f6
-      grub_printf ("%s=%s\n", env->name, env->value);
a5bd9f6
-      return 0;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
   if (argc < 1)
a5bd9f6
     {
a5bd9f6
       grub_env_iterate (print_env);
a5bd9f6
diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
a5bd9f6
index 51d89d1..7e150f2 100644
a5bd9f6
--- a/grub-core/kern/fs.c
a5bd9f6
+++ b/grub-core/kern/fs.c
a5bd9f6
@@ -32,18 +32,18 @@ grub_fs_t grub_fs_list = 0;
a5bd9f6
 
a5bd9f6
 grub_fs_autoload_hook_t grub_fs_autoload_hook = 0;
a5bd9f6
 
a5bd9f6
+/* Helper for grub_fs_probe.  */
a5bd9f6
+static int
a5bd9f6
+probe_dummy_iter (const char *filename __attribute__ ((unused)),
a5bd9f6
+		  const struct grub_dirhook_info *info __attribute__ ((unused)))
a5bd9f6
+  {
a5bd9f6
+    return 1;
a5bd9f6
+  }
a5bd9f6
+
a5bd9f6
 grub_fs_t
a5bd9f6
 grub_fs_probe (grub_device_t device)
a5bd9f6
 {
a5bd9f6
   grub_fs_t p;
a5bd9f6
-  auto int dummy_func (const char *filename,
a5bd9f6
-		       const struct grub_dirhook_info *info);
a5bd9f6
-
a5bd9f6
-  int dummy_func (const char *filename __attribute__ ((unused)),
a5bd9f6
-		  const struct grub_dirhook_info *info  __attribute__ ((unused)))
a5bd9f6
-    {
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
 
a5bd9f6
   if (device->disk)
a5bd9f6
     {
a5bd9f6
@@ -69,7 +69,7 @@ grub_fs_probe (grub_device_t device)
a5bd9f6
 	    }
a5bd9f6
 	  else
a5bd9f6
 #endif
a5bd9f6
-	    (p->dir) (device, "/", dummy_func);
a5bd9f6
+	    (p->dir) (device, "/", probe_dummy_iter);
a5bd9f6
 	  if (grub_errno == GRUB_ERR_NONE)
a5bd9f6
 	    return p;
a5bd9f6
 
a5bd9f6
@@ -93,7 +93,7 @@ grub_fs_probe (grub_device_t device)
a5bd9f6
 	    {
a5bd9f6
 	      p = grub_fs_list;
a5bd9f6
 
a5bd9f6
-	      (p->dir) (device, "/", dummy_func);
a5bd9f6
+	      (p->dir) (device, "/", probe_dummy_iter);
a5bd9f6
 	      if (grub_errno == GRUB_ERR_NONE)
a5bd9f6
 		{
a5bd9f6
 		  count--;
a5bd9f6
diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/i386/coreboot/mmap.c
a5bd9f6
index 8b0b202..8e15683 100644
a5bd9f6
--- a/grub-core/kern/i386/coreboot/mmap.c
a5bd9f6
+++ b/grub-core/kern/i386/coreboot/mmap.c
a5bd9f6
@@ -22,21 +22,22 @@
a5bd9f6
 #include <grub/err.h>
a5bd9f6
 #include <grub/misc.h>
a5bd9f6
 
a5bd9f6
+/* Helper for grub_linuxbios_table_iterate.  */
a5bd9f6
+static int
a5bd9f6
+check_signature (grub_linuxbios_table_header_t tbl_header)
a5bd9f6
+{
a5bd9f6
+  if (! grub_memcmp (tbl_header->signature, "LBIO", 4))
a5bd9f6
+    return 1;
a5bd9f6
+
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t))
a5bd9f6
 {
a5bd9f6
   grub_linuxbios_table_header_t table_header;
a5bd9f6
   grub_linuxbios_table_item_t table_item;
a5bd9f6
 
a5bd9f6
-  auto int check_signature (grub_linuxbios_table_header_t);
a5bd9f6
-  int check_signature (grub_linuxbios_table_header_t tbl_header)
a5bd9f6
-  {
a5bd9f6
-    if (! grub_memcmp (tbl_header->signature, "LBIO", 4))
a5bd9f6
-      return 1;
a5bd9f6
-
a5bd9f6
-    return 0;
a5bd9f6
-  }
a5bd9f6
-
a5bd9f6
   /* Assuming table_header is aligned to its size (8 bytes).  */
a5bd9f6
 
a5bd9f6
   for (table_header = (grub_linuxbios_table_header_t) 0x500;
a5bd9f6
diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c
a5bd9f6
index 9213caa..d1be53e 100644
a5bd9f6
--- a/grub-core/kern/parser.c
a5bd9f6
+++ b/grub-core/kern/parser.c
a5bd9f6
@@ -96,6 +96,16 @@ grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 
a5bd9f6
+/* Helper for grub_parser_split_cmdline.  */
a5bd9f6
+static inline int
a5bd9f6
+check_varstate (grub_parser_state_t s)
a5bd9f6
+{
a5bd9f6
+  return (s == GRUB_PARSER_STATE_VARNAME
a5bd9f6
+	  || s == GRUB_PARSER_STATE_VARNAME2
a5bd9f6
+	  || s == GRUB_PARSER_STATE_QVARNAME
a5bd9f6
+	  || s == GRUB_PARSER_STATE_QVARNAME2);
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 grub_err_t
a5bd9f6
 grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
a5bd9f6
 			   int *argc, char ***argv)
a5bd9f6
@@ -111,16 +121,6 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
a5bd9f6
   char *args;
a5bd9f6
   int i;
a5bd9f6
 
a5bd9f6
-  auto int check_varstate (grub_parser_state_t s);
a5bd9f6
-
a5bd9f6
-  int check_varstate (grub_parser_state_t s)
a5bd9f6
-  {
a5bd9f6
-    return (s == GRUB_PARSER_STATE_VARNAME
a5bd9f6
-	    || s == GRUB_PARSER_STATE_VARNAME2
a5bd9f6
-	    || s == GRUB_PARSER_STATE_QVARNAME
a5bd9f6
-	    || s == GRUB_PARSER_STATE_QVARNAME2);
a5bd9f6
-  }
a5bd9f6
-
a5bd9f6
   auto void add_var (grub_parser_state_t newstate);
a5bd9f6
 
a5bd9f6
   void add_var (grub_parser_state_t newstate)
a5bd9f6
diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c
a5bd9f6
index b341885..a2d9416 100644
a5bd9f6
--- a/grub-core/lib/arg.c
a5bd9f6
+++ b/grub-core/lib/arg.c
a5bd9f6
@@ -34,25 +34,26 @@ static const struct grub_arg_option help_options[] =
a5bd9f6
     {0, 0, 0, 0, 0, 0}
a5bd9f6
   };
a5bd9f6
 
a5bd9f6
+/* Helper for find_short.  */
a5bd9f6
 static struct grub_arg_option *
a5bd9f6
-find_short (const struct grub_arg_option *options, char c)
a5bd9f6
+fnd_short (const struct grub_arg_option *opt, char c)
a5bd9f6
 {
a5bd9f6
-  struct grub_arg_option *found = 0;
a5bd9f6
-  auto struct grub_arg_option *fnd_short (const struct grub_arg_option *opt);
a5bd9f6
-
a5bd9f6
-  struct grub_arg_option *fnd_short (const struct grub_arg_option *opt)
a5bd9f6
+  while (opt->doc)
a5bd9f6
     {
a5bd9f6
-      while (opt->doc)
a5bd9f6
-	{
a5bd9f6
-	  if (opt->shortarg == c)
a5bd9f6
-	    return (struct grub_arg_option *) opt;
a5bd9f6
-	  opt++;
a5bd9f6
-	}
a5bd9f6
-      return 0;
a5bd9f6
+      if (opt->shortarg == c)
a5bd9f6
+	return (struct grub_arg_option *) opt;
a5bd9f6
+      opt++;
a5bd9f6
     }
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
+static struct grub_arg_option *
a5bd9f6
+find_short (const struct grub_arg_option *options, char c)
a5bd9f6
+{
a5bd9f6
+  struct grub_arg_option *found = 0;
a5bd9f6
 
a5bd9f6
   if (options)
a5bd9f6
-    found = fnd_short (options);
a5bd9f6
+    found = fnd_short (options, c);
a5bd9f6
 
a5bd9f6
   if (! found)
a5bd9f6
     {
a5bd9f6
@@ -74,29 +75,30 @@ find_short (const struct grub_arg_option *options, char c)
a5bd9f6
   return found;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+/* Helper for find_long.  */
a5bd9f6
 static struct grub_arg_option *
a5bd9f6
-find_long (const struct grub_arg_option *options, const char *s, int len)
a5bd9f6
+fnd_long (const struct grub_arg_option *opt, const char *s, int len)
a5bd9f6
 {
a5bd9f6
-  struct grub_arg_option *found = 0;
a5bd9f6
-  auto struct grub_arg_option *fnd_long (const struct grub_arg_option *opt);
a5bd9f6
-
a5bd9f6
-  struct grub_arg_option *fnd_long (const struct grub_arg_option *opt)
a5bd9f6
+  while (opt->doc)
a5bd9f6
     {
a5bd9f6
-      while (opt->doc)
a5bd9f6
-	{
a5bd9f6
-	  if (opt->longarg && ! grub_strncmp (opt->longarg, s, len) &&
a5bd9f6
-	      opt->longarg[len] == '\0')
a5bd9f6
-	    return (struct grub_arg_option *) opt;
a5bd9f6
-	  opt++;
a5bd9f6
-	}
a5bd9f6
-      return 0;
a5bd9f6
+      if (opt->longarg && ! grub_strncmp (opt->longarg, s, len) &&
a5bd9f6
+	  opt->longarg[len] == '\0')
a5bd9f6
+	return (struct grub_arg_option *) opt;
a5bd9f6
+      opt++;
a5bd9f6
     }
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
+static struct grub_arg_option *
a5bd9f6
+find_long (const struct grub_arg_option *options, const char *s, int len)
a5bd9f6
+{
a5bd9f6
+  struct grub_arg_option *found = 0;
a5bd9f6
 
a5bd9f6
   if (options)
a5bd9f6
-    found = fnd_long (options);
a5bd9f6
+    found = fnd_long (options, s, len);
a5bd9f6
 
a5bd9f6
   if (! found)
a5bd9f6
-    found = fnd_long (help_options);
a5bd9f6
+    found = fnd_long (help_options, s, len);
a5bd9f6
 
a5bd9f6
   return found;
a5bd9f6
 }
a5bd9f6
diff --git a/grub-core/lib/crc.c b/grub-core/lib/crc.c
a5bd9f6
index ffc3ef3..bf97cc6 100644
a5bd9f6
--- a/grub-core/lib/crc.c
a5bd9f6
+++ b/grub-core/lib/crc.c
a5bd9f6
@@ -22,25 +22,26 @@
a5bd9f6
 
a5bd9f6
 static grub_uint32_t crc32c_table [256];
a5bd9f6
 
a5bd9f6
-static void
a5bd9f6
-init_crc32c_table (void)
a5bd9f6
+/* Helper for init_crc32c_table.  */
a5bd9f6
+static grub_uint32_t
a5bd9f6
+reflect (grub_uint32_t ref, int len)
a5bd9f6
 {
a5bd9f6
-  auto grub_uint32_t reflect (grub_uint32_t ref, int len);
a5bd9f6
-  grub_uint32_t reflect (grub_uint32_t ref, int len)
a5bd9f6
-    {
a5bd9f6
-      grub_uint32_t result = 0;
a5bd9f6
-      int i;
a5bd9f6
-
a5bd9f6
-      for (i = 1; i <= len; i++)
a5bd9f6
-        {
a5bd9f6
-          if (ref & 1)
a5bd9f6
-            result |= 1 << (len - i);
a5bd9f6
-          ref >>= 1;
a5bd9f6
-        }
a5bd9f6
+  grub_uint32_t result = 0;
a5bd9f6
+  int i;
a5bd9f6
 
a5bd9f6
-      return result;
a5bd9f6
+  for (i = 1; i <= len; i++)
a5bd9f6
+    {
a5bd9f6
+      if (ref & 1)
a5bd9f6
+	result |= 1 << (len - i);
a5bd9f6
+      ref >>= 1;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
+  return result;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
+static void
a5bd9f6
+init_crc32c_table (void)
a5bd9f6
+{
a5bd9f6
   grub_uint32_t polynomial = 0x1edc6f41;
a5bd9f6
   int i, j;
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/lib/crc64.c b/grub-core/lib/crc64.c
a5bd9f6
index 4b1c92c..4960f3f 100644
a5bd9f6
--- a/grub-core/lib/crc64.c
a5bd9f6
+++ b/grub-core/lib/crc64.c
a5bd9f6
@@ -25,25 +25,26 @@ GRUB_MOD_LICENSE ("GPLv3+");
a5bd9f6
 
a5bd9f6
 static grub_uint64_t crc64_table [256];
a5bd9f6
 
a5bd9f6
-static void
a5bd9f6
-init_crc64_table (void)
a5bd9f6
+/* Helper for init_crc64_table.  */
a5bd9f6
+static grub_uint64_t
a5bd9f6
+reflect (grub_uint64_t ref, int len)
a5bd9f6
 {
a5bd9f6
-  auto grub_uint64_t reflect (grub_uint64_t ref, int len);
a5bd9f6
-  grub_uint64_t reflect (grub_uint64_t ref, int len)
a5bd9f6
-    {
a5bd9f6
-      grub_uint64_t result = 0;
a5bd9f6
-      int i;
a5bd9f6
+  grub_uint64_t result = 0;
a5bd9f6
+  int i;
a5bd9f6
 
a5bd9f6
-      for (i = 1; i <= len; i++)
a5bd9f6
-        {
a5bd9f6
-          if (ref & 1)
a5bd9f6
-            result |= 1ULL << (len - i);
a5bd9f6
-          ref >>= 1;
a5bd9f6
-        }
a5bd9f6
-
a5bd9f6
-      return result;
a5bd9f6
+  for (i = 1; i <= len; i++)
a5bd9f6
+    {
a5bd9f6
+      if (ref & 1)
a5bd9f6
+	result |= 1ULL << (len - i);
a5bd9f6
+      ref >>= 1;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
+  return result;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
+static void
a5bd9f6
+init_crc64_table (void)
a5bd9f6
+{
a5bd9f6
   grub_uint64_t polynomial = 0x42f0e1eba9ea3693ULL;
a5bd9f6
   int i, j;
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/lib/ieee1275/cmos.c b/grub-core/lib/ieee1275/cmos.c
a5bd9f6
index fa57db9..328d70a 100644
a5bd9f6
--- a/grub-core/lib/ieee1275/cmos.c
a5bd9f6
+++ b/grub-core/lib/ieee1275/cmos.c
a5bd9f6
@@ -23,51 +23,53 @@
a5bd9f6
 #include <grub/misc.h>
a5bd9f6
 
a5bd9f6
 volatile grub_uint8_t *grub_cmos_port = 0;
a5bd9f6
-grub_err_t
a5bd9f6
-grub_cmos_find_port (void)
a5bd9f6
+
a5bd9f6
+/* Helper for grub_cmos_find_port.  */
a5bd9f6
+static int
a5bd9f6
+grub_cmos_find_port_iter (struct grub_ieee1275_devalias *alias)
a5bd9f6
 {
a5bd9f6
-  auto int hook (struct grub_ieee1275_devalias *alias);
a5bd9f6
-  int hook (struct grub_ieee1275_devalias *alias)
a5bd9f6
-  {
a5bd9f6
-    grub_ieee1275_phandle_t dev;
a5bd9f6
-    grub_uint32_t addr[2];
a5bd9f6
-    grub_ssize_t actual;
a5bd9f6
-    /* Enough to check if it's "m5819" */
a5bd9f6
-    char compat[100];
a5bd9f6
-    if (grub_ieee1275_finddevice (alias->path, &dev))
a5bd9f6
-      return 0;
a5bd9f6
-    if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
a5bd9f6
-				    0))
a5bd9f6
-      return 0;
a5bd9f6
-    if (grub_strcmp (compat, "m5819") != 0)
a5bd9f6
-      return 0;
a5bd9f6
-    if (grub_ieee1275_get_integer_property (dev, "address",
a5bd9f6
-					    addr, sizeof (addr), &actual))
a5bd9f6
-      return 0;
a5bd9f6
-    if (actual == 4)
a5bd9f6
-      {
a5bd9f6
-	grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
a5bd9f6
-	return 1;
a5bd9f6
-      }
a5bd9f6
+  grub_ieee1275_phandle_t dev;
a5bd9f6
+  grub_uint32_t addr[2];
a5bd9f6
+  grub_ssize_t actual;
a5bd9f6
+  /* Enough to check if it's "m5819" */
a5bd9f6
+  char compat[100];
a5bd9f6
+  if (grub_ieee1275_finddevice (alias->path, &dev))
a5bd9f6
+    return 0;
a5bd9f6
+  if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
a5bd9f6
+				  0))
a5bd9f6
+    return 0;
a5bd9f6
+  if (grub_strcmp (compat, "m5819") != 0)
a5bd9f6
+    return 0;
a5bd9f6
+  if (grub_ieee1275_get_integer_property (dev, "address",
a5bd9f6
+					  addr, sizeof (addr), &actual))
a5bd9f6
+    return 0;
a5bd9f6
+  if (actual == 4)
a5bd9f6
+    {
a5bd9f6
+      grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
a5bd9f6
+      return 1;
a5bd9f6
+    }
a5bd9f6
 
a5bd9f6
 #if GRUB_CPU_SIZEOF_VOID_P == 8
a5bd9f6
-    if (actual == 8)
a5bd9f6
-      {
a5bd9f6
-	grub_cmos_port = (volatile grub_uint8_t *) 
a5bd9f6
-	  ((((grub_addr_t) addr[0]) << 32) | addr[1]);
a5bd9f6
-	return 1;
a5bd9f6
-      }
a5bd9f6
+  if (actual == 8)
a5bd9f6
+    {
a5bd9f6
+      grub_cmos_port = (volatile grub_uint8_t *) 
a5bd9f6
+	((((grub_addr_t) addr[0]) << 32) | addr[1]);
a5bd9f6
+      return 1;
a5bd9f6
+    }
a5bd9f6
 #else
a5bd9f6
-    if (actual == 8 && addr[0] == 0)
a5bd9f6
-      {
a5bd9f6
-	grub_cmos_port = (volatile grub_uint8_t *) addr[1];
a5bd9f6
-	return 1;
a5bd9f6
-      }
a5bd9f6
+  if (actual == 8 && addr[0] == 0)
a5bd9f6
+    {
a5bd9f6
+      grub_cmos_port = (volatile grub_uint8_t *) addr[1];
a5bd9f6
+      return 1;
a5bd9f6
+    }
a5bd9f6
 #endif
a5bd9f6
-    return 0;
a5bd9f6
-  }
a5bd9f6
-  
a5bd9f6
-  grub_ieee1275_devices_iterate (hook);
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
+grub_err_t
a5bd9f6
+grub_cmos_find_port (void)
a5bd9f6
+{
a5bd9f6
+  grub_ieee1275_devices_iterate (grub_cmos_find_port_iter);
a5bd9f6
   if (!grub_cmos_port)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "no cmos found");
a5bd9f6
   
a5bd9f6
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
a5bd9f6
index 8792429..74578f1 100644
a5bd9f6
--- a/grub-core/lib/ieee1275/datetime.c
a5bd9f6
+++ b/grub-core/lib/ieee1275/datetime.c
a5bd9f6
@@ -30,22 +30,23 @@ GRUB_MOD_LICENSE ("GPLv3+");
a5bd9f6
 static char *rtc = 0;
a5bd9f6
 static int no_ieee1275_rtc = 0;
a5bd9f6
 
a5bd9f6
+/* Helper for find_rtc.  */
a5bd9f6
+static int
a5bd9f6
+find_rtc_iter (struct grub_ieee1275_devalias *alias)
a5bd9f6
+{
a5bd9f6
+  if (grub_strcmp (alias->type, "rtc") == 0)
a5bd9f6
+    {
a5bd9f6
+      grub_dprintf ("datetime", "Found RTC %s\n", alias->path);
a5bd9f6
+      rtc = grub_strdup (alias->path);
a5bd9f6
+      return 1;
a5bd9f6
+    }
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static void
a5bd9f6
 find_rtc (void)
a5bd9f6
 {
a5bd9f6
-  auto int hook (struct grub_ieee1275_devalias *alias);
a5bd9f6
-  int hook (struct grub_ieee1275_devalias *alias)
a5bd9f6
-  {
a5bd9f6
-    if (grub_strcmp (alias->type, "rtc") == 0)
a5bd9f6
-      {
a5bd9f6
-	grub_dprintf ("datetime", "Found RTC %s\n", alias->path);
a5bd9f6
-	rtc = grub_strdup (alias->path);
a5bd9f6
-	return 1;
a5bd9f6
-      }
a5bd9f6
-    return 0;
a5bd9f6
-  }
a5bd9f6
-  
a5bd9f6
-  grub_ieee1275_devices_iterate (hook);
a5bd9f6
+  grub_ieee1275_devices_iterate (find_rtc_iter);
a5bd9f6
   if (!rtc)
a5bd9f6
     no_ieee1275_rtc = 1;
a5bd9f6
 }
a5bd9f6
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
a5bd9f6
index 8e2b4da..33b644b 100644
a5bd9f6
--- a/grub-core/normal/menu_entry.c
a5bd9f6
+++ b/grub-core/normal/menu_entry.c
a5bd9f6
@@ -1205,32 +1205,6 @@ run (struct screen *screen)
a5bd9f6
   grub_menu_t menu = NULL;
a5bd9f6
   char *dummy[1] = { NULL };
a5bd9f6
 
a5bd9f6
-  auto char * editor_getsource (void);
a5bd9f6
-  char * editor_getsource (void)
a5bd9f6
-  {
a5bd9f6
-    int i;
a5bd9f6
-    grub_size_t size = 0, tot_size = 0;
a5bd9f6
-    char *source;
a5bd9f6
-
a5bd9f6
-    for (i = 0; i < screen->num_lines; i++)
a5bd9f6
-      tot_size += grub_get_num_of_utf8_bytes (screen->lines[i].buf,
a5bd9f6
-					      screen->lines[i].len) + 1;
a5bd9f6
-
a5bd9f6
-    source = grub_malloc (tot_size + 1);
a5bd9f6
-    if (! source)
a5bd9f6
-      return NULL;
a5bd9f6
-
a5bd9f6
-    for (i = 0; i < screen->num_lines; i++)
a5bd9f6
-      {
a5bd9f6
-	size += grub_ucs4_to_utf8 (screen->lines[i].buf, screen->lines[i].len,
a5bd9f6
-				   (grub_uint8_t *) source + size,
a5bd9f6
-				   tot_size - size);
a5bd9f6
-	source[size++] = '\n';
a5bd9f6
-      }
a5bd9f6
-    source[size] = '\0';
a5bd9f6
-    return source;
a5bd9f6
-  }
a5bd9f6
-
a5bd9f6
   grub_cls ();
a5bd9f6
   grub_printf ("  ");
a5bd9f6
   grub_printf_ (N_("Booting a command list"));
a5bd9f6
@@ -1248,9 +1222,27 @@ run (struct screen *screen)
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
   /* Execute the script, line for line.  */
a5bd9f6
-  script = editor_getsource ();
a5bd9f6
-  if (! script)
a5bd9f6
-    return 0;
a5bd9f6
+  {
a5bd9f6
+    int i;
a5bd9f6
+    grub_size_t size = 0, tot_size = 0;
a5bd9f6
+
a5bd9f6
+    for (i = 0; i < screen->num_lines; i++)
a5bd9f6
+      tot_size += grub_get_num_of_utf8_bytes (screen->lines[i].buf,
a5bd9f6
+					      screen->lines[i].len) + 1;
a5bd9f6
+
a5bd9f6
+    script = grub_malloc (tot_size + 1);
a5bd9f6
+    if (! script)
a5bd9f6
+      return 0;
a5bd9f6
+
a5bd9f6
+    for (i = 0; i < screen->num_lines; i++)
a5bd9f6
+      {
a5bd9f6
+	size += grub_ucs4_to_utf8 (screen->lines[i].buf, screen->lines[i].len,
a5bd9f6
+				   (grub_uint8_t *) script + size,
a5bd9f6
+				   tot_size - size);
a5bd9f6
+	script[size++] = '\n';
a5bd9f6
+      }
a5bd9f6
+    script[size] = '\0';
a5bd9f6
+  }
a5bd9f6
   grub_script_execute_sourcecode (script, 0, dummy);
a5bd9f6
   grub_free (script);
a5bd9f6
 
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6