diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-utils.c | 14 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 13 |
2 files changed, 12 insertions, 15 deletions
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index a00bc52..d5273b5 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -249,36 +249,36 @@ remove_trailing_whitespace (const char *start, const char *s) /* See documentation in cli-utils.h. */ -char * +std::string extract_arg (const char **arg) { const char *result; if (!*arg) - return NULL; + return std::string (); /* Find the start of the argument. */ *arg = skip_spaces (*arg); if (!**arg) - return NULL; + return std::string (); result = *arg; /* Find the end of the argument. */ *arg = skip_to_space (*arg + 1); if (result == *arg) - return NULL; + return std::string (); - return savestring (result, *arg - result); + return std::string (result, *arg - result); } /* See documentation in cli-utils.h. */ -char * +std::string extract_arg (char **arg) { const char *arg_const = *arg; - char *result; + std::string result; result = extract_arg (&arg_const); *arg += arg_const - *arg; diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index 0c25a7e..a77954c 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -149,17 +149,14 @@ remove_trailing_whitespace (const char *start, 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 - argument was found, or an xmalloc'd string. */ + delimited by whitespace. The return value is empty if no argument + was found. */ -extern char *extract_arg (char **arg); +extern std::string extract_arg (char **arg); -/* A const-correct version of the above. +/* A const-correct version of the above. */ - Since the returned value is xmalloc'd, it eventually needs to be - xfree'ed, which prevents us from making it const as well. */ - -extern char *extract_arg (const char **arg); +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, |