vendor: update github.com/valyala/fastjson/fastfloat from v1.6.3 to v1.6.4

This should properly parse floating-point numbers with missing integer or fractional parts.
For example, 123. or .123

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3544
This commit is contained in:
Aliaksandr Valialkin 2022-12-29 10:33:17 -08:00
parent 0a9e1d64fe
commit c90752a8be
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
5 changed files with 25 additions and 8 deletions

View file

@ -21,6 +21,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
* FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): allow configuring the default number of stored rule's update states in memory via global `-rule.updateEntriesLimit` command-line flag or per-rule via rule's `update_entries_limit` configuration param.
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): properly update the `step` value in url after the `step` input field has been manually changed. This allows preserving the proper `step` when copy-n-pasting the url to another instance of web browser. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3513).
* BUGFIX: properly parse floating-point numbers without integer or fractional parts such as `.123` and `20.` during [data import](https://docs.victoriametrics.com/#how-to-import-time-series-data). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3544).
## [v1.85.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.3)

2
go.mod
View file

@ -26,7 +26,7 @@ require (
github.com/klauspost/compress v1.15.13
github.com/prometheus/prometheus v0.41.0
github.com/urfave/cli/v2 v2.23.7
github.com/valyala/fastjson v1.6.3
github.com/valyala/fastjson v1.6.4
github.com/valyala/fastrand v1.1.0
github.com/valyala/fasttemplate v1.2.2
github.com/valyala/gozstd v1.17.0

4
go.sum
View file

@ -425,8 +425,8 @@ github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6f
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=

View file

@ -213,6 +213,12 @@ func ParseBestEffort(s string) float64 {
}
}
// the integer part might be elided to remain compliant
// with https://go.dev/ref/spec#Floating-point_literals
if s[i] == '.' && (i+1 >= uint(len(s)) || s[i+1] < '0' || s[i+1] > '9') {
return 0
}
d := uint64(0)
j := i
for i < uint(len(s)) {
@ -232,7 +238,7 @@ func ParseBestEffort(s string) float64 {
}
break
}
if i <= j {
if i <= j && s[i] != '.' {
s = s[i:]
if strings.HasPrefix(s, "+") {
s = s[1:]
@ -263,7 +269,9 @@ func ParseBestEffort(s string) float64 {
// Parse fractional part.
i++
if i >= uint(len(s)) {
return 0
// the fractional part may be elided to remain compliant
// with https://go.dev/ref/spec#Floating-point_literals
return f
}
k := i
for i < uint(len(s)) {
@ -363,6 +371,12 @@ func Parse(s string) (float64, error) {
}
}
// the integer part might be elided to remain compliant
// with https://go.dev/ref/spec#Floating-point_literals
if s[i] == '.' && (i+1 >= uint(len(s)) || s[i+1] < '0' || s[i+1] > '9') {
return 0, fmt.Errorf("missing integer and fractional part in %q", s)
}
d := uint64(0)
j := i
for i < uint(len(s)) {
@ -382,7 +396,7 @@ func Parse(s string) (float64, error) {
}
break
}
if i <= j {
if i <= j && s[i] != '.' {
ss := s[i:]
if strings.HasPrefix(ss, "+") {
ss = ss[1:]
@ -413,7 +427,9 @@ func Parse(s string) (float64, error) {
// Parse fractional part.
i++
if i >= uint(len(s)) {
return 0, fmt.Errorf("cannot parse fractional part in %q", s)
// the fractional part might be elided to remain compliant
// with https://go.dev/ref/spec#Floating-point_literals
return f, nil
}
k := i
for i < uint(len(s)) {

2
vendor/modules.txt vendored
View file

@ -447,7 +447,7 @@ github.com/urfave/cli/v2
# github.com/valyala/bytebufferpool v1.0.0
## explicit
github.com/valyala/bytebufferpool
# github.com/valyala/fastjson v1.6.3
# github.com/valyala/fastjson v1.6.4
## explicit; go 1.12
github.com/valyala/fastjson
github.com/valyala/fastjson/fastfloat