From b6ff55662e0281c0d6e111f9307625ef695df2fa Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 22 May 2025 16:27:55 +0200 Subject: [chore] update dependencies (#4188) Update dependencies: - github.com/gin-gonic/gin v1.10.0 -> v1.10.1 - github.com/gin-contrib/sessions v1.10.3 -> v1.10.4 - github.com/jackc/pgx/v5 v5.7.4 -> v5.7.5 - github.com/minio/minio-go/v7 v7.0.91 -> v7.0.92 - github.com/pquerna/otp v1.4.0 -> v1.5.0 - github.com/tdewolff/minify/v2 v2.23.5 -> v2.23.8 - github.com/yuin/goldmark v1.7.11 -> v1.7.12 - go.opentelemetry.io/otel{,/*} v1.35.0 -> v1.36.0 - modernc.org/sqlite v1.37.0 -> v1.37.1 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4188 Reviewed-by: Daenney Co-authored-by: kim Co-committed-by: kim --- vendor/github.com/tdewolff/parse/v2/common.go | 24 +++++++ .../tdewolff/parse/v2/strconv/decimal.go | 78 ++++++++++++++++++++++ .../github.com/tdewolff/parse/v2/strconv/float.go | 2 +- vendor/github.com/tdewolff/parse/v2/strconv/int.go | 40 ++++++++++- .../github.com/tdewolff/parse/v2/strconv/number.go | 3 + 5 files changed, 144 insertions(+), 3 deletions(-) (limited to 'vendor/github.com/tdewolff/parse') diff --git a/vendor/github.com/tdewolff/parse/v2/common.go b/vendor/github.com/tdewolff/parse/v2/common.go index 05f881739..68863a5ca 100644 --- a/vendor/github.com/tdewolff/parse/v2/common.go +++ b/vendor/github.com/tdewolff/parse/v2/common.go @@ -544,3 +544,27 @@ func DecodeURL(b []byte) []byte { } return b } + +func AppendEscape(b, str, chars []byte, escape byte) []byte { + i := 0 + for j := 0; j < len(str); j++ { + has := false + for _, c := range chars { + if c == str[j] { + has = true + break + } + } + if has || str[j] == escape { + if i < j { + b = append(b, str[i:j]...) + } + b = append(b, escape) + i = j + } + } + if i < len(str) { + b = append(b, str[i:]...) + } + return b +} diff --git a/vendor/github.com/tdewolff/parse/v2/strconv/decimal.go b/vendor/github.com/tdewolff/parse/v2/strconv/decimal.go index 788bb9622..137c87936 100644 --- a/vendor/github.com/tdewolff/parse/v2/strconv/decimal.go +++ b/vendor/github.com/tdewolff/parse/v2/strconv/decimal.go @@ -69,3 +69,81 @@ func ParseDecimal(b []byte) (float64, int) { } return f * math.Pow10(exp), i } + +// AppendDecimal appends a float to `b` with `dec` the maximum number of decimals. +func AppendDecimal(b []byte, f float64, dec int) []byte { + if math.IsNaN(float64(f)) || math.IsInf(float64(f), 0) { + return b + } + + if dec < 0 || 17 < dec { + dec = 17 + } + f *= math.Pow10(dec) + + // correct rounding + if 0.0 <= f { + f += 0.5 + } else { + f -= 0.5 + } + + // calculate mantissa and exponent + num := int64(f) + if num == 0 { + return append(b, '0') + } + for 0 < dec && num%10 == 0 { + num /= 10 + dec-- // remove trailing zeros + } + + i, n := len(b), LenInt(num) + if 0 < dec { + if n < dec { + n = dec // number has zero after dot + } + n++ // dot + if lim := int64pow10[dec]; 0 < num && num < lim || num < 0 && -lim < num { + n++ // zero at beginning + } + } + if cap(b) < i+n { + b = append(b, make([]byte, n)...) + } else { + b = b[:i+n] + } + + // print sign + if num < 0 { + num = -num + b[i] = '-' + } + i += n - 1 + + // print number + if 0 < dec { + b[i] = byte(num%10) + '0' + num /= 10 + dec-- + i-- + for 0 < dec { + b[i] = byte(num%10) + '0' + num /= 10 + dec-- + i-- + } + b[i] = '.' + i-- + } + if num == 0 { + b[i] = '0' + } else { + for num != 0 { + b[i] = byte(num%10) + '0' + num /= 10 + i-- + } + } + return b +} diff --git a/vendor/github.com/tdewolff/parse/v2/strconv/float.go b/vendor/github.com/tdewolff/parse/v2/strconv/float.go index 35558fc98..103db72e0 100644 --- a/vendor/github.com/tdewolff/parse/v2/strconv/float.go +++ b/vendor/github.com/tdewolff/parse/v2/strconv/float.go @@ -145,7 +145,7 @@ func AppendFloat(b []byte, f float64, prec int) ([]byte, bool) { expLen = 1 + LenInt(int64(exp)) // e + digits } else if mantExp < -3 { exp = mantExp - expLen = 2 + LenInt(int64(exp)) // e + minus + digits + expLen = 1 + LenInt(int64(exp)) // e + minus + digits } else if mantExp < -1 { mantLen += -mantExp - 1 // extra zero between dot and first digit } diff --git a/vendor/github.com/tdewolff/parse/v2/strconv/int.go b/vendor/github.com/tdewolff/parse/v2/strconv/int.go index 2f45d1e21..1e9578eb5 100644 --- a/vendor/github.com/tdewolff/parse/v2/strconv/int.go +++ b/vendor/github.com/tdewolff/parse/v2/strconv/int.go @@ -60,13 +60,45 @@ func ParseUint(b []byte) (uint64, int) { return n, i } +// AppendInt will append an int64. +func AppendInt(b []byte, num int64) []byte { + if num == 0 { + return append(b, '0') + } else if num == -9223372036854775808 { + return append(b, "-9223372036854775808"...) + } + + // resize byte slice + i, n := len(b), LenInt(num) + if cap(b) < i+n { + b = append(b, make([]byte, n)...) + } else { + b = b[:i+n] + } + + // print sign + if num < 0 { + num = -num + b[i] = '-' + } + i += n - 1 + + // print number + for num != 0 { + b[i] = byte(num%10) + '0' + num /= 10 + i-- + } + return b +} + // LenInt returns the written length of an integer. func LenInt(i int64) int { if i < 0 { if i == -9223372036854775808 { - return 19 + return 20 } - i = -i + return 1 + LenUint(uint64(-i)) } return LenUint(uint64(i)) } @@ -114,3 +146,7 @@ func LenUint(i uint64) int { } return 20 } + +var int64pow10 = []int64{ + 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000, 100000000000000000, 1000000000000000000, +} diff --git a/vendor/github.com/tdewolff/parse/v2/strconv/number.go b/vendor/github.com/tdewolff/parse/v2/strconv/number.go index eb2a909b2..cc3014cdf 100644 --- a/vendor/github.com/tdewolff/parse/v2/strconv/number.go +++ b/vendor/github.com/tdewolff/parse/v2/strconv/number.go @@ -61,6 +61,9 @@ func AppendNumber(b []byte, num int64, dec int, groupSize int, groupSym rune, de // calculate size n := LenInt(num) + if sign == -1 { + n-- // ignore minux sign, add later + } if dec < n && 0 < groupSize && groupSym != 0 { n += utf8.RuneLen(groupSym) * (n - dec - 1) / groupSize } -- cgit v1.3