aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-decode.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-12-26 22:04:40 -0700
committerTom Tromey <tromey@redhat.com>2014-01-20 09:10:51 -0700
commit1f2bdf09c6ace2eefc3dd4dfc7366dea9ff5b30e (patch)
tree45c24f000adc6a7696aa44163b94d1359f70b6f4 /gdb/cli/cli-decode.c
parentcec2c50d38391e11f7116643450156560e5a1b91 (diff)
downloadgdb-1f2bdf09c6ace2eefc3dd4dfc7366dea9ff5b30e.zip
gdb-1f2bdf09c6ace2eefc3dd4dfc7366dea9ff5b30e.tar.gz
gdb-1f2bdf09c6ace2eefc3dd4dfc7366dea9ff5b30e.tar.bz2
convert flags to bitfields
This changes various flags struct cmd_list_element into bitfields. In general I think bitfields are cleaner than flag words, at least in a case like this where there is no need to pass the flags around independently of the enclosing struct. 2014-01-20 Tom Tromey <tromey@redhat.com> * cli/cli-decode.c (add_cmd, deprecate_cmd, add_alias_cmd) (add_setshow_cmd_full, delete_cmd, lookup_cmd_1) (deprecated_cmd_warning, complete_on_cmdlist): Update. * cli/cli-decode.h (CMD_DEPRECATED, DEPRECATED_WARN_USER) (MALLOCED_REPLACEMENT, DOC_ALLOCATED): Remove. (struct cmd_list_element) <flags>: Remove. <cmd_deprecated, deprecated_warn_user, malloced_replacement, doc_allocated>: New fields. <hook_in, allow_unknown, abbrev_flag, type, var_type>: Now bitfields. * maint.c (maintenance_do_deprecate): Update. * top.c (execute_command): Update.
Diffstat (limited to 'gdb/cli/cli-decode.c')
-rw-r--r--gdb/cli/cli-decode.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 853ec88..d36ab4e 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -226,7 +226,10 @@ add_cmd (const char *name, enum command_class class, void (*fun) (char *, int),
set_cmd_cfunc (c, fun);
set_cmd_context (c, NULL);
c->doc = doc;
- c->flags = 0;
+ c->cmd_deprecated = 0;
+ c->deprecated_warn_user = 0;
+ c->malloced_replacement = 0;
+ c->doc_allocated = 0;
c->replacement = NULL;
c->pre_show_hook = NULL;
c->hook_in = 0;
@@ -261,7 +264,8 @@ add_cmd (const char *name, enum command_class class, void (*fun) (char *, int),
struct cmd_list_element *
deprecate_cmd (struct cmd_list_element *cmd, char *replacement)
{
- cmd->flags |= (CMD_DEPRECATED | DEPRECATED_WARN_USER);
+ cmd->cmd_deprecated = 1;
+ cmd->deprecated_warn_user = 1;
if (replacement != NULL)
cmd->replacement = replacement;
@@ -298,10 +302,10 @@ add_alias_cmd (const char *name, const char *oldname, enum command_class class,
c = add_cmd (name, class, NULL, old->doc, list);
/* If OLD->DOC can be freed, we should make another copy. */
- if ((old->flags & DOC_ALLOCATED) != 0)
+ if (old->doc_allocated)
{
c->doc = xstrdup (old->doc);
- c->flags |= DOC_ALLOCATED;
+ c->doc_allocated = 1;
}
/* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */
c->func = old->func;
@@ -448,7 +452,7 @@ add_setshow_cmd_full (const char *name,
}
set = add_set_or_show_cmd (name, set_cmd, class, var_type, var,
full_set_doc, set_list);
- set->flags |= DOC_ALLOCATED;
+ set->doc_allocated = 1;
if (set_func != NULL)
set_cmd_sfunc (set, set_func);
@@ -457,7 +461,7 @@ add_setshow_cmd_full (const char *name,
show = add_set_or_show_cmd (name, show_cmd, class, var_type, var,
full_show_doc, show_list);
- show->flags |= DOC_ALLOCATED;
+ show->doc_allocated = 1;
show->show_value_func = show_func;
if (set_result != NULL)
@@ -800,7 +804,7 @@ delete_cmd (const char *name, struct cmd_list_element **list,
*prehookee = iter->hookee_pre;
if (iter->hookee_post)
iter->hookee_post->hook_post = 0;
- if (iter->doc && (iter->flags & DOC_ALLOCATED) != 0)
+ if (iter->doc && iter->doc_allocated)
xfree (iter->doc);
*posthook = iter->hook_post;
*posthookee = iter->hookee_post;
@@ -1395,7 +1399,7 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
itself and we will adjust the appropriate DEPRECATED_WARN_USER
flags. */
- if (found->flags & DEPRECATED_WARN_USER)
+ if (found->deprecated_warn_user)
deprecated_cmd_warning (line);
found = found->cmd_pointer;
}
@@ -1600,14 +1604,14 @@ deprecated_cmd_warning (const char *text)
/* Return if text doesn't evaluate to a command. */
return;
- if (!((alias ? (alias->flags & DEPRECATED_WARN_USER) : 0)
- || (cmd->flags & DEPRECATED_WARN_USER) ) )
+ if (!((alias ? alias->deprecated_warn_user : 0)
+ || cmd->deprecated_warn_user) )
/* Return if nothing is deprecated. */
return;
printf_filtered ("Warning:");
- if (alias && !(cmd->flags & CMD_DEPRECATED))
+ if (alias && !cmd->cmd_deprecated)
printf_filtered (" '%s', an alias for the", alias->name);
printf_filtered (" command '");
@@ -1617,7 +1621,7 @@ deprecated_cmd_warning (const char *text)
printf_filtered ("%s", cmd->name);
- if (alias && (cmd->flags & CMD_DEPRECATED))
+ if (alias && cmd->cmd_deprecated)
printf_filtered ("' (%s) is deprecated.\n", alias->name);
else
printf_filtered ("' is deprecated.\n");
@@ -1626,7 +1630,7 @@ deprecated_cmd_warning (const char *text)
/* If it is only the alias that is deprecated, we want to indicate
the new alias, otherwise we'll indicate the new command. */
- if (alias && !(cmd->flags & CMD_DEPRECATED))
+ if (alias && !cmd->cmd_deprecated)
{
if (alias->replacement)
printf_filtered ("Use '%s'.\n\n", alias->replacement);
@@ -1643,9 +1647,9 @@ deprecated_cmd_warning (const char *text)
/* We've warned you, now we'll keep quiet. */
if (alias)
- alias->flags &= ~DEPRECATED_WARN_USER;
+ alias->deprecated_warn_user = 0;
- cmd->flags &= ~DEPRECATED_WARN_USER;
+ cmd->deprecated_warn_user = 0;
}
@@ -1787,7 +1791,7 @@ complete_on_cmdlist (struct cmd_list_element *list,
if (pass == 0)
{
- if ((ptr->flags & CMD_DEPRECATED) != 0)
+ if (ptr->cmd_deprecated)
{
saw_deprecated_match = 1;
continue;