max is supposed to be.
JMarc: I assume you are intending to use this new method, getLongArg()?
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32770
a592a061-630c-0410-9148-
cb99ea01b6c8
#include "support/lstrings.h"
#include "support/lstrings.h"
#include <iostream>
#include <sstream>
#include <vector>
#include <iostream>
#include <sstream>
#include <vector>
-void splitArg(vector<string> & 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 arguments, treating the last argument as
+// continuing to eol.
+void splitArg(vector<string> & args, string const & str,
+ unsigned int max = UINT_MAX)
{
istringstream is(str);
while (is) {
{
istringstream is(str);
while (is) {
is >> c;
if (is) {
if (c == '"')
is >> c;
if (is) {
if (c == '"')
+ // get quote delimited argument
getline(is, s, '"');
else {
getline(is, s, '"');
else {
+ // get whitespace delimited argument
is.putback(c);
is >> s;
}
is.putback(c);
is >> s;
}
string FuncRequest::getArg(unsigned int i) const
{
vector<string> args;
string FuncRequest::getArg(unsigned int i) const
{
vector<string> args;
- splitArg(args, to_utf8(argument_), string::npos);
+ splitArg(args, to_utf8(argument_));
return i < args.size() ? args[i] : string();
}
return i < args.size() ? args[i] : string();
}