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:
Tom Tromey
2017-09-10 14:19:19 -06:00
parent 7d221d749c
commit f1735a53a6
37 changed files with 154 additions and 125 deletions

View File

@@ -440,7 +440,7 @@ read_mapping (const char *line,
p++;
*endaddr = strtoulst (p, &p, 16);
p = skip_spaces_const (p);
p = skip_spaces (p);
*permissions = p;
while (*p && !isspace (*p))
p++;
@@ -448,7 +448,7 @@ read_mapping (const char *line,
*offset = strtoulst (p, &p, 16);
p = skip_spaces_const (p);
p = skip_spaces (p);
*device = p;
while (*p && !isspace (*p))
p++;
@@ -456,7 +456,7 @@ read_mapping (const char *line,
*inode = strtoulst (p, &p, 10);
p = skip_spaces_const (p);
p = skip_spaces (p);
*filename = p;
}
@@ -740,7 +740,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
pid = current_inferior ()->pid;
}
args = skip_spaces_const (args);
args = skip_spaces (args);
if (args && args[0])
error (_("Too many parameters: %s"), args);
@@ -870,7 +870,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
printf_filtered (_("Process: %s\n"),
pulongest (strtoulst (p, &p, 10)));
p = skip_spaces_const (p);
p = skip_spaces (p);
if (*p == '(')
{
/* ps command also relies on no trailing fields
@@ -884,7 +884,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
}
}
p = skip_spaces_const (p);
p = skip_spaces (p);
if (*p)
printf_filtered (_("State: %c\n"), *p++);