[chore]: Bump codeberg.org/gruf/go-kv from 1.6.3 to 1.6.4 (#2142)

This commit is contained in:
dependabot[bot]
2023-08-21 06:54:30 +00:00
committed by GitHub
parent 59b5ed6638
commit 70d87f0ff0
5 changed files with 11 additions and 36 deletions

View File

@@ -80,7 +80,7 @@ func Byte2Str(c byte) string {
return `\t`
case '\v':
return `\v`
case '\'':
case '\\':
return `\\`
default:
if c < ' ' {

View File

@@ -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] == '"') ||