Internals: Iterator cleanup. No functional change intended.

This commit is contained in:
Wilson Snyder 2024-11-06 19:21:03 -05:00
parent e47208d9b3
commit 2e1128b417
2 changed files with 13 additions and 14 deletions

View File

@ -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");
@ -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;
}

View File

@ -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;
}