aboutsummaryrefslogtreecommitdiffstats
path: root/androidmk
diff options
context:
space:
mode:
authorSasha Smundak <asmundak@google.com>2019-03-05 17:34:32 -0800
committerSasha Smundak <asmundak@google.com>2019-03-06 16:46:23 -0800
commite10952b4424418d26b732f5c96e5ed676fd7de2a (patch)
treeb8ec70ef7aff5311849c3d7decefaf4966a56fdf /androidmk
parent7aa5a56bbc66180d15fdd68245b591229344d835 (diff)
downloadbuild_soong-e10952b4424418d26b732f5c96e5ed676fd7de2a.tar.gz
build_soong-e10952b4424418d26b732f5c96e5ed676fd7de2a.tar.bz2
build_soong-e10952b4424418d26b732f5c96e5ed676fd7de2a.zip
Do not "escape" newline if comment ends with ESC character.
Fixes: 127521510 Test: manual Change-Id: I88a8eb2ca94b8aa06e2682d2c14f9e74f5ada286
Diffstat (limited to 'androidmk')
-rw-r--r--androidmk/cmd/androidmk/androidmk_test.go11
-rw-r--r--androidmk/parser/parser.go8
2 files changed, 16 insertions, 3 deletions
diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go
index 2cbfd012..98d4506a 100644
--- a/androidmk/cmd/androidmk/androidmk_test.go
+++ b/androidmk/cmd/androidmk/androidmk_test.go
@@ -1064,6 +1064,17 @@ vts_config {
}
`,
},
+ {
+ desc: "comment with ESC",
+ in: `
+# Comment line 1 \
+# Comment line 2
+`,
+ expected: `
+// Comment line 1 \
+// Comment line 2
+`,
+ },
}
func TestEndToEnd(t *testing.T) {
diff --git a/androidmk/parser/parser.go b/androidmk/parser/parser.go
index 89c1af90..86dabf97 100644
--- a/androidmk/parser/parser.go
+++ b/androidmk/parser/parser.go
@@ -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')