/*
* Pick off one argument from a string and return the rest.
* Understands quotes.
*/
std::string one_argument (const std::string & argument, std::string & arg_first)
{
char cEnd;
std::string::const_iterator argp = argument.begin();
arg_first.erase();
while (argp != argument.end() && isspace (*argp))
argp++;
cEnd = ' ';
if (*argp == '\'' || *argp == '"')
cEnd = *argp++;
while (argp != argument.end()) {
if (*argp == cEnd) {
argp++;
break;
}
arg_first.append(1, (char)tolower(*argp));
argp++;
}
while (argp != argument.end() && isspace (*argp))
argp++;
return std::string(argp, argument.end());
}
Here's the original one_argument() from SMAUG FUSS 1.9:
Here's my version: