Skip to content

Commit

Permalink
Internals: Iterator cleanup. No functional change intended.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnyder committed Nov 7, 2024
1 parent e47208d commit 2e1128b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 11 additions & 12 deletions src/V3Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,24 +418,23 @@ string V3Options::allArgsStringForHierBlock(bool forTop, bool forCMake) const {
string out;
bool stripArg = false;
bool stripArgIfNum = false;
for (std::list<string>::const_iterator it = m_impp->m_lineArgs.begin();
it != m_impp->m_lineArgs.end(); ++it) {
for (const string& arg : m_impp->m_lineArgs) {
if (stripArg) {
stripArg = false;
continue;
}
if (stripArgIfNum) {
stripArgIfNum = false;
if (isdigit((*it)[0])) continue;
if (isdigit(arg[0])) continue;
}
int skip = 0;
if (it->length() >= 2 && (*it)[0] == '-' && (*it)[1] == '-') {
if (arg.length() >= 2 && arg[0] == '-' && arg[1] == '-') {
skip = 2;
} else if (it->length() >= 1 && (*it)[0] == '-') {
} else if (arg.length() >= 1 && arg[0] == '-') {
skip = 1;
}
if (skip > 0) { // *it is an option
const string opt = it->substr(skip); // Remove '-' in the beginning
if (skip > 0) { // arg is an option
const string opt = arg.substr(skip); // Remove '-' in the beginning
const int numStrip = stripOptionsForChildRun(opt, forTop);
if (numStrip) {
UASSERT(0 <= numStrip && numStrip <= 3, "should be one of 0, 1, 2, 3");
Expand All @@ -444,15 +443,15 @@ string V3Options::allArgsStringForHierBlock(bool forTop, bool forCMake) const {
continue;
}
} else { // Not an option
if ((forCMake && vFiles.find(*it) != vFiles.end()) // Remove HDL
|| m_cppFiles.find(*it) != m_cppFiles.end()) { // Remove C++
if ((forCMake && vFiles.find(arg) != vFiles.end()) // Remove HDL
|| m_cppFiles.find(arg) != m_cppFiles.end()) { // Remove C++
continue;
}
}
if (out != "") out += " ";
// Don't use opt here because '-' is removed in it
// Use double quote because *it may contain whitespaces
out += '"' + VString::quoteAny(*it, '"', '\\') + '"';
// Don't use opt here because '-' is removed in arg
// Use double quote because arg may contain whitespaces
out += '"' + VString::quoteAny(arg, '"', '\\') + '"';
}
return out;
}
Expand Down
4 changes: 2 additions & 2 deletions src/V3ParseImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ void V3ParseImp::preprocDumps(std::ostream& os, bool forInputs) {
for (auto& buf : m_ppBuffers) {
if (noblanks) {
bool blank = true;
for (string::iterator its = buf.begin(); its != buf.end(); ++its) {
if (!std::isspace(*its) && *its != '\n') {
for (const char ch : buf) {
if (!std::isspace(ch) && ch != '\n') {
blank = false;
break;
}
Expand Down

0 comments on commit 2e1128b

Please sign in to comment.