Use skip_spaces and skip_to_space in ada-lang.c

This is just a minor cleanup that reduces a bit the code in ada-lang.c
by using skip_spaces or skip_to_space, instead of doing the skipping
ourselves.

gdb/ChangeLog:

        * ada-lang.c: #include "cli/cli-utils.h".
        (get_selections): Use skip_spaces.
        (ada_get_next_arg): Use skip_spaces and skip_to_space.
        (catch_ada_exception_command_split): Use skip_spaces.
        (ada_decode_assert_location): Likewise.
This commit is contained in:
Joel Brobecker 2012-01-04 14:55:09 +00:00
parent 5e0a92a986
commit 0fcd72ba37
2 changed files with 14 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2012-01-04 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c: #include "cli/cli-utils.h".
(get_selections): Use skip_spaces.
(ada_get_next_arg): Use skip_spaces and skip_to_space.
(catch_ada_exception_command_split): Use skip_spaces.
(ada_decode_assert_location): Likewise.
2012-01-04 Joel Brobecker <brobecker@adacore.com> 2012-01-04 Joel Brobecker <brobecker@adacore.com>
* linespec.c (decode_line_internal): Check for C++ or Java * linespec.c (decode_line_internal): Check for C++ or Java

View File

@ -63,6 +63,7 @@
#include "mi/mi-common.h" #include "mi/mi-common.h"
#include "arch-utils.h" #include "arch-utils.h"
#include "exceptions.h" #include "exceptions.h"
#include "cli/cli-utils.h"
/* Define whether or not the C operator '/' truncates towards zero for /* Define whether or not the C operator '/' truncates towards zero for
differently signed operands (truncation direction is undefined in C). differently signed operands (truncation direction is undefined in C).
@ -3611,8 +3612,7 @@ get_selections (int *choices, int n_choices, int max_results,
char *args2; char *args2;
int choice, j; int choice, j;
while (isspace (*args)) args = skip_spaces (args);
args += 1;
if (*args == '\0' && n_chosen == 0) if (*args == '\0' && n_chosen == 0)
error_no_arg (_("one or more choice numbers")); error_no_arg (_("one or more choice numbers"));
else if (*args == '\0') else if (*args == '\0')
@ -11538,19 +11538,13 @@ ada_get_next_arg (char **argsp)
char *end; char *end;
char *result; char *result;
/* Skip any leading white space. */ args = skip_spaces (args);
while (isspace (*args))
args++;
if (args[0] == '\0') if (args[0] == '\0')
return NULL; /* No more arguments. */ return NULL; /* No more arguments. */
/* Find the end of the current argument. */ /* Find the end of the current argument. */
end = args; end = skip_to_space (args);
while (*end != '\0' && !isspace (*end))
end++;
/* Adjust ARGSP to point to the start of the next argument. */ /* Adjust ARGSP to point to the start of the next argument. */
@ -11584,8 +11578,7 @@ catch_ada_exception_command_split (char *args,
/* Check that we do not have any more arguments. Anything else /* Check that we do not have any more arguments. Anything else
is unexpected. */ is unexpected. */
while (isspace (*args)) args = skip_spaces (args);
args++;
if (args[0] != '\0') if (args[0] != '\0')
error (_("Junk at end of expression")); error (_("Junk at end of expression"));
@ -11818,8 +11811,7 @@ ada_decode_assert_location (char *args, char **addr_string,
if (args != NULL) if (args != NULL)
{ {
while (isspace (*args)) args = skip_spaces (args);
args++;
if (*args != '\0') if (*args != '\0')
error (_("Junk at end of arguments.")); error (_("Junk at end of arguments."));
} }