aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2014-07-21 20:43:04 -0600
committerTom Tromey <tromey@redhat.com>2014-07-24 11:30:04 -0600
commit64e61d290ec53c27767d0d828f01ab6ae95a7478 (patch)
treefe876ff19592c8cdec5d7f8d8e3bf9a07b5a6433 /gdb
parent429e55ea941f54f8e0481dd2048dc15af751ed71 (diff)
downloadgdb-64e61d290ec53c27767d0d828f01ab6ae95a7478.zip
gdb-64e61d290ec53c27767d0d828f01ab6ae95a7478.tar.gz
gdb-64e61d290ec53c27767d0d828f01ab6ae95a7478.tar.bz2
constify command prefix
This constifies the "prefix" argument to the various command-adding functions. 2014-07-24 Tom Tromey <tromey@redhat.com> * cli/cli-decode.c (print_help_for_command): Make "prefix" const. (add_prefix_cmd, add_abbrev_prefix_cmd, apropos_cmd, help_list) (help_cmd_list): Constify. (lookup_cmd): Update. * cli/cli-decode.h (struct cmd_list_element) <prefixname>: Now const. (help_cmd_list, apropos_cmd): Update. * cli/cli-script.c (show_user): Update. * cli/cli-setshow.c (cmd_show_list): Make "prefix" const. * cli/cli-setshow.h (cmd_show_list): Update. * command.h (add_prefix_cmd, add_abbrev_prefix_cmd, help_list) (cmd_show_list): Update. * guile/scm-cmd.c (cmdscm_destroyer): Update. * python/py-cmd.c (cmdpy_destroyer): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/cli/cli-decode.c21
-rw-r--r--gdb/cli/cli-decode.h6
-rw-r--r--gdb/cli/cli-script.c2
-rw-r--r--gdb/cli/cli-setshow.c2
-rw-r--r--gdb/cli/cli-setshow.h2
-rw-r--r--gdb/command.h8
-rw-r--r--gdb/guile/scm-cmd.c2
-rw-r--r--gdb/python/py-cmd.c2
9 files changed, 40 insertions, 22 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ce4893c..4c9bf41 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
2014-07-24 Tom Tromey <tromey@redhat.com>
+ * cli/cli-decode.c (print_help_for_command): Make "prefix" const.
+ (add_prefix_cmd, add_abbrev_prefix_cmd, apropos_cmd, help_list)
+ (help_cmd_list): Constify.
+ (lookup_cmd): Update.
+ * cli/cli-decode.h (struct cmd_list_element) <prefixname>: Now
+ const.
+ (help_cmd_list, apropos_cmd): Update.
+ * cli/cli-script.c (show_user): Update.
+ * cli/cli-setshow.c (cmd_show_list): Make "prefix" const.
+ * cli/cli-setshow.h (cmd_show_list): Update.
+ * command.h (add_prefix_cmd, add_abbrev_prefix_cmd, help_list)
+ (cmd_show_list): Update.
+ * guile/scm-cmd.c (cmdscm_destroyer): Update.
+ * python/py-cmd.c (cmdpy_destroyer): Update.
+
+2014-07-24 Tom Tromey <tromey@redhat.com>
+
* cli/cli-decode.c (deprecate_cmd): Make "replacement" const.
* cli/cli-decode.h (struct cmd_list_element) <replacement>: Now
const.
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index a08cc45..622cf5f 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -93,8 +93,8 @@ set_cmd_prefix (struct cmd_list_element *c, struct cmd_list_element **list)
}
static void
-print_help_for_command (struct cmd_list_element *c, char *prefix, int recurse,
- struct ui_file *stream);
+print_help_for_command (struct cmd_list_element *c, const char *prefix,
+ int recurse, struct ui_file *stream);
/* Set the callback function for the specified command. For each both
@@ -330,7 +330,7 @@ struct cmd_list_element *
add_prefix_cmd (const char *name, enum command_class class,
cmd_cfunc_ftype *fun,
char *doc, struct cmd_list_element **prefixlist,
- char *prefixname, int allow_unknown,
+ const char *prefixname, int allow_unknown,
struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
@@ -357,7 +357,8 @@ add_prefix_cmd (const char *name, enum command_class class,
struct cmd_list_element *
add_abbrev_prefix_cmd (const char *name, enum command_class class,
cmd_cfunc_ftype *fun, char *doc,
- struct cmd_list_element **prefixlist, char *prefixname,
+ struct cmd_list_element **prefixlist,
+ const char *prefixname,
int allow_unknown, struct cmd_list_element **list)
{
struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
@@ -883,7 +884,7 @@ add_com_alias (const char *name, const char *oldname, enum command_class class,
void
apropos_cmd (struct ui_file *stream,
struct cmd_list_element *commandlist,
- struct re_pattern_buffer *regex, char *prefix)
+ struct re_pattern_buffer *regex, const char *prefix)
{
struct cmd_list_element *c;
int returnvalue;
@@ -1011,7 +1012,7 @@ help_cmd (const char *command, struct ui_file *stream)
* If you call this routine with a class >= 0, it recurses.
*/
void
-help_list (struct cmd_list_element *list, char *cmdtype,
+help_list (struct cmd_list_element *list, const char *cmdtype,
enum command_class class, struct ui_file *stream)
{
int len;
@@ -1145,8 +1146,8 @@ print_doc_line (struct ui_file *stream, char *str)
If RECURSE is non-zero, also print one-line descriptions
of all prefixed subcommands. */
static void
-print_help_for_command (struct cmd_list_element *c, char *prefix, int recurse,
- struct ui_file *stream)
+print_help_for_command (struct cmd_list_element *c, const char *prefix,
+ int recurse, struct ui_file *stream)
{
fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
print_doc_line (stream, c->doc);
@@ -1179,7 +1180,7 @@ print_help_for_command (struct cmd_list_element *c, char *prefix, int recurse,
*/
void
help_cmd_list (struct cmd_list_element *list, enum command_class class,
- char *prefix, int recurse, struct ui_file *stream)
+ const char *prefix, int recurse, struct ui_file *stream)
{
struct cmd_list_element *c;
@@ -1505,7 +1506,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list, char *cmdtype,
values. */
int local_allow_unknown = (last_list ? last_list->allow_unknown :
allow_unknown);
- char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
+ const char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
struct cmd_list_element *local_list =
(last_list ? *(last_list->prefixlist) : list);
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 9cd887d..1ddafd3 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -156,7 +156,7 @@ struct cmd_list_element
plus any others needed to get to it. Should end in a space.
It is used before the word "command" in describing the
commands reached through this prefix. */
- char *prefixname;
+ const char *prefixname;
/* The prefix command of this command. */
struct cmd_list_element *prefix;
@@ -212,14 +212,14 @@ struct cmd_list_element
};
extern void help_cmd_list (struct cmd_list_element *, enum command_class,
- char *, int, struct ui_file *);
+ const char *, int, struct ui_file *);
/* Functions that implement commands about CLI commands. */
extern void help_cmd (const char *, struct ui_file *);
extern void apropos_cmd (struct ui_file *, struct cmd_list_element *,
- struct re_pattern_buffer *, char *);
+ struct re_pattern_buffer *, const char *);
/* Used to mark commands that don't do anything. If we just leave the
function field NULL, the command is interpreted as a help topic, or
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 7dc1ba4..1147073 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1707,7 +1707,7 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
if (c->prefixlist != NULL)
{
- char *prefixname = c->prefixname;
+ const char *prefixname = c->prefixname;
for (c = *c->prefixlist; c != NULL; c = c->next)
if (c->class == class_user || c->prefixlist != NULL)
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 61ff085..0f936a4 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -670,7 +670,7 @@ do_show_command (const char *arg, int from_tty, struct cmd_list_element *c)
/* Show all the settings in a list of show commands. */
void
-cmd_show_list (struct cmd_list_element *list, int from_tty, char *prefix)
+cmd_show_list (struct cmd_list_element *list, int from_tty, const char *prefix)
{
struct cleanup *showlist_chain;
struct ui_out *uiout = current_uiout;
diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h
index 7619bad..38a8148 100644
--- a/gdb/cli/cli-setshow.h
+++ b/gdb/cli/cli-setshow.h
@@ -29,6 +29,6 @@ extern void do_show_command (const char *arg, int from_tty,
struct cmd_list_element *c);
extern void cmd_show_list (struct cmd_list_element *list, int from_tty,
- char *prefix);
+ const char *prefix);
#endif /* !defined (CLI_SETSHOW_H) */
diff --git a/gdb/command.h b/gdb/command.h
index 1d63d2b..e676237 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -134,7 +134,7 @@ extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class
cmd_cfunc_ftype *fun,
char *,
struct cmd_list_element **,
- char *, int,
+ const char *, int,
struct cmd_list_element **);
extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
@@ -142,7 +142,7 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
cmd_cfunc_ftype *fun,
char *,
struct cmd_list_element
- **, char *, int,
+ **, const char *, int,
struct cmd_list_element
**);
@@ -224,7 +224,7 @@ extern VEC (char_ptr) *complete_on_enum (const char *const *enumlist,
/* Functions that implement commands about CLI commands. */
-extern void help_list (struct cmd_list_element *, char *,
+extern void help_list (struct cmd_list_element *, const char *,
enum command_class, struct ui_file *);
/* Method for show a set/show variable's VALUE on FILE. If this
@@ -374,7 +374,7 @@ extern void
/* Do a "show" command for each thing on a command list. */
-extern void cmd_show_list (struct cmd_list_element *, int, char *);
+extern void cmd_show_list (struct cmd_list_element *, int, const char *);
/* Used everywhere whenever at least one parameter is required and
none is specified. */
diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
index 57979c8..7b8e3a5 100644
--- a/gdb/guile/scm-cmd.c
+++ b/gdb/guile/scm-cmd.c
@@ -291,7 +291,7 @@ cmdscm_destroyer (struct cmd_list_element *self, void *context)
/* We allocated the name, doc string, and perhaps the prefix name. */
xfree ((char *) self->name);
xfree (self->doc);
- xfree (self->prefixname);
+ xfree ((char *) self->prefixname);
}
/* Called by gdb to invoke the command. */
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 524ba5a..f8f1f05 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -109,7 +109,7 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
name. */
xfree ((char *) self->name);
xfree (self->doc);
- xfree (self->prefixname);
+ xfree ((char *) self->prefixname);
do_cleanups (cleanup);
}