Emit: Fix indent tracking when // inside string literal (#2990)
// was so far unconditionally treated as comment.
c443e229ee introduced a string literal in
the output that contained a http:// url, which broke the indent
tracking. No functional change intended
This commit is contained in:
parent
ef9f477df2
commit
f4c1a7efeb
|
|
@ -715,9 +715,13 @@ void V3OutFormatter::puts(const char* strg) {
|
||||||
break;
|
break;
|
||||||
case ' ': wordstart = true; break;
|
case ' ': wordstart = true; break;
|
||||||
case '\t': wordstart = true; break;
|
case '\t': wordstart = true; break;
|
||||||
|
case '"':
|
||||||
|
wordstart = false;
|
||||||
|
m_inStringLiteral = !m_inStringLiteral;
|
||||||
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if (m_lang == LA_C || m_lang == LA_VERILOG) {
|
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
|
// Output ignoring contents to EOL
|
||||||
cp++;
|
cp++;
|
||||||
while (*cp && cp[1] && cp[1] != '\n') putcNoTracking(*cp++);
|
while (*cp && cp[1] && cp[1] != '\n') putcNoTracking(*cp++);
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ private:
|
||||||
int m_column = 0;
|
int m_column = 0;
|
||||||
int m_nobreak = false; // Basic operator or begin paren, don't break next
|
int m_nobreak = false; // Basic operator or begin paren, don't break next
|
||||||
bool m_prependIndent = true;
|
bool m_prependIndent = true;
|
||||||
|
bool m_inStringLiteral = false;
|
||||||
int m_indentLevel = 0; // Current {} indentation
|
int m_indentLevel = 0; // Current {} indentation
|
||||||
std::stack<int> m_parenVec; // Stack of columns where last ( was
|
std::stack<int> m_parenVec; // Stack of columns where last ( was
|
||||||
int m_bracketLevel = 0; // Intenting = { block, indicates number of {'s seen.
|
int m_bracketLevel = 0; // Intenting = { block, indicates number of {'s seen.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue