diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 23e3e3700..8553d9542 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -87,7 +87,7 @@ private: if (!nodep->isToggleCoverable()) return "Not relevant signal type"; if (!v3Global.opt.coverageUnderscore()) { - if (prettyName.c_str()[0] == '_') + if (prettyName[0] == '_') return "Leading underscore"; if (prettyName.find("._") != string::npos) return "Inlined leading underscore"; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 3f07d5fb5..68fd3a2cb 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -563,9 +563,9 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) { return false; } -bool V3Options::suffixed(const char* sw, const char* arg) { - if (strlen(arg) > strlen(sw)) return false; - return (0==strcmp(sw+strlen(sw)-strlen(arg), arg)); +bool V3Options::suffixed(const string& sw, const char* arg) { + if (strlen(arg) > sw.length()) return false; + return (0==strcmp(sw.c_str()+sw.length()-strlen(arg), arg)); } void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char** argv) { @@ -962,16 +962,16 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char else { // Filename string filename = parseFileArg(optdir,argv[i]); - if (suffixed(filename.c_str(), ".cpp") - || suffixed(filename.c_str(), ".cxx") - || suffixed(filename.c_str(), ".cc") - || suffixed(filename.c_str(), ".c") - || suffixed(filename.c_str(), ".sp")) { + if (suffixed(filename, ".cpp") + || suffixed(filename, ".cxx") + || suffixed(filename, ".cc") + || suffixed(filename, ".c") + || suffixed(filename, ".sp")) { V3Options::addCppFile(filename); } - else if (suffixed(filename.c_str(), ".a") - || suffixed(filename.c_str(), ".o") - || suffixed(filename.c_str(), ".so")) { + else if (suffixed(filename, ".a") + || suffixed(filename, ".o") + || suffixed(filename, ".so")) { V3Options::addLdLibs(filename); } else { diff --git a/src/V3Options.h b/src/V3Options.h index 53749713c..1f6435446 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -168,7 +168,7 @@ class V3Options { void showVersion(bool verbose); void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; } bool onoff(const char* sw, const char* arg, bool& flag); - bool suffixed(const char* sw, const char* arg); + bool suffixed(const string& sw, const char* arg); string parseFileArg(const string& optdir, const string& relfilename); bool parseLangExt(const char* swp, const char* langswp, const V3LangCode& lc); string filePathCheckOneDir(const string& modname, const string& dirname);