ENH/BUG: Improved function parsing to allow just about anything inside a double-quoted argument. Also fixed parsing of lines with both quoted and non-quoted arguments.
This commit is contained in:
parent
5c74b6b90d
commit
41d198ed40
@ -198,10 +198,10 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
|
|||||||
if(fin.getline(inbuffer, BUFFER_SIZE ) )
|
if(fin.getline(inbuffer, BUFFER_SIZE ) )
|
||||||
{
|
{
|
||||||
cmRegularExpression blankLine("^$");
|
cmRegularExpression blankLine("^$");
|
||||||
cmRegularExpression comment("^#.*");
|
cmRegularExpression comment("^#.*$");
|
||||||
cmRegularExpression oneLiner("[ \t]*([A-Za-z_0-9]*).*\\((.*)\\)");
|
cmRegularExpression oneLiner("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)\\)[ \t]*$");
|
||||||
cmRegularExpression multiLine("[ \t]*([A-Za-z_0-9]*).*\\((.*)");
|
cmRegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$");
|
||||||
cmRegularExpression lastLine("(.*)\\)");
|
cmRegularExpression lastLine("^(.*)\\)[ \t]*$");
|
||||||
|
|
||||||
// BEGIN VERBATIM JUNK SHOULD BE REMOVED
|
// BEGIN VERBATIM JUNK SHOULD BE REMOVED
|
||||||
cmRegularExpression verbatim("BEGIN MAKE VERBATIM");
|
cmRegularExpression verbatim("BEGIN MAKE VERBATIM");
|
||||||
@ -294,25 +294,52 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
|
|||||||
void cmSystemTools::GetArguments(std::string& line,
|
void cmSystemTools::GetArguments(std::string& line,
|
||||||
std::vector<std::string>& arguments)
|
std::vector<std::string>& arguments)
|
||||||
{
|
{
|
||||||
cmRegularExpression argument("[\t ]*([-/\\.\\\\{}\\$A-Za-z_0-9]+)[\t ]*");
|
// Match a normal argument (not quoted, no spaces).
|
||||||
cmRegularExpression argumentWithSpaces("[\t ]*\"([-\\. /\\\\{}\\$A-Za-z_0-9]+)\"[\t ]*");
|
cmRegularExpression normalArgument("[\t ]*([^\" \t]+)[\t ]*");
|
||||||
std::string arg(" ");
|
// Match a quoted argument (surrounded by double quotes, spaces allowed).
|
||||||
while(arg.length() )
|
cmRegularExpression quotedArgument("[\t ]*(\"[^\"]*\")[\t ]*");
|
||||||
{
|
|
||||||
arg = "";
|
|
||||||
long endpos;
|
|
||||||
|
|
||||||
if (argumentWithSpaces.find(line.c_str()))
|
bool done = false;
|
||||||
|
while(!done)
|
||||||
{
|
{
|
||||||
arg = argumentWithSpaces.match(1);
|
std::string arg;
|
||||||
endpos = argumentWithSpaces.end(1);
|
long endpos;
|
||||||
}
|
bool foundQuoted = quotedArgument.find(line.c_str());
|
||||||
else if(argument.find(line.c_str()))
|
bool foundNormal = normalArgument.find(line.c_str());
|
||||||
|
|
||||||
|
if(foundQuoted && foundNormal)
|
||||||
{
|
{
|
||||||
arg = argument.match(1);
|
// Both matches were found. Take the earlier one.
|
||||||
endpos = argument.end(1);
|
if(normalArgument.start(1) < quotedArgument.start(1))
|
||||||
|
{
|
||||||
|
arg = normalArgument.match(1);
|
||||||
|
endpos = normalArgument.end(1);
|
||||||
}
|
}
|
||||||
if(arg.length())
|
else
|
||||||
|
{
|
||||||
|
arg = quotedArgument.match(1);
|
||||||
|
endpos = quotedArgument.end(1);
|
||||||
|
// Strip off the double quotes on the ends.
|
||||||
|
arg = arg.substr(1, arg.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (foundQuoted)
|
||||||
|
{
|
||||||
|
arg = quotedArgument.match(1);
|
||||||
|
endpos = quotedArgument.end(1);
|
||||||
|
// Strip off the double quotes on the ends.
|
||||||
|
arg = arg.substr(1, arg.length()-2);
|
||||||
|
}
|
||||||
|
else if(foundNormal)
|
||||||
|
{
|
||||||
|
arg = normalArgument.match(1);
|
||||||
|
endpos = normalArgument.end(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
if(!done)
|
||||||
{
|
{
|
||||||
arguments.push_back(arg);
|
arguments.push_back(arg);
|
||||||
line = line.substr(endpos, line.length() - endpos);
|
line = line.substr(endpos, line.length() - endpos);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user