forked from Imagelibrary/binutils-gdb
gdb: Allow quoting around string options in the gdb::option framework
Currently string options must be a single string with no whitespace, this limitation prevents the gdb::option framework being used in some places. After this commit, string options can be quoted in single or double quotes, and quote characters can be escaped with a backslash if needed to either place them within quotes, or to avoid starting a quoted argument. This test adds a new function extract_string_maybe_quoted which is basically a copy of extract_arg_maybe_quoted from cli/cli-utils.c, however, the cli-utils.c function will be deleted in the next commit. There are tests to exercise the new quoting mechanism. gdb/ChangeLog: * cli/cli-option.c (parse_option): Use extract_string_maybe_quoted to extract string arguments. * common/common-utils.c (extract_string_maybe_quoted): New function. * common/common-utils.h (extract_string_maybe_quoted): Declare. gdb/testsuite/ChangeLog: * gdb.base/options.exp (expect_string): Dequote strings in results. (test-string): Test strings with different quoting and reindent.
This commit is contained in:
@@ -94,6 +94,16 @@ void string_vappendf (std::string &dest, const char* fmt, va_list args)
|
||||
|
||||
char *savestring (const char *ptr, size_t len);
|
||||
|
||||
/* Extract the next word from ARG. The next word is defined as either,
|
||||
everything up to the next space, or, if the next word starts with either
|
||||
a single or double quote, then everything up to the closing quote. The
|
||||
enclosing quotes are not returned in the result string. The pointer in
|
||||
ARG is updated to point to the first character after the end of the
|
||||
word, or, for quoted words, the first character after the closing
|
||||
quote. */
|
||||
|
||||
std::string extract_string_maybe_quoted (const char **arg);
|
||||
|
||||
/* The strerror() function can return NULL for errno values that are
|
||||
out of range. Provide a "safe" version that always returns a
|
||||
printable string. */
|
||||
|
||||
Reference in New Issue
Block a user