diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index ec9047731..49adf7d48 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -26,6 +26,7 @@ #include "V3PreShell.h" #include "V3String.h" +#include #include #include #include @@ -540,10 +541,7 @@ void V3PreProcImp::unputString(const string& strg) { } void V3PreProcImp::unputDefrefString(const string& strg) { - int multiline = 0; - for (size_t i = 0; i < strg.length(); i++) { - if (strg[i] == '\n') multiline++; - } + int multiline = std::count(strg.begin(), strg.end(), '\n'); unputString(strg); // A define that inserts multiple newlines are really attributed to one source line, // so temporarily don't increment lineno. @@ -1320,7 +1318,7 @@ int V3PreProcImp::getStateToken() { // multiline "..." without \ escapes. // The spec is silent about this either way; simulators vary string::size_type pos; - while ((pos = out.find('\n')) != string::npos) out.replace(pos, 1, " "); + std::replace(out.begin(), out.end(), '\n', ' '); unputString(string("\"") + out + "\""); statePop(); goto next_tok;