aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-decode.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cli/cli-decode.c')
-rw-r--r--gdb/cli/cli-decode.c94
1 files changed, 46 insertions, 48 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index a8f7747..61a7b5a 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -34,16 +34,16 @@
/* Prototypes for local functions. */
-static void undef_cmd_error (char *, char *);
+static void undef_cmd_error (const char *, const char *);
-static struct cmd_list_element *delete_cmd (char *name,
+static struct cmd_list_element *delete_cmd (const char *name,
struct cmd_list_element **list,
struct cmd_list_element **prehook,
struct cmd_list_element **prehookee,
struct cmd_list_element **posthook,
struct cmd_list_element **posthookee);
-static struct cmd_list_element *find_cmd (char *command,
+static struct cmd_list_element *find_cmd (const char *command,
int len,
struct cmd_list_element *clist,
int ignore_help_classes,
@@ -189,7 +189,7 @@ set_cmd_completer (struct cmd_list_element *cmd, completer_ftype *completer)
of *LIST). */
struct cmd_list_element *
-add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
+add_cmd (const char *name, enum command_class class, void (*fun) (char *, int),
char *doc, struct cmd_list_element **list)
{
struct cmd_list_element *c
@@ -278,18 +278,15 @@ deprecate_cmd (struct cmd_list_element *cmd, char *replacement)
}
struct cmd_list_element *
-add_alias_cmd (char *name, char *oldname, enum command_class class,
+add_alias_cmd (const char *name, const char *oldname, enum command_class class,
int abbrev_flag, struct cmd_list_element **list)
{
- /* Must do this since lookup_cmd tries to side-effect its first
- arg. */
- char *copied_name;
+ const char *tmp;
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);
+ tmp = oldname;
+ old = lookup_cmd (&tmp, *list, "", 1, 1);
if (old == 0)
{
@@ -333,7 +330,7 @@ add_alias_cmd (char *name, char *oldname, enum command_class class,
containing that list. */
struct cmd_list_element *
-add_prefix_cmd (char *name, enum command_class class,
+add_prefix_cmd (const char *name, enum command_class class,
void (*fun) (char *, int),
char *doc, struct cmd_list_element **prefixlist,
char *prefixname, int allow_unknown,
@@ -361,7 +358,7 @@ add_prefix_cmd (char *name, enum command_class class,
/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
struct cmd_list_element *
-add_abbrev_prefix_cmd (char *name, enum command_class class,
+add_abbrev_prefix_cmd (const char *name, enum command_class class,
void (*fun) (char *, int), char *doc,
struct cmd_list_element **prefixlist, char *prefixname,
int allow_unknown, struct cmd_list_element **list)
@@ -398,7 +395,7 @@ empty_sfunc (char *args, int from_tty, struct cmd_list_element *c)
DOC is the documentation string. */
static struct cmd_list_element *
-add_set_or_show_cmd (char *name,
+add_set_or_show_cmd (const char *name,
enum cmd_types type,
enum command_class class,
var_types var_type,
@@ -428,7 +425,7 @@ add_set_or_show_cmd (char *name,
structures. */
static void
-add_setshow_cmd_full (char *name,
+add_setshow_cmd_full (const char *name,
enum command_class class,
var_types var_type, void *var,
const char *set_doc, const char *show_doc,
@@ -481,7 +478,7 @@ add_setshow_cmd_full (char *name,
which will contain the matching string (from ENUMLIST). */
void
-add_setshow_enum_cmd (char *name,
+add_setshow_enum_cmd (const char *name,
enum command_class class,
const char *const *enumlist,
const char **var,
@@ -510,7 +507,7 @@ const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL };
variable which will contain the value. DOC is the documentation
string. FUNC is the corresponding callback. */
void
-add_setshow_auto_boolean_cmd (char *name,
+add_setshow_auto_boolean_cmd (const char *name,
enum command_class class,
enum auto_boolean *var,
const char *set_doc, const char *show_doc,
@@ -535,7 +532,7 @@ add_setshow_auto_boolean_cmd (char *name,
add_cmd. VAR is address of the variable which will contain the
value. SET_DOC and SHOW_DOC are the documentation strings. */
void
-add_setshow_boolean_cmd (char *name, enum command_class class, int *var,
+add_setshow_boolean_cmd (const char *name, enum command_class class, int *var,
const char *set_doc, const char *show_doc,
const char *help_doc,
cmd_sfunc_ftype *set_func,
@@ -557,7 +554,7 @@ add_setshow_boolean_cmd (char *name, enum command_class class, int *var,
/* Add element named NAME to both the set and show command LISTs (the
list for set/show or some sublist thereof). */
void
-add_setshow_filename_cmd (char *name, enum command_class class,
+add_setshow_filename_cmd (const char *name, enum command_class class,
char **var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -579,7 +576,7 @@ add_setshow_filename_cmd (char *name, enum command_class class,
/* Add element named NAME to both the set and show command LISTs (the
list for set/show or some sublist thereof). */
void
-add_setshow_string_cmd (char *name, enum command_class class,
+add_setshow_string_cmd (const char *name, enum command_class class,
char **var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -598,7 +595,7 @@ add_setshow_string_cmd (char *name, enum command_class class,
/* Add element named NAME to both the set and show command LISTs (the
list for set/show or some sublist thereof). */
struct cmd_list_element *
-add_setshow_string_noescape_cmd (char *name, enum command_class class,
+add_setshow_string_noescape_cmd (const char *name, enum command_class class,
char **var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -620,7 +617,7 @@ add_setshow_string_noescape_cmd (char *name, enum command_class class,
/* Add element named NAME to both the set and show command LISTs (the
list for set/show or some sublist thereof). */
void
-add_setshow_optional_filename_cmd (char *name, enum command_class class,
+add_setshow_optional_filename_cmd (const char *name, enum command_class class,
char **var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -647,7 +644,7 @@ add_setshow_optional_filename_cmd (char *name, enum command_class class,
value. SET_DOC and SHOW_DOC are the documentation strings. This
function is only used in Python API. Please don't use it elsewhere. */
void
-add_setshow_integer_cmd (char *name, enum command_class class,
+add_setshow_integer_cmd (const char *name, enum command_class class,
int *var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -668,7 +665,7 @@ add_setshow_integer_cmd (char *name, enum command_class class,
add_cmd. VAR is address of the variable which will contain the
value. SET_DOC and SHOW_DOC are the documentation strings. */
void
-add_setshow_uinteger_cmd (char *name, enum command_class class,
+add_setshow_uinteger_cmd (const char *name, enum command_class class,
unsigned int *var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -689,7 +686,7 @@ add_setshow_uinteger_cmd (char *name, enum command_class class,
add_cmd. VAR is address of the variable which will contain the
value. SET_DOC and SHOW_DOC are the documentation strings. */
void
-add_setshow_zinteger_cmd (char *name, enum command_class class,
+add_setshow_zinteger_cmd (const char *name, enum command_class class,
int *var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -706,7 +703,7 @@ add_setshow_zinteger_cmd (char *name, enum command_class class,
}
void
-add_setshow_zuinteger_unlimited_cmd (char *name,
+add_setshow_zuinteger_unlimited_cmd (const char *name,
enum command_class class,
int *var,
const char *set_doc,
@@ -729,7 +726,7 @@ add_setshow_zuinteger_unlimited_cmd (char *name,
add_cmd. VAR is address of the variable which will contain the
value. SET_DOC and SHOW_DOC are the documentation strings. */
void
-add_setshow_zuinteger_cmd (char *name, enum command_class class,
+add_setshow_zuinteger_cmd (const char *name, enum command_class class,
unsigned int *var,
const char *set_doc, const char *show_doc,
const char *help_doc,
@@ -753,7 +750,7 @@ add_setshow_zuinteger_cmd (char *name, enum command_class class,
set to NULL. */
static struct cmd_list_element *
-delete_cmd (char *name, struct cmd_list_element **list,
+delete_cmd (const char *name, struct cmd_list_element **list,
struct cmd_list_element **prehook,
struct cmd_list_element **prehookee,
struct cmd_list_element **posthook,
@@ -823,7 +820,7 @@ delete_cmd (char *name, struct cmd_list_element **list,
/* Add an element to the list of info subcommands. */
struct cmd_list_element *
-add_info (char *name, void (*fun) (char *, int), char *doc)
+add_info (const char *name, void (*fun) (char *, int), char *doc)
{
return add_cmd (name, no_class, fun, doc, &infolist);
}
@@ -831,7 +828,7 @@ add_info (char *name, void (*fun) (char *, int), char *doc)
/* Add an alias to the list of info subcommands. */
struct cmd_list_element *
-add_info_alias (char *name, char *oldname, int abbrev_flag)
+add_info_alias (const char *name, char *oldname, int abbrev_flag)
{
return add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);
}
@@ -839,7 +836,7 @@ add_info_alias (char *name, char *oldname, int abbrev_flag)
/* Add an element to the list of commands. */
struct cmd_list_element *
-add_com (char *name, enum command_class class, void (*fun) (char *, int),
+add_com (const char *name, enum command_class class, void (*fun) (char *, int),
char *doc)
{
return add_cmd (name, class, fun, doc, &cmdlist);
@@ -848,7 +845,7 @@ add_com (char *name, enum command_class class, void (*fun) (char *, int),
/* Add an alias or abbreviation command to the list of commands. */
struct cmd_list_element *
-add_com_alias (char *name, char *oldname, enum command_class class,
+add_com_alias (const char *name, const char *oldname, enum command_class class,
int abbrev_flag)
{
return add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist);
@@ -914,9 +911,10 @@ apropos_cmd (struct ui_file *stream,
help_list. */
void
-help_cmd (char *command, struct ui_file *stream)
+help_cmd (char *arg, struct ui_file *stream)
{
struct cmd_list_element *c;
+ const char *command = arg;
if (!command)
{
@@ -1184,7 +1182,7 @@ help_cmd_list (struct cmd_list_element *list, enum command_class class,
found in nfound. */
static struct cmd_list_element *
-find_cmd (char *command, int len, struct cmd_list_element *clist,
+find_cmd (const char *command, int len, struct cmd_list_element *clist,
int ignore_help_classes, int *nfound)
{
struct cmd_list_element *found, *c;
@@ -1305,13 +1303,13 @@ valid_user_defined_cmd_name_p (const char *name)
the struct cmd_list_element is NULL). */
struct cmd_list_element *
-lookup_cmd_1 (char **text, struct cmd_list_element *clist,
+lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
struct cmd_list_element **result_list, int ignore_help_classes)
{
char *command;
int len, tmp, nfound;
struct cmd_list_element *found, *c;
- char *line = *text;
+ const char *line = *text;
while (**text == ' ' || **text == '\t')
(*text)++;
@@ -1376,7 +1374,7 @@ lookup_cmd_1 (char **text, struct cmd_list_element *clist,
flags. */
if (found->flags & DEPRECATED_WARN_USER)
- deprecated_cmd_warning (&line);
+ deprecated_cmd_warning (line);
found = found->cmd_pointer;
}
/* If we found a prefix command, keep looking. */
@@ -1423,7 +1421,7 @@ lookup_cmd_1 (char **text, struct cmd_list_element *clist,
/* All this hair to move the space to the front of cmdtype */
static void
-undef_cmd_error (char *cmdtype, char *q)
+undef_cmd_error (const char *cmdtype, const char *q)
{
error (_("Undefined %scommand: \"%s\". Try \"help%s%.*s\"."),
cmdtype,
@@ -1448,7 +1446,7 @@ undef_cmd_error (char *cmdtype, char *q)
the function field of the struct cmd_list_element is 0). */
struct cmd_list_element *
-lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
+lookup_cmd (const char **line, struct cmd_list_element *list, char *cmdtype,
int allow_unknown, int ignore_help_classes)
{
struct cmd_list_element *last_list = 0;
@@ -1544,14 +1542,14 @@ lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
return 0;
}
-/* We are here presumably because an alias or command in *TEXT is
+/* We are here presumably because an alias or command in TEXT is
deprecated and a warning message should be generated. This
- function decodes *TEXT and potentially generates a warning message
+ function decodes TEXT and potentially generates a warning message
as outlined below.
Example for 'set endian big' which has a fictitious alias 'seb'.
- If alias wasn't used in *TEXT, and the command is deprecated:
+ If alias wasn't used in TEXT, and the command is deprecated:
"warning: 'set endian big' is deprecated."
If alias was used, and only the alias is deprecated:
@@ -1567,13 +1565,13 @@ lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
*/
void
-deprecated_cmd_warning (char **text)
+deprecated_cmd_warning (const char *text)
{
struct cmd_list_element *alias = NULL;
struct cmd_list_element *prefix_cmd = NULL;
struct cmd_list_element *cmd = NULL;
- if (!lookup_cmd_composition (*text, &alias, &prefix_cmd, &cmd))
+ if (!lookup_cmd_composition (text, &alias, &prefix_cmd, &cmd))
/* Return if text doesn't evaluate to a command. */
return;
@@ -1641,7 +1639,7 @@ deprecated_cmd_warning (char **text)
*/
int
-lookup_cmd_composition (char *text,
+lookup_cmd_composition (const char *text,
struct cmd_list_element **alias,
struct cmd_list_element **prefix_cmd,
struct cmd_list_element **cmd)
@@ -1738,7 +1736,8 @@ lookup_cmd_composition (char *text,
"oobar"; if WORD is "baz/foo", return "baz/foobar". */
VEC (char_ptr) *
-complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word,
+complete_on_cmdlist (struct cmd_list_element *list,
+ const char *text, const char *word,
int ignore_help_classes)
{
struct cmd_list_element *ptr;
@@ -1808,8 +1807,7 @@ complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word,
VEC (char_ptr) *
complete_on_enum (const char *const *enumlist,
- char *text,
- char *word)
+ const char *text, const char *word)
{
VEC (char_ptr) *matchlist = NULL;
int textlen = strlen (text);