ENH: better comment processing

This commit is contained in:
Bill Hoffman 2002-05-22 09:48:06 -04:00
parent ceb365813f
commit 2489a3583d
1 changed files with 19 additions and 4 deletions

View File

@ -743,6 +743,19 @@ std::string cmSystemTools::ConvertToWindowsOutputPath(const char* path)
return ret; return ret;
} }
inline void RemoveComments(char* ptr)
{
while(*ptr)
{
if(*ptr == '#')
{
*ptr = 0;
break;
}
++ptr;
}
}
bool cmSystemTools::ParseFunction(std::ifstream& fin, bool cmSystemTools::ParseFunction(std::ifstream& fin,
std::string& name, std::string& name,
std::vector<std::string>& arguments, std::vector<std::string>& arguments,
@ -760,14 +773,15 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
} }
if(fin.getline(inbuffer, BUFFER_SIZE ) ) if(fin.getline(inbuffer, BUFFER_SIZE ) )
{ {
RemoveComments(inbuffer);
cmRegularExpression blankLine("^[ \t\r]*$"); cmRegularExpression blankLine("^[ \t\r]*$");
cmRegularExpression comment("^[ \t]*#.*$"); // cmRegularExpression comment("^[ \t]*#.*$");
cmRegularExpression oneLiner("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)\\)[ \t\r]*$"); cmRegularExpression oneLiner("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)\\)[ \t\r]*$");
cmRegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$"); cmRegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$");
cmRegularExpression lastLine("^(.*)\\)[ \t\r]*$"); cmRegularExpression lastLine("^(.*)\\)[ \t\r]*$");
// check for black line or comment // check for blank line or comment
if(blankLine.find(inbuffer) || comment.find(inbuffer)) if(blankLine.find(inbuffer) )
{ {
return false; return false;
} }
@ -794,8 +808,9 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
// read lines until the end paren is found // read lines until the end paren is found
if(fin.getline(inbuffer, BUFFER_SIZE ) ) if(fin.getline(inbuffer, BUFFER_SIZE ) )
{ {
RemoveComments(inbuffer);
// Check for comment lines and ignore them. // Check for comment lines and ignore them.
if(blankLine.find(inbuffer) || comment.find(inbuffer)) if(blankLine.find(inbuffer))
{ continue; } { continue; }
// Is this the last line? // Is this the last line?
if(lastLine.find(inbuffer)) if(lastLine.find(inbuffer))