diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-utils.c | 11 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 2cce068..62a2f12 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -234,3 +234,14 @@ skip_to_space (char *chp) chp++; return chp; } + +/* See documentation in cli-utils.h. */ + +char * +remove_trailing_whitespace (const char *start, char *s) +{ + while (s > start && isspace (*(s - 1))) + --s; + + return s; +} diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index 2954c46..8a6e5b3 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -99,4 +99,8 @@ extern char *skip_spaces (char *inp); extern char *skip_to_space (char *inp); +/* Reverse S to the last non-whitespace character without skipping past + START. */ + +extern char *remove_trailing_whitespace (const char *start, char *s); #endif /* CLI_UTILS_H */ |