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

am: e3ca7fd565

Change-Id: I2d206fb24ec74e8e051f83a503fb0cac381796e0
This commit is contained in:
Sasha Smundak
2019-03-06 20:38:24 -08:00
committed by android-build-merger
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 { vts_config {
name: "vtsconf", 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 '\\': case '\\':
p.parseEscape() p.parseEscape()
if p.tok == '\n' { if p.tok == '\n' {
comment += "\n" // Special case: '\' does not "escape" newline in comment (b/127521510)
} else { comment += "\\"
comment += "\\" + p.scanner.TokenText() p.accept(p.tok)
break loop
} }
comment += "\\" + p.scanner.TokenText()
p.accept(p.tok) p.accept(p.tok)
case '\n': case '\n':
p.accept('\n') p.accept('\n')