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.
This commit is contained in:
Tom Tromey
2013-12-26 22:04:40 -07:00
parent cec2c50d38
commit 1f2bdf09c6
5 changed files with 85 additions and 61 deletions

View File

@@ -615,28 +615,40 @@ maintenance_do_deprecate (char *text, int deprecate)
memory. */
if (alias)
{
if (alias->flags & MALLOCED_REPLACEMENT)
if (alias->malloced_replacement)
xfree (alias->replacement);
if (deprecate)
alias->flags |= (DEPRECATED_WARN_USER | CMD_DEPRECATED);
{
alias->deprecated_warn_user = 1;
alias->cmd_deprecated = 1;
}
else
alias->flags &= ~(DEPRECATED_WARN_USER | CMD_DEPRECATED);
{
alias->deprecated_warn_user = 0;
alias->cmd_deprecated = 0;
}
alias->replacement = replacement;
alias->flags |= MALLOCED_REPLACEMENT;
alias->malloced_replacement = 1;
return;
}
else if (cmd)
{
if (cmd->flags & MALLOCED_REPLACEMENT)
if (cmd->malloced_replacement)
xfree (cmd->replacement);
if (deprecate)
cmd->flags |= (DEPRECATED_WARN_USER | CMD_DEPRECATED);
{
cmd->deprecated_warn_user = 1;
cmd->cmd_deprecated = 1;
}
else
cmd->flags &= ~(DEPRECATED_WARN_USER | CMD_DEPRECATED);
{
cmd->deprecated_warn_user = 0;
cmd->cmd_deprecated = 0;
}
cmd->replacement = replacement;
cmd->flags |= MALLOCED_REPLACEMENT;
cmd->malloced_replacement = 1;
return;
}
xfree (replacement);