aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-09-10 14:19:19 -0600
committerTom Tromey <tom@tromey.com>2017-09-11 15:46:12 -0600
commitf1735a53a63040cc4b4a735bf18a3f20d308e519 (patch)
treeed2e6da354b27e174e0617a15c18a193fbaa8497 /gdb/common
parent7d221d749c0239f06ca571be6c9452cd22b5d582 (diff)
downloadgdb-f1735a53a63040cc4b4a735bf18a3f20d308e519.zip
gdb-f1735a53a63040cc4b4a735bf18a3f20d308e519.tar.gz
gdb-f1735a53a63040cc4b4a735bf18a3f20d308e519.tar.bz2
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.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/common-utils.c12
-rw-r--r--gdb/common/common-utils.h6
2 files changed, 13 insertions, 5 deletions
diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c
index e75a1b9..6b10d11 100644
--- a/gdb/common/common-utils.c
+++ b/gdb/common/common-utils.c
@@ -298,7 +298,7 @@ skip_spaces (char *chp)
/* A const-correct version of the above. */
const char *
-skip_spaces_const (const char *chp)
+skip_spaces (const char *chp)
{
if (chp == NULL)
return NULL;
@@ -310,7 +310,7 @@ skip_spaces_const (const char *chp)
/* See documentation in common-utils.h. */
const char *
-skip_to_space_const (const char *chp)
+skip_to_space (const char *chp)
{
if (chp == NULL)
return NULL;
@@ -319,6 +319,14 @@ skip_to_space_const (const char *chp)
return chp;
}
+/* See documentation in common-utils.h. */
+
+char *
+skip_to_space (char *chp)
+{
+ return (char *) skip_to_space ((const char *) chp);
+}
+
/* See common/common-utils.h. */
void
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
index 787bac9..6475c28 100644
--- a/gdb/common/common-utils.h
+++ b/gdb/common/common-utils.h
@@ -93,16 +93,16 @@ extern char *skip_spaces (char *inp);
/* A const-correct version of the above. */
-extern const char *skip_spaces_const (const char *inp);
+extern const char *skip_spaces (const char *inp);
/* Skip leading non-whitespace characters in INP, returning an updated
pointer. If INP is NULL, return NULL. */
-#define skip_to_space(INP) ((char *) skip_to_space_const (INP))
+extern char *skip_to_space (char *inp);
/* A const-correct version of the above. */
-extern const char *skip_to_space_const (const char *inp);
+extern const char *skip_to_space (const char *inp);
/* Assumes that V is an argv for a program, and iterates through
freeing all the elements. */