From: Richard Heck Date: Tue, 5 Jan 2010 15:01:32 +0000 (+0000) Subject: Kill warning: string::npos was the wrong type, and does not reflect what X-Git-Tag: 2.0.0~4584 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1ba5857f26ffda97decd3f56aeacb033fd063173;p=features.git Kill warning: string::npos was the wrong type, and does not reflect what 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 --- diff --git a/src/FuncRequest.cpp b/src/FuncRequest.cpp index eeebca2891..7755a86957 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 arguments, treating the last argument 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(); }