aboutsummaryrefslogtreecommitdiff
path: root/ninja.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <ukai@google.com>2015-07-29 11:52:28 +0900
committerFumitoshi Ukai <ukai@google.com>2015-07-29 11:52:28 +0900
commit48ac8ae4ecb572659b2d47ef0ba78f6e728e4e2e (patch)
tree83d5d5c82a4867e5fb1b85b7729619b99a0a50a0 /ninja.go
parent03e9ea628b38d04f9bf188295b96d6611f0405dc (diff)
[go] fix ninja colon_ws_in_{file,target}.mk
Diffstat (limited to 'ninja.go')
-rw-r--r--ninja.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/ninja.go b/ninja.go
index 0f2a885..5aec5c2 100644
--- a/ninja.go
+++ b/ninja.go
@@ -377,18 +377,32 @@ func (n *NinjaGenerator) emitBuild(output, rule, inputs, orderOnlys string) {
}
func escapeBuildTarget(s string) string {
- i := strings.IndexAny(s, "$: ")
+ i := strings.IndexAny(s, "$: \\")
if i < 0 {
return s
}
+ // unescapeInput only "\ ", "\=" unescape as " ", "=".
+ // TODO(ukai): which char should unescape, which should not here?
+ var esc rune
var buf bytes.Buffer
for _, c := range s {
switch c {
+ case '\\':
+ esc = c
+ continue
case '$', ':', ' ':
+ esc = 0
buf.WriteByte('$')
}
+ if esc != 0 {
+ buf.WriteRune(esc)
+ esc = 0
+ }
buf.WriteRune(c)
}
+ if esc != 0 {
+ buf.WriteRune(esc)
+ }
return buf.String()
}