Internals: Add some std::. No functional change intended.

This commit is contained in:
Wilson Snyder 2023-02-10 20:32:35 -05:00
parent 8f87022496
commit 5aa4f46101
17 changed files with 104 additions and 99 deletions

View File

@ -87,8 +87,8 @@ string AstNode::encodeName(const string& namein) {
// Encode signal name raw from parser, then not called again on same signal
string out;
for (string::const_iterator pos = namein.begin(); pos != namein.end(); ++pos) {
if ((pos == namein.begin()) ? isalpha(pos[0]) // digits can't lead identifiers
: isalnum(pos[0])) {
if ((pos == namein.begin()) ? std::isalpha(pos[0]) // digits can't lead identifiers
: std::isalnum(pos[0])) {
out += pos[0];
} else if (pos[0] == '_') {
if (pos[1] == '_') {
@ -186,11 +186,14 @@ string AstNode::prettyName(const string& namein) {
pos += 7;
continue;
}
if (pos[0] == '_' && pos[1] == '_' && pos[2] == '0' && isxdigit(pos[3])
&& isxdigit(pos[4])) {
if (pos[0] == '_' && pos[1] == '_' && pos[2] == '0' && std::isxdigit(pos[3])
&& std::isxdigit(pos[4])) {
char value = 0;
value += 16 * (isdigit(pos[3]) ? (pos[3] - '0') : (tolower(pos[3]) - 'a' + 10));
value += (isdigit(pos[4]) ? (pos[4] - '0') : (tolower(pos[4]) - 'a' + 10));
value += 16
* (std::isdigit(pos[3]) ? (pos[3] - '0')
: (std::tolower(pos[3]) - 'a' + 10));
value
+= (std::isdigit(pos[4]) ? (pos[4] - '0') : (std::tolower(pos[4]) - 'a' + 10));
pretty += value;
pos += 5;
continue;
@ -232,11 +235,14 @@ string AstNode::vpiName(const string& namein) {
} else if (0 == std::strncmp(pos, "__PVT__", 7)) {
pos += 7;
continue;
} else if (pos[0] == '_' && pos[1] == '_' && pos[2] == '0' && isxdigit(pos[3])
&& isxdigit(pos[4])) {
} else if (pos[0] == '_' && pos[1] == '_' && pos[2] == '0' && std::isxdigit(pos[3])
&& std::isxdigit(pos[4])) {
char value = 0;
value += 16 * (isdigit(pos[3]) ? (pos[3] - '0') : (tolower(pos[3]) - 'a' + 10));
value += (isdigit(pos[4]) ? (pos[4] - '0') : (tolower(pos[4]) - 'a' + 10));
value += 16
* (std::isdigit(pos[3]) ? (pos[3] - '0')
: (std::tolower(pos[3]) - 'a' + 10));
value
+= (std::isdigit(pos[4]) ? (pos[4] - '0') : (std::tolower(pos[4]) - 'a' + 10));
// __ doesn't always imply escaped ident
if (value != '_') inEscapedIdent = true;

View File

@ -3094,12 +3094,12 @@ private:
if (!inPct && ch == '%') {
inPct = true;
fmt = ch;
} else if (inPct && (isdigit(ch) || ch == '.' || ch == '-')) {
} else if (inPct && (std::isdigit(ch) || ch == '.' || ch == '-')) {
fmt += ch;
} else if (inPct) {
inPct = false;
fmt += ch;
switch (tolower(ch)) {
switch (std::tolower(ch)) {
case '%': break; // %% - just output a %
case 'm': break; // %m - auto insert "name"
case 'l': break; // %l - auto insert "library"

View File

@ -155,7 +155,7 @@ void EmitCFunc::emitOpName(AstNode* nodep, const string& format, AstNode* lhsp,
puts("(");
} else {
// Normal text
if (isalnum(pos[0])) needComma = true;
if (std::isalnum(pos[0])) needComma = true;
COMMA;
string s;
s += pos[0];
@ -329,7 +329,7 @@ void EmitCFunc::displayNode(AstNode* nodep, AstScopeName* scopenamep, const stri
m_emitDispState.pushFormat(*pos);
} else { // Format character
inPct = false;
switch (tolower(pos[0])) {
switch (std::tolower(pos[0])) {
case '0': // FALLTHRU
case '1': // FALLTHRU
case '2': // FALLTHRU

View File

@ -633,7 +633,7 @@ bool V3OutFormatter::tokenMatch(const char* cp, const char* cmp) {
++cmp;
}
if (*cmp) return false;
if (*cp && !isspace(*cp)) return false;
if (*cp && !std::isspace(*cp)) return false;
return true;
}
@ -659,7 +659,7 @@ int V3OutFormatter::endLevels(const char* strg) {
int levels = m_indentLevel;
{
const char* cp = strg;
while (isspace(*cp)) ++cp;
while (std::isspace(*cp)) ++cp;
switch (*cp) {
case '\n': // Newlines.. No need for whitespace before it
return 0;
@ -669,7 +669,7 @@ int V3OutFormatter::endLevels(const char* strg) {
{
// label/public/private: Deindent by 2 spaces
const char* mp = cp;
for (; isalnum(*mp); ++mp) {}
for (; std::isalnum(*mp); ++mp) {}
if (mp[0] == ':' && mp[1] != ':') return (levels - m_blockIndent / 2);
}
}
@ -708,7 +708,7 @@ void V3OutFormatter::puts(const char* strg) {
bool equalsForBracket = false; // Looking for "= {"
for (const char* cp = strg; *cp; ++cp) {
putcNoTracking(*cp);
if (isalpha(*cp)) {
if (std::isalpha(*cp)) {
if (wordstart && m_lang == LA_VERILOG && tokenNotStart(cp)) notstart = true;
if (wordstart && m_lang == LA_VERILOG && !notstart && tokenStart(cp)) indentInc();
if (wordstart && m_lang == LA_VERILOG && tokenEnd(cp)) indentDec();
@ -870,7 +870,7 @@ string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::L
out += std::string{">"};
} else if (c == '&') {
out += std::string{"&"};
} else if (isprint(c)) {
} else if (std::isprint(c)) {
out += c;
} else {
out += std::string{"&#"} + cvtToStr((unsigned int)(c & 0xff)) + ";";
@ -887,7 +887,7 @@ string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::L
out += "\\r";
} else if (c == '\t') {
out += "\\t";
} else if (isprint(c)) {
} else if (std::isprint(c)) {
out += c;
} else {
// This will also cover \a etc
@ -942,7 +942,7 @@ void V3OutCFile::putsGuard() {
string var
= VString::upcase(std::string{"VERILATED_"} + V3Os::filenameNonDir(filename()) + "_");
for (char& c : var) {
if (!isalnum(c)) c = '_';
if (!std::isalnum(c)) c = '_';
}
puts("\n#ifndef " + var + "\n");
puts("#define " + var + " // guard\n");

View File

@ -210,26 +210,26 @@ void FileLine::lineDirective(const char* textp, int& enterExitRef) {
// will come from the same stream as the previous line.
// Skip `line
while (*textp && isspace(*textp)) textp++;
while (*textp && !isspace(*textp)) textp++;
while (*textp && (isspace(*textp) || *textp == '"')) textp++;
while (*textp && std::isspace(*textp)) ++textp;
while (*textp && !std::isspace(*textp)) ++textp;
while (*textp && (std::isspace(*textp) || *textp == '"')) ++textp;
// Grab linenumber
bool fail = false;
const char* const ln = textp;
while (*textp && !isspace(*textp)) textp++;
if (isdigit(*ln)) {
while (*textp && !std::isspace(*textp)) ++textp;
if (std::isdigit(*ln)) {
lineno(std::atoi(ln));
} else {
fail = true;
}
while (*textp && (isspace(*textp))) textp++;
while (*textp && (std::isspace(*textp))) ++textp;
if (*textp != '"') fail = true;
while (*textp && (isspace(*textp) || *textp == '"')) textp++;
while (*textp && (std::isspace(*textp) || *textp == '"')) ++textp;
// Grab filename
const char* const fn = textp;
while (*textp && !(isspace(*textp) || *textp == '"')) textp++;
while (*textp && !(std::isspace(*textp) || *textp == '"')) ++textp;
if (textp != fn) {
string strfn = fn;
strfn = strfn.substr(0, textp - fn);
@ -239,8 +239,8 @@ void FileLine::lineDirective(const char* textp, int& enterExitRef) {
}
// Grab level
while (*textp && (isspace(*textp) || *textp == '"')) textp++;
if (isdigit(*textp)) {
while (*textp && (std::isspace(*textp) || *textp == '"')) ++textp;
if (std::isdigit(*textp)) {
enterExitRef = std::atoi(textp);
if (enterExitRef >= 3) fail = true;
} else {

View File

@ -212,12 +212,12 @@ private:
inPct = true;
inIgnore = false;
fmt = ch;
} else if (inPct && (isdigit(ch) || ch == '.' || ch == '-')) {
} else if (inPct && (std::isdigit(ch) || ch == '.' || ch == '-')) {
fmt += ch;
} else if (inPct) {
inPct = false;
fmt += ch;
switch (tolower(ch)) {
switch (std::tolower(ch)) {
case '%': // %% - just output a %
break;
case '*':

View File

@ -153,7 +153,7 @@ void V3Number::create(const char* sourcep) {
if (*cp != '_') widthn += *cp;
}
while (*cp == '_') cp++;
if (*cp && tolower(*cp) == 's') {
if (*cp && std::tolower(*cp) == 's') {
cp++;
isSigned(true);
}
@ -191,11 +191,11 @@ void V3Number::create(const char* sourcep) {
width(1, false); // So we extend it
setBit(0, 1);
m_data.m_autoExtend = true;
} else if (tolower(base) == 'z') {
} else if (std::tolower(base) == 'z') {
width(1, false); // So we extend it
setBit(0, 'z');
m_data.m_autoExtend = true;
} else if (tolower(base) == 'x') {
} else if (std::tolower(base) == 'x') {
width(1, false); // So we extend it
setBit(0, 'x');
m_data.m_autoExtend = true;
@ -207,7 +207,7 @@ void V3Number::create(const char* sourcep) {
}
// Ignore leading blanks
while (*value_startp == '_' || isspace(*value_startp)) value_startp++;
while (*value_startp == '_' || std::isspace(*value_startp)) ++value_startp;
if (!*value_startp && !m_data.m_autoExtend) {
v3error("Number is missing value digits: " << sourcep);
}
@ -217,7 +217,7 @@ void V3Number::create(const char* sourcep) {
}
int obit = 0; // Start at LSB
if (tolower(base) == 'd') {
if (std::tolower(base) == 'd') {
// Ignore leading zeros so we don't issue too many digit errors when lots of leading 0's
while (*value_startp == '_' || *value_startp == '0') value_startp++;
// Convert decimal number to hex
@ -227,7 +227,7 @@ void V3Number::create(const char* sourcep) {
int got_z = 0;
int got_01 = 0;
for (const char* cp = value_startp; *cp; cp++) {
switch (tolower(*cp)) {
switch (std::tolower(*cp)) {
case '0': // FALLTHRU
case '1': // FALLTHRU
case '2': // FALLTHRU
@ -298,9 +298,9 @@ void V3Number::create(const char* sourcep) {
v3error("Too many digits for " << width() << " bit number: " << sourcep);
break;
}
switch (tolower(base)) {
switch (std::tolower(base)) {
case 'b': {
switch (tolower(*cp)) {
switch (std::tolower(*cp)) {
case '0': setBit(obit++, 0); break;
case '1': setBit(obit++, 1); break;
case 'z':
@ -314,7 +314,7 @@ void V3Number::create(const char* sourcep) {
case 'o':
case 'c': {
switch (tolower(*cp)) {
switch (std::tolower(*cp)) {
// clang-format off
case '0': setBit(obit++, 0); setBit(obit++, 0); setBit(obit++, 0); break;
case '1': setBit(obit++, 1); setBit(obit++, 0); setBit(obit++, 0); break;
@ -335,7 +335,7 @@ void V3Number::create(const char* sourcep) {
}
case 'h': {
switch (tolower(*cp)) {
switch (std::tolower(*cp)) {
// clang-format off
case '0': setBit(obit++,0); setBit(obit++,0); setBit(obit++,0); setBit(obit++,0); break;
case '1': setBit(obit++,1); setBit(obit++,0); setBit(obit++,0); setBit(obit++,0); break;
@ -575,7 +575,7 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const {
bool V3Number::displayedFmtLegal(char format, bool isScan) {
// Is this a valid format letter?
switch (tolower(format)) {
switch (std::tolower(format)) {
case 'b': return true;
case 'c': return true;
case 'd': return true; // Unsigned decimal
@ -619,11 +619,11 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
++pos;
}
string fmtsize;
for (; pos != vformat.cend() && (isdigit(pos[0]) || pos[0] == '.'); ++pos) {
for (; pos != vformat.cend() && (std::isdigit(pos[0]) || pos[0] == '.'); ++pos) {
fmtsize += pos[0];
}
string str;
const char code = tolower(pos[0]);
const char code = std::tolower(pos[0]);
switch (code) {
case 'b': // FALLTHRU
case 'o': // FALLTHRU
@ -2468,15 +2468,13 @@ V3Number& V3Number::opReplN(const V3Number& lhs, uint32_t rhsval) {
V3Number& V3Number::opToLowerN(const V3Number& lhs) {
NUM_ASSERT_OP_ARGS1(lhs);
NUM_ASSERT_STRING_ARGS1(lhs);
std::string out = lhs.toString();
for (auto& cr : out) cr = tolower(cr);
std::string out = VString::downcase(lhs.toString());
return setString(out);
}
V3Number& V3Number::opToUpperN(const V3Number& lhs) {
NUM_ASSERT_OP_ARGS1(lhs);
NUM_ASSERT_STRING_ARGS1(lhs);
std::string out = lhs.toString();
for (auto& cr : out) cr = toupper(cr);
std::string out = VString::upcase(lhs.toString());
return setString(out);
}

View File

@ -237,20 +237,20 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr
precr = VTimescale::NONE;
const char* cp = textp;
for (; isspace(*cp); ++cp) {}
for (; std::isspace(*cp); ++cp) {}
const char* const unitp = cp;
for (; *cp && *cp != '/'; ++cp) {}
const string unitStr(unitp, cp - unitp);
for (; isspace(*cp); ++cp) {}
for (; std::isspace(*cp); ++cp) {}
string precStr;
if (*cp == '/') {
++cp;
for (; isspace(*cp); ++cp) {}
for (; std::isspace(*cp); ++cp) {}
const char* const precp = cp;
for (; *cp && *cp != '/'; ++cp) {}
precStr = string(precp, cp - precp);
}
for (; isspace(*cp); ++cp) {}
for (; std::isspace(*cp); ++cp) {}
if (*cp) {
fl->v3error("`timescale syntax error: '" << textp << "'");
return;
@ -1295,8 +1295,8 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
fl->v3warn(DEPRECATED, "Option -O<letter> is deprecated. "
"Use -f<optimization> or -fno-<optimization> instead.");
for (const char* cp = optp; *cp; ++cp) {
const bool flag = isupper(*cp);
switch (tolower(*cp)) {
const bool flag = std::isupper(*cp);
switch (std::tolower(*cp)) {
case '0': optimize(0); break;
case '1': optimize(1); break;
case '2': optimize(2); break;
@ -1648,8 +1648,8 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|| !std::strcmp(argv[i], "--j")) { // Allow gnu -- switches
++i;
int val = 0;
if (i < argc && isdigit(argv[i][0])) {
val = atoi(argv[i]); // Can't be negative due to isdigit above
if (i < argc && std::isdigit(argv[i][0])) {
val = std::atoi(argv[i]); // Can't be negative due to isdigit above
if (val == 0) val = std::thread::hardware_concurrency();
++i;
}
@ -1718,7 +1718,8 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
++pos;
}
} else if (*pos == '/' && *(pos + 1) == '/'
&& (pos == line.begin() || isspace(lastch))) { // But allow /file//path
&& (pos == line.begin()
|| std::isspace(lastch))) { // But allow /file//path
break; // Ignore to EOL
} else if (*pos == '#' && space_begin) { // Only # at [spaced] begin of line
break; // Ignore to EOL
@ -1728,7 +1729,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
// cppcheck-suppress StlMissingComparison
++pos;
} else {
if (!isspace(*pos)) space_begin = false;
if (!std::isspace(*pos)) space_begin = false;
oline += *pos;
}
}
@ -1761,7 +1762,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
char curr_char = whole_file[pos];
switch (st) {
case ST_IN_OPTION: // Get all chars up to a white space or a "="
if (isspace(curr_char)) { // End of option
if (std::isspace(curr_char)) { // End of option
if (!arg.empty()) { // End of word
args.push_back(arg);
}

View File

@ -173,7 +173,7 @@ string V3Os::filenameSubstitute(const string& filename) {
string::size_type endpos = pos + 1;
while (((endpos + 1) < filename.length())
&& (((brackets == NONE)
&& (isalnum(filename[endpos + 1]) || filename[endpos + 1] == '_'))
&& (std::isalnum(filename[endpos + 1]) || filename[endpos + 1] == '_'))
|| ((brackets == CURLY) && (filename[endpos + 1] != '}'))
|| ((brackets == PAREN) && (filename[endpos + 1] != ')'))))
++endpos;

View File

@ -257,7 +257,7 @@ string V3ParseGrammar::deQuote(FileLine* fileline, string text) {
int octal_digits = 0;
for (string::const_iterator cp = text.begin(); cp != text.end(); ++cp) {
if (quoted) {
if (isdigit(*cp)) {
if (std::isdigit(*cp)) {
octal_val = octal_val * 8 + (*cp - '0');
if (++octal_digits == 3) {
octal_digits = 0;
@ -286,13 +286,13 @@ string V3ParseGrammar::deQuote(FileLine* fileline, string text) {
newtext += '\t';
} else if (*cp == 'v') {
newtext += '\v'; // SystemVerilog 3.1
} else if (*cp == 'x' && isxdigit(cp[1])
&& isxdigit(cp[2])) { // SystemVerilog 3.1
#define vl_decodexdigit(c) ((isdigit(c) ? ((c) - '0') : (tolower((c)) - 'a' + 10)))
} else if (*cp == 'x' && std::isxdigit(cp[1])
&& std::isxdigit(cp[2])) { // SystemVerilog 3.1
#define vl_decodexdigit(c) ((std::isdigit(c) ? ((c) - '0') : (std::tolower((c)) - 'a' + 10)))
newtext
+= static_cast<char>(16 * vl_decodexdigit(cp[1]) + vl_decodexdigit(cp[2]));
cp += 2;
} else if (isalnum(*cp)) {
} else if (std::isalnum(*cp)) {
fileline->v3error("Unknown escape sequence: \\" << *cp);
break;
} else {

View File

@ -134,10 +134,10 @@ void V3ParseImp::lexVerilatorCmtLintRestore(FileLine* fl) {
void V3ParseImp::lexVerilatorCmtLint(FileLine* fl, const char* textp, bool warnOff) {
const char* sp = textp;
while (*sp && !isspace(*sp)) ++sp;
while (*sp && isspace(*sp)) ++sp;
while (*sp && !isspace(*sp)) ++sp;
while (*sp && isspace(*sp)) ++sp;
while (*sp && !std::isspace(*sp)) ++sp;
while (*sp && std::isspace(*sp)) ++sp;
while (*sp && !std::isspace(*sp)) ++sp;
while (*sp && std::isspace(*sp)) ++sp;
string msg = sp;
string::size_type pos;
if ((pos = msg.find('*')) != string::npos) msg.erase(pos);
@ -155,9 +155,9 @@ void V3ParseImp::lexVerilatorCmtBad(FileLine* fl, const char* textp) {
if (cmtparse.substr(0, std::strlen("/*verilator")) == "/*verilator") {
cmtparse.replace(0, std::strlen("/*verilator"), "");
}
while (isspace(cmtparse[0])) cmtparse.replace(0, 1, "");
while (std::isspace(cmtparse[0])) cmtparse.replace(0, 1, "");
string cmtname;
for (int i = 0; isalnum(cmtparse[i]); i++) { cmtname += cmtparse[i]; }
for (int i = 0; std::isalnum(cmtparse[i]); i++) cmtname += cmtparse[i];
if (!v3Global.opt.isFuture(cmtname)) {
fl->v3error("Unknown verilator comment: '" << textp << "'");
}
@ -191,7 +191,7 @@ double V3ParseImp::lexParseTimenum(const char* textp) {
char* const strgp = new char[length + 1];
char* dp = strgp;
const char* sp = textp;
for (; isdigit(*sp) || *sp == '_' || *sp == '.'; ++sp) {
for (; std::isdigit(*sp) || *sp == '_' || *sp == '.'; ++sp) {
if (*sp != '_') *dp++ = *sp;
}
*dp++ = '\0';
@ -256,7 +256,7 @@ void V3ParseImp::preprocDumps(std::ostream& os) {
if (noblanks) {
bool blank = true;
for (string::iterator its = buf.begin(); its != buf.end(); ++its) {
if (!isspace(*its) && *its != '\n') {
if (!std::isspace(*its) && *its != '\n') {
blank = false;
break;
}

View File

@ -389,14 +389,14 @@ string V3PreProcImp::commentCleanup(const string& text) {
while ((pos = cmd.find('\"')) != string::npos) cmd.replace(pos, 1, " ");
while ((pos = cmd.find('\t')) != string::npos) cmd.replace(pos, 1, " ");
while ((pos = cmd.find(" ")) != string::npos) cmd.replace(pos, 2, " ");
while (!cmd.empty() && isspace(cmd[cmd.size() - 1])) cmd.erase(cmd.size() - 1);
while (!cmd.empty() && std::isspace(cmd[cmd.size() - 1])) cmd.erase(cmd.size() - 1);
return cmd;
}
bool V3PreProcImp::commentTokenMatch(string& cmdr, const char* strg) {
int len = std::strlen(strg);
if (VString::startsWith(cmdr, strg) && (cmdr[len] == '\0' || isspace(cmdr[len]))) {
if (isspace(cmdr[len])) len++;
if (VString::startsWith(cmdr, strg) && (cmdr[len] == '\0' || std::isspace(cmdr[len]))) {
if (std::isspace(cmdr[len])) len++;
cmdr = cmdr.substr(len);
return true;
} else {
@ -419,7 +419,7 @@ void V3PreProcImp::comment(const string& text) {
return;
}
while (isspace(*cp)) cp++;
while (std::isspace(*cp)) ++cp;
bool synth = false;
bool vlcomment = false;
@ -452,7 +452,7 @@ void V3PreProcImp::comment(const string& text) {
if (!vlcomment && !synth) return; // Short-circuit
while (isspace(*cp)) cp++;
while (std::isspace(*cp)) ++cp;
string cmd = commentCleanup(string(cp));
// cmd now is comment without extra spaces and "verilator" prefix
@ -480,7 +480,7 @@ void V3PreProcImp::comment(const string& text) {
while (VString::isWordChar(cmd[endOfCmd])) ++endOfCmd;
string baseCmd = cmd.substr(0, endOfCmd);
string arg = cmd.substr(endOfCmd);
while (isspace(arg[0])) arg = arg.substr(1);
while (std::isspace(arg[0])) arg = arg.substr(1);
if (arg.size() && baseCmd == "public_flat_rw_on")
baseCmd += "_sns"; // different cmd for applying sensitivity
if (!printed) insertUnreadback("/*verilator " + baseCmd + "*/ " + arg + " /**/");
@ -560,16 +560,16 @@ string V3PreProcImp::trimWhitespace(const string& strg, bool trailing) {
// Remove leading whitespace
string out = strg;
string::size_type leadspace = 0;
while (out.length() > leadspace && isspace(out[leadspace])) leadspace++;
while (out.length() > leadspace && std::isspace(out[leadspace])) ++leadspace;
if (leadspace) out.erase(0, leadspace);
// Remove trailing whitespace
if (trailing) {
string::size_type trailspace = 0;
while (out.length() > trailspace && isspace(out[out.length() - 1 - trailspace]))
trailspace++;
while (out.length() > trailspace && std::isspace(out[out.length() - 1 - trailspace]))
++trailspace;
// Don't remove \{space_or_newline}
if (trailspace && out.length() > trailspace && out[out.length() - 1 - trailspace] == '\\')
trailspace--;
--trailspace;
if (trailspace) out.erase(out.length() - trailspace, trailspace);
}
return out;
@ -681,13 +681,13 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
// UINFO(4, "CH "<<*cp<<" an "<<argName<<endl);
if (!quote && *cp == '\\') {
backslashesc = true;
} else if (isspace(*cp)) {
} else if (std::isspace(*cp)) {
backslashesc = false;
}
// We don't check for quotes; some simulators expand even inside quotes
if (isalpha(*cp) || *cp == '_'
if (std::isalpha(*cp) || *cp == '_'
|| *cp == '$' // Won't replace system functions, since no $ in argValueByName
|| (argName != "" && (isdigit(*cp) || *cp == '$'))) {
|| (argName != "" && (std::isdigit(*cp) || *cp == '$'))) {
argName += *cp;
continue;
}

View File

@ -1099,7 +1099,7 @@ private:
inPct = false;
if (V3Number::displayedFmtLegal(tolower(pos[0]), false)) {
if (V3Number::displayedFmtLegal(std::tolower(pos[0]), false)) {
AstNode* const argp = nextArgp;
nextArgp = nextArgp->nextp();
AstConst* const constp = fetchConstNull(argp);
@ -1111,7 +1111,7 @@ private:
const string pformat = std::string{"%"} + width + pos[0];
result += constp->num().displayed(nodep, pformat);
} else {
switch (tolower(pos[0])) {
switch (std::tolower(pos[0])) {
case '%': result += "%"; break;
case 'm':
// This happens prior to AstScope so we don't

View File

@ -80,13 +80,13 @@ string VString::dot(const string& a, const string& dot, const string& b) {
string VString::downcase(const string& str) {
string out = str;
for (auto& cr : out) cr = tolower(cr);
for (auto& cr : out) cr = std::tolower(cr);
return out;
}
string VString::upcase(const string& str) {
string out = str;
for (auto& cr : out) cr = toupper(cr);
for (auto& cr : out) cr = std::toupper(cr);
return out;
}
@ -133,7 +133,7 @@ string VString::escapeStringForPath(const string& str) {
string VString::spaceUnprintable(const string& str) {
string out;
for (const char c : str) {
if (isprint(c)) {
if (std::isprint(c)) {
out += c;
} else {
out += ' ';
@ -146,14 +146,14 @@ string VString::removeWhitespace(const string& str) {
string out;
out.reserve(str.size());
for (const char c : str) {
if (!isspace(c)) out += c;
if (!std::isspace(c)) out += c;
}
return out;
}
bool VString::isWhitespace(const string& str) {
for (const char c : str) {
if (!isspace(c)) return false;
if (!std::isspace(c)) return false;
}
return true;
}

View File

@ -70,7 +70,7 @@ inline uint32_t cvtToHash(const void* vp) {
inline string ucfirst(const string& text) {
string out = text;
out[0] = toupper(out[0]);
out[0] = std::toupper(out[0]);
return out;
}

View File

@ -4606,12 +4606,12 @@ private:
if (!inPct && ch == '%') {
inPct = true;
fmt = ch;
} else if (inPct && (isdigit(ch) || ch == '.' || ch == '-')) {
} else if (inPct && (std::isdigit(ch) || ch == '.' || ch == '-')) {
fmt += ch;
} else if (inPct) {
inPct = false;
bool added = false;
switch (tolower(ch)) {
switch (std::tolower(ch)) {
case '%': break; // %% - just output a %
case 'm': break; // %m - auto insert "name"
case 'l': break; // %m - auto insert "library"

View File

@ -910,7 +910,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
/* "# 1'b0" is a delay value so must lex as "#" "1" "'b0" */
if (PARSEP->lexPrevToken()=='#') {
int shortlen = 0;
while (isdigit(yytext[shortlen])) ++shortlen;
while (std::isdigit(yytext[shortlen])) ++shortlen;
if (shortlen) {
// Push rest past numbers for later parse
PARSEP->lexUnputString(yytext + shortlen, yyleng - shortlen);