Internals: Favor std method. No functional change intended.

This commit is contained in:
Wilson Snyder 2020-10-09 17:46:55 -04:00
parent 7be343fd7c
commit 1ebf937a6c

View File

@ -26,6 +26,7 @@
#include "V3PreShell.h" #include "V3PreShell.h"
#include "V3String.h" #include "V3String.h"
#include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <stack> #include <stack>
@ -540,10 +541,7 @@ void V3PreProcImp::unputString(const string& strg) {
} }
void V3PreProcImp::unputDefrefString(const string& strg) { void V3PreProcImp::unputDefrefString(const string& strg) {
int multiline = 0; int multiline = std::count(strg.begin(), strg.end(), '\n');
for (size_t i = 0; i < strg.length(); i++) {
if (strg[i] == '\n') multiline++;
}
unputString(strg); unputString(strg);
// A define that inserts multiple newlines are really attributed to one source line, // A define that inserts multiple newlines are really attributed to one source line,
// so temporarily don't increment lineno. // so temporarily don't increment lineno.
@ -1320,7 +1318,7 @@ int V3PreProcImp::getStateToken() {
// multiline "..." without \ escapes. // multiline "..." without \ escapes.
// The spec is silent about this either way; simulators vary // The spec is silent about this either way; simulators vary
string::size_type pos; 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 + "\""); unputString(string("\"") + out + "\"");
statePop(); statePop();
goto next_tok; goto next_tok;