aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-06-13 00:06:52 +0100
committerPedro Alves <palves@redhat.com>2019-06-13 00:08:50 +0100
commitcbba3ecd36f0f861e4e810fbd5415c9759080cdc (patch)
tree0ff7941e323a33afd43355872000ab351762f195 /gdb/cli
parentb9a3f8429b012b753e30a4222bd8e4cbba019fad (diff)
downloadbinutils-cbba3ecd36f0f861e4e810fbd5415c9759080cdc.zip
binutils-cbba3ecd36f0f861e4e810fbd5415c9759080cdc.tar.gz
binutils-cbba3ecd36f0f861e4e810fbd5415c9759080cdc.tar.bz2
Make check_for_argument skip whitespace after arg itself
Basically every caller of check_for_argument needs to skip space after the argument. This patch makes check_for_argument do it itself. Suggested by Philippe Waroquiers. gdb/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * ax-gdb.c (agent_command_1): Remove skip_spaces call. * breakpoint.c (watch_maybe_just_location): Remove skip_spaces call. * cli/cli-cmds.c (apropos_command): Remove skip_spaces call. * cli/cli-utils.c (extract_info_print_args): Remove skip_spaces calls. (check_for_argument): Skip spaces after argument.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c3
-rw-r--r--gdb/cli/cli-utils.c3
-rw-r--r--gdb/cli/cli-utils.h4
3 files changed, 4 insertions, 6 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 5c44ba9..62f4d7f 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1381,9 +1381,6 @@ apropos_command (const char *arg, int from_tty)
{
bool verbose = arg && check_for_argument (&arg, "-v", 2);
- if (verbose)
- arg = skip_spaces (arg);
-
if (arg == NULL || *arg == '\0')
error (_("REGEXP string is empty"));
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index c8b07f0..a24fe92 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -139,7 +139,6 @@ extract_info_print_args (const char **args,
/* Check for NAMEREGEXP or -- NAMEREGEXP. */
if (**args != '-' || check_for_argument (args, "--", 2))
{
- *args = skip_spaces (*args);
*regexp = *args;
*args = NULL;
return true;
@@ -155,7 +154,6 @@ extract_info_print_args (const char **args,
if (check_for_argument (args, "-q", 2))
{
*quiet = true;
- *args = skip_spaces (*args);
return true;
}
@@ -459,6 +457,7 @@ check_for_argument (const char **str, const char *arg, int arg_len)
&& ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len])))
{
*str += arg_len;
+ *str = skip_spaces (*str);
return 1;
}
return 0;
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index d0161db..9425fb4 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -188,7 +188,9 @@ extern std::string 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,
or be followed by whitespace. Returns 1 if it finds the argument,
- 0 otherwise. If the argument is found, it updates *STR. */
+ 0 otherwise. If the argument is found, it updates *STR to point
+ past the argument and past any whitespace following the
+ argument. */
extern int check_for_argument (const char **str, const char *arg, int arg_len);
/* Same, for non-const STR. */