aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-03-13 18:34:55 +0000
committerPedro Alves <palves@redhat.com>2013-03-13 18:34:55 +0000
commit6f937416b997de1c0fb4664df3b7a69910b66b76 (patch)
treed66ba0c4f47f61e4d59446204692771d055db9d4 /gdb/cli
parent6dd24dfaecfff8a3a388bbd42e077956c2ec763d (diff)
downloadgdb-6f937416b997de1c0fb4664df3b7a69910b66b76.zip
gdb-6f937416b997de1c0fb4664df3b7a69910b66b76.tar.gz
gdb-6f937416b997de1c0fb4664df3b7a69910b66b76.tar.bz2
Constify strings in tracepoint.c, lookup_cmd and the completers.
This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c6
-rw-r--r--gdb/cli/cli-decode.c94
-rw-r--r--gdb/cli/cli-decode.h2
-rw-r--r--gdb/cli/cli-script.c17
-rw-r--r--gdb/cli/cli-script.h6
5 files changed, 64 insertions, 61 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 77da738..c05f77f 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1213,7 +1213,7 @@ show_user (char *args, int from_tty)
if (args)
{
- char *comname = args;
+ const char *comname = args;
c = lookup_cmd (&comname, cmdlist, "", 0, 1);
/* c->user_commands would be NULL if it's a python command. */
@@ -1291,7 +1291,7 @@ argv_to_dyn_string (char **argv, int n)
Return TRUE if COMMAND exists, unambiguously. Otherwise FALSE. */
static int
-valid_command_p (char *command)
+valid_command_p (const char *command)
{
struct cmd_list_element *c;
@@ -1400,7 +1400,7 @@ alias_command (char *args, int from_tty)
else
{
dyn_string_t alias_prefix_dyn_string, command_prefix_dyn_string;
- char *alias_prefix, *command_prefix;
+ const char *alias_prefix, *command_prefix;
struct cmd_list_element *c_alias, *c_command;
if (alias_argc != command_argc)
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);
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 47e3a3b..bf4dd1d 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -59,7 +59,7 @@ struct cmd_list_element
struct cmd_list_element *next;
/* Name of this command. */
- char *name;
+ const char *name;
/* Command class; class values are chosen by application program. */
enum command_class class;
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index a968866..3b24799 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1416,7 +1416,8 @@ validate_comname (char **comname)
if (last_word != *comname)
{
struct cmd_list_element *c;
- char saved_char, *tem = *comname;
+ char saved_char;
+ const char *tem = *comname;
/* Separate the prefix and the command. */
saved_char = last_word[-1];
@@ -1461,6 +1462,7 @@ define_command (char *comname, int from_tty)
struct command_line *cmds;
struct cmd_list_element *c, *newc, *hookc = 0, **list;
char *tem, *comfull;
+ const char *tem_c;
char tmpbuf[MAX_TMPBUF];
int hook_type = CMD_NO_HOOK;
int hook_name_size = 0;
@@ -1474,8 +1476,8 @@ define_command (char *comname, int from_tty)
list = validate_comname (&comname);
/* Look it up, and verify that we got an exact match. */
- tem = comname;
- c = lookup_cmd (&tem, *list, "", -1, 1);
+ tem_c = comname;
+ c = lookup_cmd (&tem_c, *list, "", -1, 1);
if (c && strcmp (comname, c->name) != 0)
c = 0;
@@ -1509,8 +1511,8 @@ define_command (char *comname, int from_tty)
if (hook_type != CMD_NO_HOOK)
{
/* Look up cmd it hooks, and verify that we got an exact match. */
- tem = comname + hook_name_size;
- hookc = lookup_cmd (&tem, *list, "", -1, 0);
+ tem_c = comname + hook_name_size;
+ hookc = lookup_cmd (&tem_c, *list, "", -1, 0);
if (hookc && strcmp (comname + hook_name_size, hookc->name) != 0)
hookc = 0;
if (!hookc)
@@ -1570,7 +1572,8 @@ document_command (char *comname, int from_tty)
{
struct command_line *doclines;
struct cmd_list_element *c, **list;
- char *tem, *comfull;
+ const char *tem;
+ char *comfull;
char tmpbuf[128];
comfull = comname;
@@ -1676,7 +1679,7 @@ script_from_file (FILE *stream, const char *file)
(recursively). PREFIX and NAME combined are the name of the
current command. */
void
-show_user_1 (struct cmd_list_element *c, char *prefix, char *name,
+show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
struct ui_file *stream)
{
struct command_line *cmdlines;
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index d02cb36..31db811 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -25,8 +25,10 @@ struct cmd_list_element;
extern void script_from_file (FILE *stream, const char *file);
-extern void show_user_1 (struct cmd_list_element *c, char *prefix,
- char *name, struct ui_file *stream);
+extern void show_user_1 (struct cmd_list_element *c,
+ const char *prefix,
+ const char *name,
+ struct ui_file *stream);
/* Exported to gdb/breakpoint.c */