diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-04-12 03:56:00 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-04-12 03:56:00 +0900 |
commit | c4c98106620069867625123d0a4fd9fc4addfeb5 (patch) | |
tree | b0bd5bef157d8af7e2a401ec807a7c8d38fe7bbe | |
parent | 3796d1ec378cf63889007ab32ca33a92eed1d4ff (diff) | |
download | android_build_kati-c4c98106620069867625123d0a4fd9fc4addfeb5.tar.gz android_build_kati-c4c98106620069867625123d0a4fd9fc4addfeb5.tar.bz2 android_build_kati-c4c98106620069867625123d0a4fd9fc4addfeb5.zip |
Fix spaces between concatenated lines
-rw-r--r-- | parser.go | 4 | ||||
-rw-r--r-- | strutil.go | 9 | ||||
-rw-r--r-- | testcase/multiline_and_leading_space.mk | 12 |
3 files changed, 24 insertions, 1 deletions
@@ -111,9 +111,11 @@ func (p *parser) processDefineLine(line []byte) []byte { // TODO: Handle \\ at the end of the line? for len(line) > 0 && line[len(line)-1] == '\\' { line = line[:len(line)-1] + line = bytes.TrimRight(line, "\t ") lineno := p.lineno - nline := p.readLine() + nline := trimLeftSpaceBytes(p.readLine()) p.lineno = lineno + line = append(line, ' ') line = append(line, nline...) } return line @@ -153,3 +153,12 @@ func trimLeftSpace(s string) string { } return "" } + +func trimLeftSpaceBytes(s []byte) []byte { + for i, ch := range s { + if ch != ' ' && ch != '\t' { + return s[i:] + } + } + return nil +} diff --git a/testcase/multiline_and_leading_space.mk b/testcase/multiline_and_leading_space.mk new file mode 100644 index 0000000..71f0a5e --- /dev/null +++ b/testcase/multiline_and_leading_space.mk @@ -0,0 +1,12 @@ +X:=foo \ + bar + +Y:=foo \ + \ + bar + +$(info foo \ + bar) + +test: + echo PASS $(X) $(Y) |