aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
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/cli
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/cli')
-rw-r--r--gdb/cli/cli-cmds.c4
-rw-r--r--gdb/cli/cli-dump.c8
-rw-r--r--gdb/cli/cli-script.c4
-rw-r--r--gdb/cli/cli-setshow.c2
-rw-r--r--gdb/cli/cli-utils.c16
-rw-r--r--gdb/cli/cli-utils.h8
6 files changed, 21 insertions, 21 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index a2041fa..883844e 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1240,7 +1240,7 @@ disassemble_command (char *arg, int from_tty)
}
}
- p = skip_spaces_const (p);
+ p = skip_spaces (p);
}
if ((flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE))
@@ -1277,7 +1277,7 @@ disassemble_command (char *arg, int from_tty)
/* Two arguments. */
int incl_flag = 0;
low = pc;
- p = skip_spaces_const (p);
+ p = skip_spaces (p);
if (p[0] == '+')
{
++p;
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 8e59ed4..8d57119 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -45,7 +45,7 @@ scan_expression (const char **cmd, const char *def)
end = (*cmd) + strcspn (*cmd, " \t");
exp = savestring ((*cmd), end - (*cmd));
- (*cmd) = skip_spaces_const (end);
+ (*cmd) = skip_spaces (end);
return gdb::unique_xmalloc_ptr<char> (exp);
}
}
@@ -71,10 +71,10 @@ scan_filename (const char **cmd, const char *defname)
/* FIXME: should parse a possibly quoted string. */
const char *end;
- (*cmd) = skip_spaces_const (*cmd);
+ (*cmd) = skip_spaces (*cmd);
end = *cmd + strcspn (*cmd, " \t");
filename.reset (savestring ((*cmd), end - (*cmd)));
- (*cmd) = skip_spaces_const (end);
+ (*cmd) = skip_spaces (end);
}
gdb_assert (filename != NULL);
@@ -538,7 +538,7 @@ restore_command (char *args_in, int from_tty)
{
binary_flag = 1;
args += strlen (binary_string);
- args = skip_spaces_const (args);
+ args = skip_spaces (args);
}
/* Parse offset (optional). */
if (args != NULL && *args != '\0')
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 9b2ffd0..02f66cc 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -888,7 +888,7 @@ line_first_arg (const char *p)
{
const char *first_arg = p + find_command_name_length (p);
- return skip_spaces_const (first_arg);
+ return skip_spaces (first_arg);
}
/* Process one input line. If the command is an "end", return such an
@@ -932,7 +932,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
const char *cmd_name = p;
struct cmd_list_element *cmd
= lookup_cmd_1 (&cmd_name, cmdlist, NULL, 1);
- cmd_name = skip_spaces_const (cmd_name);
+ cmd_name = skip_spaces (cmd_name);
bool inline_cmd = *cmd_name != '\0';
/* If commands are parsed, we skip initial spaces. Otherwise,
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index c6e5ebc..f89d268 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -134,7 +134,7 @@ is_unlimited_literal (const char *arg)
{
size_t len = sizeof ("unlimited") - 1;
- arg = skip_spaces_const (arg);
+ arg = skip_spaces (arg);
return (strncmp (arg, "unlimited", len) == 0
&& (isspace (arg[len]) || arg[len] == '\0'));
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index 8eac7c4..a00bc52 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -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;
}
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 9848a27..0c25a7e 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -33,9 +33,9 @@ extern int get_number_trailer (const char **pp, int trailer);
/* Convenience. Like get_number_trailer, but with no TRAILER. */
-extern int get_number_const (const char **);
+extern int get_number (const char **);
-/* Like get_number_const, but takes a non-const "char **". */
+/* Like the above, but takes a non-const "char **". */
extern int get_number (char **);
@@ -154,12 +154,12 @@ remove_trailing_whitespace (const char *start, char *s)
extern char *extract_arg (char **arg);
-/* A const-correct version of "extract_arg".
+/* A const-correct version of the above.
Since the returned value is xmalloc'd, it eventually needs to be
xfree'ed, which prevents us from making it const as well. */
-extern char *extract_arg_const (const char **arg);
+extern char *extract_arg (const char **arg);
/* A helper function that looks for an argument at the start of a
string. The argument must also either be at the end of the string,