diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-utils.c | 6 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 22 |
2 files changed, 23 insertions, 5 deletions
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index b353c18..8eac7c4 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -238,8 +238,8 @@ number_is_in_list (const char *list, int number) /* See documentation in cli-utils.h. */ -char * -remove_trailing_whitespace (const char *start, char *s) +const char * +remove_trailing_whitespace (const char *start, const char *s) { while (s > start && isspace (*(s - 1))) --s; @@ -288,7 +288,7 @@ extract_arg (char **arg) /* See documentation in cli-utils.h. */ int -check_for_argument (char **str, char *arg, int arg_len) +check_for_argument (const char **str, const char *arg, int arg_len) { if (strncmp (*str, arg, arg_len) == 0 && ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len]))) diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index c80bae0..9848a27 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -137,7 +137,16 @@ extern int number_is_in_list (const char *list, int number); /* Reverse S to the last non-whitespace character without skipping past START. */ -extern char *remove_trailing_whitespace (const char *start, char *s); +extern const char *remove_trailing_whitespace (const char *start, + const char *s); + +/* Same, for non-const S. */ + +static inline char * +remove_trailing_whitespace (const char *start, char *s) +{ + return (char *) remove_trailing_whitespace (start, (const char *) s); +} /* A helper function to extract an argument from *ARG. An argument is delimited by whitespace. The return value is either NULL if no @@ -156,6 +165,15 @@ extern char *extract_arg_const (const char **arg); 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. */ -extern int check_for_argument (char **str, char *arg, int arg_len); +extern int check_for_argument (const char **str, const char *arg, int arg_len); + +/* Same, for non-const STR. */ + +static inline int +check_for_argument (char **str, const char *arg, int arg_len) +{ + return check_for_argument (const_cast<const char **> (str), + arg, arg_len); +} #endif /* CLI_UTILS_H */ |