Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const, skip_to_space_const, get_number_const, extract_arg_const -- to drop the "_const" suffix and instead rely on overloading. This makes future const fixes simpler by reducing the number of lines that must be changed. I think it is also not any less clear, as all these functions have the same interface as their non-const versions by design. Furthermore there's an example of using an overload in-tree already, namely check_for_argument. This patch was largely created using some perl one-liners; then a few fixes were applied by hand. ChangeLog 2017-09-11 Tom Tromey <tom@tromey.com> * common/common-utils.h (skip_to_space): Remove macro, redeclare as function. (skip_to_space): Rename from skip_to_space_const. * common/common-utils.c (skip_to_space): New function. (skip_to_space): Rename from skip_to_space_const. * cli/cli-utils.h (get_number): Rename from get_number_const. (extract_arg): Rename from extract_arg_const. * cli/cli-utils.c (get_number): Rename from get_number_const. (extract_arg): Rename from extract_arg_const. (number_or_range_parser::get_number): Use ::get_number. * aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c, break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c, cli/cli-script.c, cli/cli-setshow.c, compile/compile.c, completer.c, demangle.c, disasm.c, findcmd.c, linespec.c, linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c, minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c, python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c, stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
This commit is contained in:
parent
7d221d749c
commit
f1735a53a6
37 changed files with 154 additions and 125 deletions
|
@ -93,7 +93,7 @@ get_number_trailer (const char **pp, int trailer)
|
|||
++p;
|
||||
retval = 0;
|
||||
}
|
||||
p = skip_spaces_const (p);
|
||||
p = skip_spaces (p);
|
||||
*pp = p;
|
||||
return retval;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ get_number_trailer (const char **pp, int trailer)
|
|||
/* See documentation in cli-utils.h. */
|
||||
|
||||
int
|
||||
get_number_const (const char **pp)
|
||||
get_number (const char **pp)
|
||||
{
|
||||
return get_number_trailer (pp, '\0');
|
||||
}
|
||||
|
@ -172,8 +172,8 @@ number_or_range_parser::get_number ()
|
|||
and also remember the end of the final token. */
|
||||
|
||||
temp = &m_end_ptr;
|
||||
m_end_ptr = skip_spaces_const (m_cur_tok + 1);
|
||||
m_end_value = get_number_const (temp);
|
||||
m_end_ptr = skip_spaces (m_cur_tok + 1);
|
||||
m_end_value = ::get_number (temp);
|
||||
if (m_end_value < m_last_retval)
|
||||
{
|
||||
error (_("inverted range"));
|
||||
|
@ -250,7 +250,7 @@ remove_trailing_whitespace (const char *start, const char *s)
|
|||
/* See documentation in cli-utils.h. */
|
||||
|
||||
char *
|
||||
extract_arg_const (const char **arg)
|
||||
extract_arg (const char **arg)
|
||||
{
|
||||
const char *result;
|
||||
|
||||
|
@ -258,13 +258,13 @@ extract_arg_const (const char **arg)
|
|||
return NULL;
|
||||
|
||||
/* Find the start of the argument. */
|
||||
*arg = skip_spaces_const (*arg);
|
||||
*arg = skip_spaces (*arg);
|
||||
if (!**arg)
|
||||
return NULL;
|
||||
result = *arg;
|
||||
|
||||
/* Find the end of the argument. */
|
||||
*arg = skip_to_space_const (*arg + 1);
|
||||
*arg = skip_to_space (*arg + 1);
|
||||
|
||||
if (result == *arg)
|
||||
return NULL;
|
||||
|
@ -280,7 +280,7 @@ extract_arg (char **arg)
|
|||
const char *arg_const = *arg;
|
||||
char *result;
|
||||
|
||||
result = extract_arg_const (&arg_const);
|
||||
result = extract_arg (&arg_const);
|
||||
*arg += arg_const - *arg;
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue