Allow /**/ comments in -f option files.

git-svn-id: file://localhost/svn/verilator/trunk/verilator@1037 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder
2008-04-24 15:36:46 +00:00
parent 7b870f4b2a
commit 0110f0193e
5 changed files with 67 additions and 3 deletions
+18 -3
View File
@@ -729,16 +729,31 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename) {
string whole_file;
string::size_type pos;
bool inCmt = false;
while (!ifp->eof()) {
string line;
getline(*ifp, line);
// Strip simple comments
if ((pos=line.find("//")) != string::npos) {
line.erase(pos);
string oline;
for (string::const_iterator pos = line.begin(); pos != line.end(); pos++) {
if (inCmt) {
if (*pos=='*' && *(pos+1)=='/') {
inCmt = false;
pos++;
}
} else if (*pos=='/' && *(pos+1)=='/') {
break; // Ignore to EOL
} else if (*pos=='/' && *(pos+1)=='*') {
inCmt = true;
pos++;
} else {
oline += *pos;
}
}
whole_file += line + " ";
whole_file += oline + " ";
}
whole_file += "\n"; // So string match below is simplified
if (inCmt) fl->v3error("Unterminated /* comment inside -f file.");
fl = new FileLine(filename, 0);