forked from github/verilator
Fix crash due to cygwin bug in getline, bug1349.
This commit is contained in:
parent
2a43410fa6
commit
15af706286
2
Changes
2
Changes
@ -16,6 +16,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
**** Fix hang on bad pattern keys, bug1364. [Matt Myers]
|
||||
|
||||
**** Fix crash due to cygwin bug in getline, bug1349. [Affe Mao]
|
||||
|
||||
|
||||
* Verilator 4.006 2018-10-27
|
||||
|
||||
|
@ -206,12 +206,12 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
|
||||
return false;
|
||||
}
|
||||
{
|
||||
string ignore; getline(*ifp, ignore);
|
||||
string ignore = V3Os::getline(*ifp);
|
||||
}
|
||||
{
|
||||
char chkDir; *ifp>>chkDir;
|
||||
char quote; *ifp>>quote;
|
||||
string chkCmdline; getline(*ifp, chkCmdline, '"');
|
||||
char chkDir; *ifp>>chkDir;
|
||||
char quote; *ifp>>quote;
|
||||
string chkCmdline = V3Os::getline(*ifp, '"');
|
||||
string cmdline = stripQuotes(cmdlineIn);
|
||||
if (cmdline != chkCmdline) {
|
||||
UINFO(2," --check-times failed: different command line\n");
|
||||
@ -228,8 +228,8 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
|
||||
time_t chkCnstime; *ifp>>chkCnstime;
|
||||
time_t chkMstime; *ifp>>chkMstime;
|
||||
time_t chkMnstime; *ifp>>chkMnstime;
|
||||
char quote; *ifp>>quote;
|
||||
string chkFilename; getline(*ifp, chkFilename, '"');
|
||||
char quote; *ifp>>quote;
|
||||
string chkFilename = V3Os::getline(*ifp, '"');
|
||||
|
||||
V3Options::fileNfsFlush(chkFilename);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
|
@ -1113,10 +1113,9 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
||||
string whole_file;
|
||||
bool inCmt = false;
|
||||
while (!ifp->eof()) {
|
||||
string line;
|
||||
getline(*ifp, line);
|
||||
// Strip simple comments
|
||||
string oline;
|
||||
string line = V3Os::getline(*ifp);
|
||||
// Strip simple comments
|
||||
string oline;
|
||||
// cppcheck-suppress StlMissingComparison
|
||||
for (string::const_iterator pos = line.begin(); pos != line.end(); ++pos) {
|
||||
if (inCmt) {
|
||||
|
15
src/V3Os.cpp
15
src/V3Os.cpp
@ -165,6 +165,21 @@ bool V3Os::filenameIsRel(const string& filename) {
|
||||
return (filename.length()>0 && filename[0] != '/');
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// File utilities
|
||||
|
||||
string V3Os::getline(std::istream& is, char delim) {
|
||||
string line;
|
||||
#if defined(__CYGWIN__) // Work around buggy implementation of getline
|
||||
char buf[65536];
|
||||
is.getline(buf, 65535, delim);
|
||||
line = buf;
|
||||
#else
|
||||
std::getline(is, line, delim);
|
||||
#endif
|
||||
return line;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// Directory utilities
|
||||
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
static string filenameRealPath(const string& filename); ///< Return realpath of filename
|
||||
static bool filenameIsRel(const string& filename); ///< True if relative
|
||||
|
||||
// METHODS (file utilities)
|
||||
static string getline(std::istream& is, char delim='\n');
|
||||
|
||||
// METHODS (directory utilities)
|
||||
static void createDir(const string& dirname);
|
||||
static void unlinkRegexp(const string& dir, const string& regexp);
|
||||
|
@ -42,10 +42,9 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) {
|
||||
VlcTest* testp = tests().newTest(filename, 0, 0);
|
||||
|
||||
while (!is.eof()) {
|
||||
string line;
|
||||
getline(is, line);
|
||||
//UINFO(9," got "<<line<<endl);
|
||||
if (line[0] == 'C') {
|
||||
string line = V3Os::getline(is);
|
||||
//UINFO(9," got "<<line<<endl);
|
||||
if (line[0] == 'C') {
|
||||
string::size_type secspace=3;
|
||||
for (; secspace<line.length(); secspace++) {
|
||||
if (line[secspace]=='\'' && line[secspace+1]==' ') break;
|
||||
@ -219,9 +218,8 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
|
||||
|
||||
int lineno = 0;
|
||||
while (!is.eof()) {
|
||||
lineno++;
|
||||
string line;
|
||||
getline(is, line);
|
||||
lineno++;
|
||||
string line = V3Os::getline(is);
|
||||
|
||||
bool first = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user