summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-split/join_util.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2025-03-09 17:47:56 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2025-12-01 22:08:04 +0100
commitb1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch)
tree9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/codeberg.org/gruf/go-split/join_util.go
parent[chore] update URLs to forked source (diff)
downloadgotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-split/join_util.go')
-rw-r--r--vendor/codeberg.org/gruf/go-split/join_util.go71
1 files changed, 0 insertions, 71 deletions
diff --git a/vendor/codeberg.org/gruf/go-split/join_util.go b/vendor/codeberg.org/gruf/go-split/join_util.go
deleted file mode 100644
index e517fe908..000000000
--- a/vendor/codeberg.org/gruf/go-split/join_util.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package split
-
-import (
- "strconv"
- "strings"
-)
-
-// singleTermLine: beyond a certain length of string, all of the
-// extra checks to handle quoting/not-quoting add a significant
-// amount of extra processing time. Quoting in this manner only really
-// effects readability on a single line, so a max string length that
-// encompasses the maximum number of columns on *most* terminals was
-// selected. This was chosen using the metric that 1080p is one of the
-// most common display resolutions, and that a relatively small font size
-// of 7 requires ~ 223 columns. So 256 should be >= $COLUMNS (fullscreen)
-// in 99% of usecases (these figures all pulled out of my ass).
-const singleTermLine = 256
-
-// appendQuote will append 'str' to 'buf', double quoting and escaping if needed.
-func appendQuote(buf []byte, str string) []byte {
- switch {
- case len(str) > singleTermLine || !strconv.CanBackquote(str):
- // Append quoted and escaped string
- return strconv.AppendQuote(buf, str)
-
- case (strings.IndexByte(str, '"') != -1):
- // Double quote and escape string
- buf = append(buf, '"')
- buf = appendEscape(buf, str)
- buf = append(buf, '"')
- return buf
-
- case (strings.IndexByte(str, ',') != -1):
- // Double quote this string as-is
- buf = append(buf, '"')
- buf = append(buf, str...)
- buf = append(buf, '"')
- return buf
-
- default:
- // Append string as-is
- return append(buf, str...)
- }
-}
-
-// appendEscape will append 'str' to 'buf' and escape any double quotes.
-func appendEscape(buf []byte, str string) []byte {
- var delim bool
- for i := range str {
- switch {
- case str[i] == '\\' && !delim:
- // Set delim flag
- delim = true
-
- case str[i] == '"' && !delim:
- // Append escaped double quote
- buf = append(buf, `\"`...)
-
- case delim:
- // Append skipped slash
- buf = append(buf, `\`...)
- delim = false
- fallthrough
-
- default:
- // Append char as-is
- buf = append(buf, str[i])
- }
- }
- return buf
-}