Make check_for_argument skip whitespace after arg itself
authorPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:08:50 +0000 (00:08 +0100)
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.

gdb/ChangeLog
gdb/ax-gdb.c
gdb/breakpoint.c
gdb/cli/cli-cmds.c
gdb/cli/cli-utils.c
gdb/cli/cli-utils.h

index 3843e12710bd79f39815bae8421e14cf4664144b..538db3a06b760746f00401588cc7128659baede3 100644 (file)
@@ -1,3 +1,13 @@
+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.
+
 2019-06-13  Pedro Alves  <palves@redhat.com>
 
        * thread.c (thread_apply_command): Adjust TID parsing.
index 778e89515b6da3dd2eb59324491831b19485cc8b..5872bec47777be0556735329104921e9fa4574a7 100644 (file)
@@ -2634,8 +2634,6 @@ agent_command_1 (const char *exp, int eval)
     {
       struct linespec_result canonical;
 
-      exp = skip_spaces (exp);
-
       event_location_up location
        = new_linespec_location (&exp, symbol_name_match_type::WILD);
       decode_line_full (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL,
index 80f343e1de6401abfc781157463401904495ff16..dce8a0f33f2bf6766222e085b9ca69230d6a13f3 100644 (file)
@@ -10896,10 +10896,7 @@ watch_maybe_just_location (const char *arg, int accessflag, int from_tty)
   if (arg
       && (check_for_argument (&arg, "-location", sizeof ("-location") - 1)
          || check_for_argument (&arg, "-l", sizeof ("-l") - 1)))
-    {
-      arg = skip_spaces (arg);
-      just_location = 1;
-    }
+    just_location = 1;
 
   watch_command_1 (arg, accessflag, from_tty, just_location, 0);
 }
index 5c44ba91287a1b79aa2d38d2b26bffab701231c5..62f4d7f0c5ed5f77118f0758c28c332818e929d9 100644 (file)
@@ -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"));
 
index c8b07f0b6bc853e325bb8f810c0668e74b0b773e..a24fe9278c745c65024b0c14b06bf1af7e88cb69 100644 (file)
@@ -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;
index d0161db0916633cacd085bdd664758d5956277b4..9425fb4c09d459bc6780db51f6c59c91ed9e4c5f 100644 (file)
@@ -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.  */
This page took 0.036502 seconds and 4 git commands to generate.