diff options
Diffstat (limited to 'vendor/codeberg.org')
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/format/util.go | 2 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-kv/util.go | 37 |
2 files changed, 7 insertions, 32 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/format/util.go b/vendor/codeberg.org/gruf/go-kv/format/util.go index f36727679..79cb30981 100644 --- a/vendor/codeberg.org/gruf/go-kv/format/util.go +++ b/vendor/codeberg.org/gruf/go-kv/format/util.go @@ -80,7 +80,7 @@ func Byte2Str(c byte) string { return `\t` case '\v': return `\v` - case '\'': + case '\\': return `\\` default: if c < ' ' { diff --git a/vendor/codeberg.org/gruf/go-kv/util.go b/vendor/codeberg.org/gruf/go-kv/util.go index ebcd3e304..c0c8ccdab 100644 --- a/vendor/codeberg.org/gruf/go-kv/util.go +++ b/vendor/codeberg.org/gruf/go-kv/util.go @@ -18,7 +18,9 @@ func AppendQuoteString(buf *byteutil.Buffer, str string) { case len(str) == 1: // Append quote single byte. - appendQuoteByte(buf, str[0]) + buf.B = append(buf.B, '\'') + buf.B = append(buf.B, format.Byte2Str(str[0])...) + buf.B = append(buf.B, '\'') return case len(str) > format.SingleTermLine || !format.IsSafeASCII(str): @@ -63,7 +65,9 @@ func AppendQuoteValue(buf *byteutil.Buffer, str string) { case len(str) == 1: // Append quote single byte. - appendQuoteByte(buf, str[0]) + buf.B = append(buf.B, '\'') + buf.B = append(buf.B, format.Byte2Str(str[0])...) + buf.B = append(buf.B, '\'') return case len(str) > format.SingleTermLine || !format.IsSafeASCII(str): @@ -115,35 +119,6 @@ func AppendQuoteValue(buf *byteutil.Buffer, str string) { return } -// appendEscapeByte will append byte to buffer, quoting and escaping where necessary. -func appendQuoteByte(buf *byteutil.Buffer, c byte) { - switch c { - // Double quote space. - case ' ': - buf.B = append(buf.B, '"', c, '"') - - // Escape + double quote. - case '\a': - buf.B = append(buf.B, '"', '\\', 'a', '"') - case '\b': - buf.B = append(buf.B, '"', '\\', 'b', '"') - case '\f': - buf.B = append(buf.B, '"', '\\', 'f', '"') - case '\n': - buf.B = append(buf.B, '"', '\\', 'n', '"') - case '\r': - buf.B = append(buf.B, '"', '\\', 'r', '"') - case '\t': - buf.B = append(buf.B, '"', '\\', 't', '"') - case '\v': - buf.B = append(buf.B, '"', '\\', 'v', '"') - - // Append as-is. - default: - buf.B = append(buf.B, c) - } -} - // isQuoted checks if string is single or double quoted. func isQuoted(str string) bool { return (str[0] == '"' && str[len(str)-1] == '"') || |