constify command docs
This makes the command "doc" parameter const. 2014-07-24 Tom Tromey <tromey@redhat.com> * cli/cli-decode.c (add_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, add_set_or_show_cmd, add_info) (add_info_alias, add_com): Make "doc" const. (print_doc_line): Make "str" const. (delete_cmd): Update. * cli/cli-decode.h (struct cmd_list_element) <doc>: Now const. (print_doc_line): Update. * cli/cli-script.c (document_command): Update. * command.h (add_cmd, add_prefix_cmd, add_abbrev_prefix_cmd) (add_com, add_info, add_info_alias): Update. * guile/scm-cmd.c (cmdscm_destroyer): Update. * python/py-cmd.c (cmdpy_destroyer): Update.
This commit is contained in:
parent
64e61d290e
commit
1947513d92
8 changed files with 45 additions and 26 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2014-07-24 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* cli/cli-decode.c (add_cmd, add_prefix_cmd)
|
||||||
|
(add_abbrev_prefix_cmd, add_set_or_show_cmd, add_info)
|
||||||
|
(add_info_alias, add_com): Make "doc" const.
|
||||||
|
(print_doc_line): Make "str" const.
|
||||||
|
(delete_cmd): Update.
|
||||||
|
* cli/cli-decode.h (struct cmd_list_element) <doc>: Now const.
|
||||||
|
(print_doc_line): Update.
|
||||||
|
* cli/cli-script.c (document_command): Update.
|
||||||
|
* command.h (add_cmd, add_prefix_cmd, add_abbrev_prefix_cmd)
|
||||||
|
(add_com, add_info, add_info_alias): Update.
|
||||||
|
* guile/scm-cmd.c (cmdscm_destroyer): Update.
|
||||||
|
* python/py-cmd.c (cmdpy_destroyer): Update.
|
||||||
|
|
||||||
2014-07-24 Tom Tromey <tromey@redhat.com>
|
2014-07-24 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* cli/cli-decode.c (print_help_for_command): Make "prefix" const.
|
* cli/cli-decode.c (print_help_for_command): Make "prefix" const.
|
||||||
|
|
|
@ -183,7 +183,7 @@ set_cmd_completer (struct cmd_list_element *cmd, completer_ftype *completer)
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_cmd (const char *name, enum command_class class, cmd_cfunc_ftype *fun,
|
add_cmd (const char *name, enum command_class class, cmd_cfunc_ftype *fun,
|
||||||
char *doc, struct cmd_list_element **list)
|
const char *doc, struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *c
|
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));
|
||||||
|
@ -329,7 +329,7 @@ add_alias_cmd (const char *name, const char *oldname, enum command_class class,
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_prefix_cmd (const char *name, enum command_class class,
|
add_prefix_cmd (const char *name, enum command_class class,
|
||||||
cmd_cfunc_ftype *fun,
|
cmd_cfunc_ftype *fun,
|
||||||
char *doc, struct cmd_list_element **prefixlist,
|
const char *doc, struct cmd_list_element **prefixlist,
|
||||||
const char *prefixname, int allow_unknown,
|
const char *prefixname, int allow_unknown,
|
||||||
struct cmd_list_element **list)
|
struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
|
@ -356,7 +356,7 @@ add_prefix_cmd (const char *name, enum command_class class,
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_abbrev_prefix_cmd (const char *name, enum command_class class,
|
add_abbrev_prefix_cmd (const char *name, enum command_class class,
|
||||||
cmd_cfunc_ftype *fun, char *doc,
|
cmd_cfunc_ftype *fun, const char *doc,
|
||||||
struct cmd_list_element **prefixlist,
|
struct cmd_list_element **prefixlist,
|
||||||
const char *prefixname,
|
const char *prefixname,
|
||||||
int allow_unknown, struct cmd_list_element **list)
|
int allow_unknown, struct cmd_list_element **list)
|
||||||
|
@ -398,7 +398,7 @@ add_set_or_show_cmd (const char *name,
|
||||||
enum command_class class,
|
enum command_class class,
|
||||||
var_types var_type,
|
var_types var_type,
|
||||||
void *var,
|
void *var,
|
||||||
char *doc,
|
const char *doc,
|
||||||
struct cmd_list_element **list)
|
struct cmd_list_element **list)
|
||||||
{
|
{
|
||||||
struct cmd_list_element *c = add_cmd (name, class, NULL, doc, list);
|
struct cmd_list_element *c = add_cmd (name, class, NULL, doc, list);
|
||||||
|
@ -805,7 +805,7 @@ delete_cmd (const char *name, struct cmd_list_element **list,
|
||||||
if (iter->hookee_post)
|
if (iter->hookee_post)
|
||||||
iter->hookee_post->hook_post = 0;
|
iter->hookee_post->hook_post = 0;
|
||||||
if (iter->doc && iter->doc_allocated)
|
if (iter->doc && iter->doc_allocated)
|
||||||
xfree (iter->doc);
|
xfree ((char *) iter->doc);
|
||||||
*posthook = iter->hook_post;
|
*posthook = iter->hook_post;
|
||||||
*posthookee = iter->hookee_post;
|
*posthookee = iter->hookee_post;
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ delete_cmd (const char *name, struct cmd_list_element **list,
|
||||||
/* Add an element to the list of info subcommands. */
|
/* Add an element to the list of info subcommands. */
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_info (const char *name, cmd_cfunc_ftype *fun, char *doc)
|
add_info (const char *name, cmd_cfunc_ftype *fun, const char *doc)
|
||||||
{
|
{
|
||||||
return add_cmd (name, no_class, fun, doc, &infolist);
|
return add_cmd (name, no_class, fun, doc, &infolist);
|
||||||
}
|
}
|
||||||
|
@ -854,7 +854,7 @@ add_info (const char *name, cmd_cfunc_ftype *fun, char *doc)
|
||||||
/* Add an alias to the list of info subcommands. */
|
/* Add an alias to the list of info subcommands. */
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_info_alias (const char *name, char *oldname, int abbrev_flag)
|
add_info_alias (const char *name, const char *oldname, int abbrev_flag)
|
||||||
{
|
{
|
||||||
return add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);
|
return add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);
|
||||||
}
|
}
|
||||||
|
@ -863,7 +863,7 @@ add_info_alias (const char *name, char *oldname, int abbrev_flag)
|
||||||
|
|
||||||
struct cmd_list_element *
|
struct cmd_list_element *
|
||||||
add_com (const char *name, enum command_class class, cmd_cfunc_ftype *fun,
|
add_com (const char *name, enum command_class class, cmd_cfunc_ftype *fun,
|
||||||
char *doc)
|
const char *doc)
|
||||||
{
|
{
|
||||||
return add_cmd (name, class, fun, doc, &cmdlist);
|
return add_cmd (name, class, fun, doc, &cmdlist);
|
||||||
}
|
}
|
||||||
|
@ -1111,11 +1111,11 @@ help_all (struct ui_file *stream)
|
||||||
|
|
||||||
/* Print only the first line of STR on STREAM. */
|
/* Print only the first line of STR on STREAM. */
|
||||||
void
|
void
|
||||||
print_doc_line (struct ui_file *stream, char *str)
|
print_doc_line (struct ui_file *stream, const char *str)
|
||||||
{
|
{
|
||||||
static char *line_buffer = 0;
|
static char *line_buffer = 0;
|
||||||
static int line_size;
|
static int line_size;
|
||||||
char *p;
|
const char *p;
|
||||||
|
|
||||||
if (!line_buffer)
|
if (!line_buffer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,7 +128,7 @@ struct cmd_list_element
|
||||||
First line is brief documentation; remaining lines form, with it,
|
First line is brief documentation; remaining lines form, with it,
|
||||||
the full documentation. First line should end with a period.
|
the full documentation. First line should end with a period.
|
||||||
Entire string should also end with a period, not a newline. */
|
Entire string should also end with a period, not a newline. */
|
||||||
char *doc;
|
const char *doc;
|
||||||
|
|
||||||
/* For set/show commands. A method for printing the output to the
|
/* For set/show commands. A method for printing the output to the
|
||||||
specified stream. */
|
specified stream. */
|
||||||
|
@ -229,7 +229,7 @@ extern void not_just_help_class_command (char *arg, int from_tty);
|
||||||
|
|
||||||
/* Exported to cli/cli-setshow.c */
|
/* Exported to cli/cli-setshow.c */
|
||||||
|
|
||||||
extern void print_doc_line (struct ui_file *, char *);
|
extern void print_doc_line (struct ui_file *, const char *);
|
||||||
|
|
||||||
extern const char * const auto_boolean_enums[];
|
extern const char * const auto_boolean_enums[];
|
||||||
|
|
||||||
|
|
|
@ -1611,24 +1611,27 @@ document_command (char *comname, int from_tty)
|
||||||
doclines = read_command_lines (tmpbuf, from_tty, 0, 0, 0);
|
doclines = read_command_lines (tmpbuf, from_tty, 0, 0, 0);
|
||||||
|
|
||||||
if (c->doc)
|
if (c->doc)
|
||||||
xfree (c->doc);
|
xfree ((char *) c->doc);
|
||||||
|
|
||||||
{
|
{
|
||||||
struct command_line *cl1;
|
struct command_line *cl1;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
char *doc;
|
||||||
|
|
||||||
for (cl1 = doclines; cl1; cl1 = cl1->next)
|
for (cl1 = doclines; cl1; cl1 = cl1->next)
|
||||||
len += strlen (cl1->line) + 1;
|
len += strlen (cl1->line) + 1;
|
||||||
|
|
||||||
c->doc = (char *) xmalloc (len + 1);
|
doc = (char *) xmalloc (len + 1);
|
||||||
*c->doc = 0;
|
*doc = 0;
|
||||||
|
|
||||||
for (cl1 = doclines; cl1; cl1 = cl1->next)
|
for (cl1 = doclines; cl1; cl1 = cl1->next)
|
||||||
{
|
{
|
||||||
strcat (c->doc, cl1->line);
|
strcat (doc, cl1->line);
|
||||||
if (cl1->next)
|
if (cl1->next)
|
||||||
strcat (c->doc, "\n");
|
strcat (doc, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->doc = doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
free_command_lines (&doclines);
|
free_command_lines (&doclines);
|
||||||
|
|
|
@ -123,7 +123,7 @@ extern int valid_user_defined_cmd_name_p (const char *name);
|
||||||
|
|
||||||
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
|
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
|
||||||
cmd_cfunc_ftype *fun,
|
cmd_cfunc_ftype *fun,
|
||||||
char *,
|
const char *,
|
||||||
struct cmd_list_element **);
|
struct cmd_list_element **);
|
||||||
|
|
||||||
extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
|
extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
|
||||||
|
@ -132,7 +132,7 @@ extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
|
||||||
|
|
||||||
extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
|
extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
|
||||||
cmd_cfunc_ftype *fun,
|
cmd_cfunc_ftype *fun,
|
||||||
char *,
|
const char *,
|
||||||
struct cmd_list_element **,
|
struct cmd_list_element **,
|
||||||
const char *, int,
|
const char *, int,
|
||||||
struct cmd_list_element **);
|
struct cmd_list_element **);
|
||||||
|
@ -140,7 +140,7 @@ extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class
|
||||||
extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
|
extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
|
||||||
enum command_class,
|
enum command_class,
|
||||||
cmd_cfunc_ftype *fun,
|
cmd_cfunc_ftype *fun,
|
||||||
char *,
|
const char *,
|
||||||
struct cmd_list_element
|
struct cmd_list_element
|
||||||
**, const char *, int,
|
**, const char *, int,
|
||||||
struct cmd_list_element
|
struct cmd_list_element
|
||||||
|
@ -205,16 +205,17 @@ extern int lookup_cmd_composition (const char *text,
|
||||||
|
|
||||||
extern struct cmd_list_element *add_com (const char *, enum command_class,
|
extern struct cmd_list_element *add_com (const char *, enum command_class,
|
||||||
cmd_cfunc_ftype *fun,
|
cmd_cfunc_ftype *fun,
|
||||||
char *);
|
const char *);
|
||||||
|
|
||||||
extern struct cmd_list_element *add_com_alias (const char *, const char *,
|
extern struct cmd_list_element *add_com_alias (const char *, const char *,
|
||||||
enum command_class, int);
|
enum command_class, int);
|
||||||
|
|
||||||
extern struct cmd_list_element *add_info (const char *,
|
extern struct cmd_list_element *add_info (const char *,
|
||||||
cmd_cfunc_ftype *fun,
|
cmd_cfunc_ftype *fun,
|
||||||
char *);
|
const char *);
|
||||||
|
|
||||||
extern struct cmd_list_element *add_info_alias (const char *, char *, int);
|
extern struct cmd_list_element *add_info_alias (const char *, const char *,
|
||||||
|
int);
|
||||||
|
|
||||||
extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *,
|
extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *,
|
||||||
const char *, const char *, int);
|
const char *, const char *, int);
|
||||||
|
|
|
@ -290,7 +290,7 @@ cmdscm_destroyer (struct cmd_list_element *self, void *context)
|
||||||
|
|
||||||
/* We allocated the name, doc string, and perhaps the prefix name. */
|
/* We allocated the name, doc string, and perhaps the prefix name. */
|
||||||
xfree ((char *) self->name);
|
xfree ((char *) self->name);
|
||||||
xfree (self->doc);
|
xfree ((char *) self->doc);
|
||||||
xfree ((char *) self->prefixname);
|
xfree ((char *) self->prefixname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
|
||||||
/* We allocated the name, doc string, and perhaps the prefix
|
/* We allocated the name, doc string, and perhaps the prefix
|
||||||
name. */
|
name. */
|
||||||
xfree ((char *) self->name);
|
xfree ((char *) self->name);
|
||||||
xfree (self->doc);
|
xfree ((char *) self->doc);
|
||||||
xfree ((char *) self->prefixname);
|
xfree ((char *) self->prefixname);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
|
|
|
@ -2315,7 +2315,7 @@ static void
|
||||||
function_destroyer (struct cmd_list_element *self, void *ignore)
|
function_destroyer (struct cmd_list_element *self, void *ignore)
|
||||||
{
|
{
|
||||||
xfree ((char *) self->name);
|
xfree ((char *) self->name);
|
||||||
xfree (self->doc);
|
xfree ((char *) self->doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a new internal function. NAME is the name of the function; DOC
|
/* Add a new internal function. NAME is the name of the function; DOC
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue