From 3d0b35641081d0f57d32583093f3297ff39b7379 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Fri, 14 May 2021 15:38:49 -0400
Subject: gdb: add cmd_list_element::is_prefix

Same idea as the previous patch, but for prefix instead of alias.

gdb/ChangeLog:

	* cli/cli-decode.h (cmd_list_element) <is_prefix>: New, use it.

Change-Id: I76a9d2e82fc8d7429904424674d99ce6f9880e2b
---
 gdb/cli/cli-script.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'gdb/cli/cli-script.c')

diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 5ddfab9..ff93523 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1350,7 +1350,7 @@ validate_comname (const char **comname)
       const char *tem = prefix.c_str ();
 
       c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1);
-      if (c->subcommands == NULL)
+      if (!c->is_prefix ())
 	error (_("\"%s\" is not a prefix command."), prefix.c_str ());
 
       list = c->subcommands;
@@ -1414,7 +1414,7 @@ do_define_command (const char *comname, int from_tty,
 	  /* if C is a prefix command that was previously defined,
 	     tell the user its subcommands will be kept, and ask
 	     if ok to redefine the command.  */
-	  if (c->subcommands != nullptr)
+	  if (c->is_prefix ())
 	    q = (c->user_commands.get () == nullptr
 		 || query (_("Keeping subcommands of prefix command \"%s\".\n"
 			     "Redefine command \"%s\"? "), c->name, c->name));
@@ -1595,7 +1595,7 @@ define_prefix_command (const char *comname, int from_tty)
   if (c != nullptr && c->theclass != class_user)
     error (_("Command \"%s\" is built-in."), comfull);
 
-  if (c != nullptr && c->subcommands != nullptr)
+  if (c != nullptr && c->is_prefix ())
     {
       /* c is already a user defined prefix command.  */
       return;
@@ -1665,7 +1665,7 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
       struct command_line *cmdlines = c->user_commands.get ();
 
       fprintf_filtered (stream, "User %scommand \"",
-			c->subcommands == NULL ? "" : "prefix ");
+			c->is_prefix () ? "prefix" : "");
       fprintf_styled (stream, title_style.style (), "%s%s",
 		      prefix, name);
       fprintf_filtered (stream, "\":\n");
@@ -1676,12 +1676,12 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
 	}
     }
 
-  if (c->subcommands != NULL)
+  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->subcommands != NULL)
+	if (c->theclass == class_user || c->is_prefix ())
 	  show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout);
     }
 
-- 
cgit v1.1