Merge "Do not "escape" newline if comment ends with ESC character."

This commit is contained in:
Treehugger Robot
2019-03-07 04:29:45 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 3 deletions

View File

@@ -1062,6 +1062,17 @@ include test/vts/tools/build/Android.host_config.mk
vts_config {
name: "vtsconf",
}
`,
},
{
desc: "comment with ESC",
in: `
# Comment line 1 \
# Comment line 2
`,
expected: `
// Comment line 1 \
// Comment line 2
`,
},
}

View File

@@ -485,10 +485,12 @@ loop:
case '\\':
p.parseEscape()
if p.tok == '\n' {
comment += "\n"
} else {
comment += "\\" + p.scanner.TokenText()
// Special case: '\' does not "escape" newline in comment (b/127521510)
comment += "\\"
p.accept(p.tok)
break loop
}
comment += "\\" + p.scanner.TokenText()
p.accept(p.tok)
case '\n':
p.accept('\n')