char *doc, struct cmd_list_element **list)
{
struct cmd_list_element *c
- = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
+ = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
struct cmd_list_element *p, *iter;
/* Turn each alias of the old command into an alias of the new
char *copied_name;
struct cmd_list_element *old;
struct cmd_list_element *c;
+
copied_name = (char *) alloca (strlen (oldname) + 1);
strcpy (copied_name, oldname);
old = lookup_cmd (&copied_name, *list, "", 1, 1);
struct cmd_list_element *aliases = delete_cmd (name, list,
&prehook, &prehookee,
&posthook, &posthookee);
+
/* If this happens, it means a programmer error somewhere. */
gdb_assert (!aliases && !prehook && !prehookee
&& !posthook && ! posthookee);
struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
+
c->prefixlist = prefixlist;
c->prefixname = prefixname;
c->allow_unknown = allow_unknown;
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
+
c->prefixlist = prefixlist;
c->prefixname = prefixname;
c->allow_unknown = allow_unknown;
struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, NULL, doc, list);
+
gdb_assert (type == set_cmd || type == show_cmd);
c->type = type;
c->var_type = var_type;
struct cmd_list_element **show_list)
{
struct cmd_list_element *c;
+
add_setshow_cmd_full (name, class, var_enum, var,
set_doc, show_doc, help_doc,
set_func, show_func,
{
static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL };
struct cmd_list_element *c;
+
add_setshow_cmd_full (name, class, var_auto_boolean, var,
set_doc, show_doc, help_doc,
set_func, show_func,
{
static const char *boolean_enums[] = { "on", "off", NULL };
struct cmd_list_element *c;
+
add_setshow_cmd_full (name, class, var_boolean, var,
set_doc, show_doc, help_doc,
set_func, show_func,
struct cmd_list_element **show_list)
{
struct cmd_list_element *set_result;
+
add_setshow_cmd_full (name, class, var_filename, var,
set_doc, show_doc, help_doc,
set_func, show_func,
*/
void
apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist,
- struct re_pattern_buffer *regex, char *prefix)
+ struct re_pattern_buffer *regex, char *prefix)
{
struct cmd_list_element *c;
int returnvalue;
+
/* Walk through the commands */
for (c=commandlist;c;c=c->next)
{
if (c->name != NULL)
{
/* Try to match against the name*/
- returnvalue=re_search(regex,c->name,strlen(c->name),0,strlen(c->name),NULL);
+ returnvalue = re_search (regex, c->name, strlen(c->name),
+ 0, strlen (c->name), NULL);
if (returnvalue >= 0)
{
print_help_for_command (c, prefix,
for (tmp = 0; tmp < len; tmp++)
{
char x = command[tmp];
+
command[tmp] = isupper (x) ? tolower (x) : x;
}
found = find_cmd (command, len, clist, ignore_help_classes, &nfound);
allow_unknown);
char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
struct cmd_list_element *local_list =
- (last_list ? *(last_list->prefixlist) : list);
+ (last_list ? *(last_list->prefixlist) : list);
if (local_allow_unknown < 0)
{
printf_filtered ("' is deprecated.\n");
- /* if it is only the alias that is deprecated, we want to indicate the
- new alias, otherwise we'll indicate the new command */
+ /* 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->replacement)
- printf_filtered ("Use '%s'.\n\n", alias->replacement);
+ printf_filtered ("Use '%s'.\n\n", alias->replacement);
else
- printf_filtered ("No alternative known.\n\n");
+ printf_filtered ("No alternative known.\n\n");
}
else
{
if (cmd->replacement)
- printf_filtered ("Use '%s'.\n\n", cmd->replacement);
+ printf_filtered ("Use '%s'.\n\n", cmd->replacement);
else
- printf_filtered ("No alternative known.\n\n");
+ printf_filtered ("No alternative known.\n\n");
}
/* We've warned you, now we'll keep quiet */
int len, tmp, nfound;
struct cmd_list_element *cur_list;
struct cmd_list_element *prev_cmd;
+
*alias = NULL;
*prefix_cmd = NULL;
*cmd = NULL;
while (1)
{
/* Go through as many command lists as we need to
- to find the command TEXT refers to. */
+ to find the command TEXT refers to. */
prev_cmd = *cmd;
while (*text == ' ' || *text == '\t')
- (text)++;
+ (text)++;
/* Identify the name of the command. */
len = find_command_name_length (text);
if (len == 0)
return 0;
- /* text is the start of the first command word to lookup (and
- it's length is len). We copy this into a local temporary */
+ /* Text is the start of the first command word to lookup (and
+ it's length is len). We copy this into a local temporary. */
command = (char *) alloca (len + 1);
memcpy (command, text, len);
*cmd = find_cmd (command, len, cur_list, 1, &nfound);
/* We didn't find the command in the entered case, so lower case it
- and search again.
+ and search again.
*/
if (!*cmd || nfound == 0)
- {
- for (tmp = 0; tmp < len; tmp++)
- {
- char x = command[tmp];
- command[tmp] = isupper (x) ? tolower (x) : x;
- }
- *cmd = find_cmd (command, len, cur_list, 1, &nfound);
- }
+ {
+ for (tmp = 0; tmp < len; tmp++)
+ {
+ char x = command[tmp];
+
+ command[tmp] = isupper (x) ? tolower (x) : x;
+ }
+ *cmd = find_cmd (command, len, cur_list, 1, &nfound);
+ }
if (*cmd == (struct cmd_list_element *) -1)
- {
- return 0; /* ambiguous */
- }
+ {
+ return 0; /* ambiguous */
+ }
if (*cmd == NULL)
- return 0; /* nothing found */
+ return 0; /* nothing found */
else
- {
- if ((*cmd)->cmd_pointer)
- {
- /* cmd was actually an alias, we note that an alias was used
- (by assigning *alais) and we set *cmd.
- */
- *alias = *cmd;
- *cmd = (*cmd)->cmd_pointer;
- }
- *prefix_cmd = prev_cmd;
- }
+ {
+ if ((*cmd)->cmd_pointer)
+ {
+ /* cmd was actually an alias, we note that an alias was used
+ (by assigning *alais) and we set *cmd. */
+ *alias = *cmd;
+ *cmd = (*cmd)->cmd_pointer;
+ }
+ *prefix_cmd = prev_cmd;
+ }
if ((*cmd)->prefixlist)
- cur_list = *(*cmd)->prefixlist;
+ cur_list = *(*cmd)->prefixlist;
else
- return 1;
+ return 1;
text += len;
}
list = cmd;
while (list)
{
-
if (depth)
ui_out_spaces (uiout, 2 * depth);
clear_hook_in_cleanup (void *data)
{
struct cmd_list_element *c = data;
+
c->hook_in = 0; /* Allow hook to work again once it is complete */
}
if ((c->hook_post) && (!c->hook_in))
{
struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
+
c->hook_in = 1; /* Prevent recursive hooking */
execute_user_command (c->hook_post, (char *) 0);
do_cleanups (cleanups);
static void
do_restore_user_call_depth (void * call_depth)
{
- int * depth = call_depth;
+ int *depth = call_depth;
+
(*depth)--;
if ((*depth) == 0)
in_user_command = 0;
case while_control:
{
char *buffer = alloca (strlen (cmd->line) + 7);
+
sprintf (buffer, "while %s", cmd->line);
print_command_trace (buffer);
case if_control:
{
char *buffer = alloca (strlen (cmd->line) + 4);
+
sprintf (buffer, "if %s", cmd->line);
print_command_trace (buffer);
arg_cleanup (void *ignore)
{
struct user_args *oargs = user_args;
+
if (!user_args)
internal_error (__FILE__, __LINE__,
_("arg_cleanup called with no user args.\n"));
i = p[4] - '0';
len = user_args->a[i].len;
if (len)
- {
- memcpy (new_line, user_args->a[i].arg, len);
- new_line += len;
- }
+ {
+ memcpy (new_line, user_args->a[i].arg, len);
+ new_line += len;
+ }
}
line = p + 5;
}
else if (p_end - p > 5 && !strncmp (p, "while", 5))
{
char *first_arg;
+
first_arg = p + 5;
while (first_arg < p_end && isspace (*first_arg))
first_arg++;
else if (p_end - p > 2 && !strncmp (p, "if", 2))
{
char *first_arg;
+
first_arg = p + 2;
while (first_arg < p_end && isspace (*first_arg))
first_arg++;
else if (p_end - p >= 8 && !strncmp (p, "commands", 8))
{
char *first_arg;
+
first_arg = p + 8;
while (first_arg < p_end && isspace (*first_arg))
first_arg++;
if (validator)
{
volatile struct gdb_exception ex;
+
TRY_CATCH (ex, RETURN_MASK_ALL)
{
validator ((*command)->line, closure);
if (c)
{
int q;
+
if (c->class == class_user || c->class == class_alias)
q = query (_("Redefine command \"%s\"? "), c->name);
else
source_cleanup_lines (void *args)
{
struct source_cleanup_lines_args *p =
- (struct source_cleanup_lines_args *) args;
+ (struct source_cleanup_lines_args *) args;
+
source_line_number = p->old_line;
source_file_name = p->old_file;
}
wrapped_read_command_file (struct ui_out *uiout, void *data)
{
struct wrapped_read_command_file_args *args = data;
+
read_command_file (args->stream);
}
{
struct gdb_exception e;
struct wrapped_read_command_file_args args;
+
args.stream = stream;
e = catch_exception (uiout, wrapped_read_command_file, &args,
RETURN_MASK_ERROR);
if (c->prefixlist != NULL)
{
char *prefixname = c->prefixname;
+
for (c = *c->prefixlist; c != NULL; c = c->next)
if (c->class == class_user || c->prefixlist != NULL)
show_user_1 (c, prefixname, c->name, gdb_stdout);
if (arg != NULL && *arg != '\0')
{
int length = strlen (arg);
+
while (isspace (arg[length - 1]) && length > 0)
length--;
if (strncmp (arg, "on", length) == 0
{
/* Clear trailing whitespace of filename. */
char *ptr = arg + strlen (arg) - 1;
+
while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
ptr--;
*(ptr + 1) = '\0';
case var_integer:
{
unsigned int val;
+
if (arg == NULL)
error_no_arg (_("integer to set it to."));
val = parse_and_eval_long (arg);
{
char *msg;
int msg_len = 0;
+
for (i = 0; c->enums[i]; i++)
msg_len += strlen (c->enums[i]) + 2;
else
{
char *value = ui_file_xstrdup (stb->stream, NULL);
+
make_cleanup (xfree, value);
if (c->show_value_func != NULL)
c->show_value_func (gdb_stdout, from_tty, c, value);
struct cleanup *optionlist_chain
= make_cleanup_ui_out_tuple_begin_end (uiout, "optionlist");
char *new_prefix = strstr (list->prefixname, "show ") + 5;
+
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "prefix", new_prefix);
cmd_show_list (*list->prefixlist, from_tty, new_prefix);
{
struct cleanup *option_chain
= make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+
ui_out_text (uiout, prefix);
ui_out_field_string (uiout, "name", list->name);
ui_out_text (uiout, ": ");