Fix comments with continuation am: 7890211d58
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1505513 Change-Id: Ic8af398cdfe92ea78471f59ca79b400dfc389f98
This commit is contained in:
@@ -137,7 +137,14 @@ func ConvertFile(filename string, buffer *bytes.Buffer) (string, []error) {
|
||||
|
||||
switch x := node.(type) {
|
||||
case *mkparser.Comment:
|
||||
file.insertComment("//" + x.Comment)
|
||||
// Split the comment on escaped newlines and then
|
||||
// add each chunk separately.
|
||||
chunks := strings.Split(x.Comment, "\\\n")
|
||||
file.insertComment("//" + chunks[0])
|
||||
for i := 1; i < len(chunks); i++ {
|
||||
file.bpPos.Line++
|
||||
file.insertComment("//" + chunks[i])
|
||||
}
|
||||
case *mkparser.Assignment:
|
||||
handleAssignment(file, x, assignmentCond)
|
||||
case *mkparser.Directive:
|
||||
|
@@ -1260,10 +1260,10 @@ prebuilt_firmware {
|
||||
desc: "comment with ESC",
|
||||
in: `
|
||||
# Comment line 1 \
|
||||
# Comment line 2
|
||||
Comment line 2
|
||||
`,
|
||||
expected: `
|
||||
// Comment line 1 \
|
||||
// Comment line 1
|
||||
// Comment line 2
|
||||
`,
|
||||
},
|
||||
|
@@ -497,12 +497,6 @@ loop:
|
||||
switch p.tok {
|
||||
case '\\':
|
||||
p.parseEscape()
|
||||
if p.tok == '\n' {
|
||||
// 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':
|
||||
|
Reference in New Issue
Block a user