bump(github.com/docker/libcompose) v0.3.0

This commit is contained in:
Tomas Kral
2016-08-22 10:51:22 +02:00
parent 223b4f37fa
commit e341adce0e
57 changed files with 944 additions and 12907 deletions
+14 -9
View File
@@ -14,6 +14,7 @@
package expfmt
import (
"bytes"
"fmt"
"io"
"math"
@@ -284,17 +285,21 @@ func labelPairsToText(
return written, nil
}
var (
escape = strings.NewReplacer("\\", `\\`, "\n", `\n`)
escapeWithDoubleQuote = strings.NewReplacer("\\", `\\`, "\n", `\n`, "\"", `\"`)
)
// escapeString replaces '\' by '\\', new line character by '\n', and - if
// includeDoubleQuote is true - '"' by '\"'.
func escapeString(v string, includeDoubleQuote bool) string {
if includeDoubleQuote {
return escapeWithDoubleQuote.Replace(v)
result := bytes.NewBuffer(make([]byte, 0, len(v)))
for _, c := range v {
switch {
case c == '\\':
result.WriteString(`\\`)
case includeDoubleQuote && c == '"':
result.WriteString(`\"`)
case c == '\n':
result.WriteString(`\n`)
default:
result.WriteRune(c)
}
}
return escape.Replace(v)
return result.String()
}