diff options
| author | 2023-11-27 13:15:03 +0000 | |
|---|---|---|
| committer | 2023-11-27 13:15:03 +0000 | |
| commit | 66b77acb1c8b86f0be3836ccaf31683c0bfa317a (patch) | |
| tree | 9a255a8ea8ef97229b6d75d17de45bdac1755be9 /vendor/github.com/bytedance/sonic/ast/decode.go | |
| parent | [bugfix] Add Actor to outgoing poll vote Create; other fixes (#2384) (diff) | |
| download | gotosocial-66b77acb1c8b86f0be3836ccaf31683c0bfa317a.tar.xz | |
[chore]: Bump github.com/gin-contrib/cors from 1.4.0 to 1.5.0 (#2388)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/decode.go')
| -rw-r--r-- | vendor/github.com/bytedance/sonic/ast/decode.go | 36 | 
1 files changed, 23 insertions, 13 deletions
| diff --git a/vendor/github.com/bytedance/sonic/ast/decode.go b/vendor/github.com/bytedance/sonic/ast/decode.go index 6a5f6fea3..3e08bfcb2 100644 --- a/vendor/github.com/bytedance/sonic/ast/decode.go +++ b/vendor/github.com/bytedance/sonic/ast/decode.go @@ -220,7 +220,7 @@ func decodeFloat64(src string, pos int) (ret int, v float64, err error) {      return ret, v, nil  } -func decodeValue(src string, pos int) (ret int, v types.JsonState) { +func decodeValue(src string, pos int, skipnum bool) (ret int, v types.JsonState) {      pos = skipBlank(src, pos)      if pos < 0 {          return pos, types.JsonState{Vt: types.ValueType(pos)} @@ -256,20 +256,30 @@ func decodeValue(src string, pos int) (ret int, v types.JsonState) {          }          return ret, types.JsonState{Vt: types.V_FALSE}      case '-', '+', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': -        var iv int64 -        ret, iv, _ = decodeInt64(src, pos) -        if ret >= 0 { -            return ret, types.JsonState{Vt: types.V_INTEGER, Iv: iv, Ep: pos} -        } else if ret != -int(types.ERR_INVALID_NUMBER_FMT) { -            return ret, types.JsonState{Vt: types.ValueType(ret)} -        } -        var fv float64 -        ret, fv, _ = decodeFloat64(src, pos) -        if ret >= 0 { -            return ret, types.JsonState{Vt: types.V_DOUBLE, Dv: fv, Ep: pos} +        if skipnum { +            ret = skipNumber(src, pos) +            if ret >= 0 { +                return ret, types.JsonState{Vt: types.V_DOUBLE, Iv: 0, Ep: pos} +            } else { +                return ret, types.JsonState{Vt: types.ValueType(ret)} +            }          } else { -            return ret, types.JsonState{Vt: types.ValueType(ret)} +            var iv int64 +            ret, iv, _ = decodeInt64(src, pos) +            if ret >= 0 { +                return ret, types.JsonState{Vt: types.V_INTEGER, Iv: iv, Ep: pos} +            } else if ret != -int(types.ERR_INVALID_NUMBER_FMT) { +                return ret, types.JsonState{Vt: types.ValueType(ret)} +            } +            var fv float64 +            ret, fv, _ = decodeFloat64(src, pos) +            if ret >= 0 { +                return ret, types.JsonState{Vt: types.V_DOUBLE, Dv: fv, Ep: pos} +            } else { +                return ret, types.JsonState{Vt: types.ValueType(ret)} +            }          } +              default:          return -int(types.ERR_INVALID_CHAR), types.JsonState{Vt:-types.ValueType(types.ERR_INVALID_CHAR)}      } | 
