ENH: clean up returns from input, so we can read dos files on unix

This commit is contained in:
Bill Hoffman 2001-10-05 17:31:29 -04:00
parent c1fa8454a1
commit d0aec59356
1 changed files with 14 additions and 1 deletions

View File

@ -484,6 +484,18 @@ const char *cmSystemTools::ConvertToWindowsSlashesAndCleanUp(std::string& path)
return path.c_str();
}
inline void CleanText(char* s)
{
while(*s != 0)
{
if(*s == '\r')
{
*s = ' ';
}
s++;
}
}
bool cmSystemTools::ParseFunction(std::ifstream& fin,
std::string& name,
std::vector<std::string>& arguments,
@ -497,9 +509,9 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
{
return false;
}
if(fin.getline(inbuffer, BUFFER_SIZE ) )
{
CleanText(&inbuffer[0]);
cmRegularExpression blankLine("^[ \t]*$");
cmRegularExpression comment("^[ \t]*#.*$");
cmRegularExpression oneLiner("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)\\)[ \t]*$");
@ -534,6 +546,7 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
// read lines until the end paren is found
if(fin.getline(inbuffer, BUFFER_SIZE ) )
{
CleanText(&inbuffer[0]);
// Check for comment lines and ignore them.
if(blankLine.find(inbuffer) || comment.find(inbuffer))
{ continue; }