diff options
| author | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-07-15 10:41:47 +0900 |
|---|---|---|
| committer | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-07-15 10:41:47 +0900 |
| commit | 43b56663e2b3c9e86d274e1da5f281fab4aff672 (patch) | |
| tree | feed0786802a5380fe61509d23e38bdd6d952c71 /ninja.go | |
| parent | 53eaaf88148c956dd2aab9b95d21e370eaf872f9 (diff) | |
[go] backport [C++] Do not strip words which do not start with '#'
commit e7f2d9d24c9cff8f9f19b9d0b37c61e1c2da4d42
Diffstat (limited to 'ninja.go')
| -rw-r--r-- | ninja.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -137,6 +137,9 @@ func stripShellComment(s string) string { // Fast path. return s } + // set space as an initial value so the leading comment will be + // stripped out. + lastch := rune(' ') var escape bool var quote rune for i, c := range s { @@ -145,7 +148,7 @@ func stripShellComment(s string) string { quote = 0 } } else if !escape { - if c == '#' { + if c == '#' && isWhitespace(lastch) { return s[:i] } else if c == '\'' || c == '"' || c == '`' { quote = c @@ -158,6 +161,7 @@ func stripShellComment(s string) string { } else { escape = false } + lastch = c } return s } |
