diff --git a/src/V3File.cpp b/src/V3File.cpp index 63920e061..2372de6a9 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -715,9 +715,13 @@ void V3OutFormatter::puts(const char* strg) { break; case ' ': wordstart = true; break; case '\t': wordstart = true; break; + case '"': + wordstart = false; + m_inStringLiteral = !m_inStringLiteral; + break; case '/': if (m_lang == LA_C || m_lang == LA_VERILOG) { - if (cp > strg && cp[-1] == '/') { + if (cp > strg && cp[-1] == '/' && !m_inStringLiteral) { // Output ignoring contents to EOL cp++; while (*cp && cp[1] && cp[1] != '\n') putcNoTracking(*cp++); diff --git a/src/V3File.h b/src/V3File.h index b198a10b4..9d22a77b0 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -121,6 +121,7 @@ private: int m_column = 0; int m_nobreak = false; // Basic operator or begin paren, don't break next bool m_prependIndent = true; + bool m_inStringLiteral = false; int m_indentLevel = 0; // Current {} indentation std::stack m_parenVec; // Stack of columns where last ( was int m_bracketLevel = 0; // Intenting = { block, indicates number of {'s seen.