[2/5] Move show_user_1 to cli-cmds.c

Message ID 20230129162105.526266-3-tom@tromey.com
State New
Headers
Series Additions to "save" command |

Commit Message

Tom Tromey Jan. 29, 2023, 4:21 p.m. UTC
  show_user_1 is only called from cli-cmds.c, so move it there and make
it static.
---
 gdb/cli/cli-cmds.c   | 35 +++++++++++++++++++++++++++++++++++
 gdb/cli/cli-script.c | 35 -----------------------------------
 gdb/cli/cli-script.h |  5 -----
 3 files changed, 35 insertions(+), 40 deletions(-)
  

Patch

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 6c0d780face..61f890a7dae 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1643,6 +1643,41 @@  make_command (const char *arg, int from_tty)
     }
 }
 
+/* Print the definition of user command C to STREAM.  Or, if C is a
+   prefix command, show the definitions of all user commands under C
+   (recursively).  PREFIX and NAME combined are the name of the
+   current command.  */
+static void
+show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
+	     struct ui_file *stream)
+{
+  if (cli_user_command_p (c))
+    {
+      struct command_line *cmdlines = c->user_commands.get ();
+
+      gdb_printf (stream, "User %scommand \"",
+		  c->is_prefix () ? "prefix" : "");
+      fprintf_styled (stream, title_style.style (), "%s%s",
+		      prefix, name);
+      gdb_printf (stream, "\":\n");
+      if (cmdlines)
+	{
+	  print_command_lines (current_uiout, cmdlines, 1);
+	  gdb_puts ("\n", stream);
+	}
+    }
+
+  if (c->is_prefix ())
+    {
+      const std::string prefixname = c->prefixname ();
+
+      for (c = *c->subcommands; c != NULL; c = c->next)
+	if (c->theclass == class_user || c->is_prefix ())
+	  show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
+    }
+
+}
+
 static void
 show_user (const char *args, int from_tty)
 {
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 92005ba8c38..0bd5803dc31 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1651,41 +1651,6 @@  script_from_file (FILE *stream, const char *file)
     }
 }
 
-/* Print the definition of user command C to STREAM.  Or, if C is a
-   prefix command, show the definitions of all user commands under C
-   (recursively).  PREFIX and NAME combined are the name of the
-   current command.  */
-void
-show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
-	     struct ui_file *stream)
-{
-  if (cli_user_command_p (c))
-    {
-      struct command_line *cmdlines = c->user_commands.get ();
-
-      gdb_printf (stream, "User %scommand \"",
-		  c->is_prefix () ? "prefix" : "");
-      fprintf_styled (stream, title_style.style (), "%s%s",
-		      prefix, name);
-      gdb_printf (stream, "\":\n");
-      if (cmdlines)
-	{
-	  print_command_lines (current_uiout, cmdlines, 1);
-	  gdb_puts ("\n", stream);
-	}
-    }
-
-  if (c->is_prefix ())
-    {
-      const std::string prefixname = c->prefixname ();
-
-      for (c = *c->subcommands; c != NULL; c = c->next)
-	if (c->theclass == class_user || c->is_prefix ())
-	  show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
-    }
-
-}
-
 void _initialize_cli_script ();
 void
 _initialize_cli_script ()
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index da7307bbf8d..67ef0bb672e 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -130,11 +130,6 @@  extern counted_command_line read_command_lines_1
 
 extern void script_from_file (FILE *stream, const char *file);
 
-extern void show_user_1 (struct cmd_list_element *c,
-			 const char *prefix,
-			 const char *name,
-			 struct ui_file *stream);
-
 /* Execute the commands in CMDLINES.  */
 
 extern void execute_control_commands (struct command_line *cmdlines,