X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFuncRequest.cpp;h=c7624c38ae336775ffe6e2da052f8ffac60dbb8b;hb=2098f1d8c20d51e63e670bcdc9da8996068975bf;hp=eeebca2891c6346a79582809b060aaed1ab4485d;hpb=fc3de8c1509c4fec4b924c711488f67d964bf8d6;p=lyx.git diff --git a/src/FuncRequest.cpp b/src/FuncRequest.cpp index eeebca2891..c7624c38ae 100644 --- a/src/FuncRequest.cpp +++ b/src/FuncRequest.cpp @@ -15,6 +15,7 @@ #include "support/lstrings.h" +#include #include #include #include @@ -76,7 +77,12 @@ mouse_button::state FuncRequest::button() const namespace { -void splitArg(vector & args, string const & str, unsigned int max) +// Extracts arguments from str into args. Arguments are delimted by +// whitespace or by double quotes. +// We extract at most max + 1 arguments, treating args[max] as +// continuing to eol. +void splitArg(vector & args, string const & str, + unsigned int max = UINT_MAX) { istringstream is(str); while (is) { @@ -92,8 +98,10 @@ void splitArg(vector & args, string const & str, unsigned int max) is >> c; if (is) { if (c == '"') + // get quote delimited argument getline(is, s, '"'); else { + // get whitespace delimited argument is.putback(c); is >> s; } @@ -107,7 +115,7 @@ void splitArg(vector & args, string const & str, unsigned int max) string FuncRequest::getArg(unsigned int i) const { vector args; - splitArg(args, to_utf8(argument_), string::npos); + splitArg(args, to_utf8(argument_)); return i < args.size() ? args[i] : string(); }