aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/json-iterator/go/iter_skip_strict.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
committerLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
commit404aeae4545d2426c089a5f8d5e82dae56f5212b (patch)
tree2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/json-iterator/go/iter_skip_strict.go
parent209d8b0187ed025dec9ac149ebcced3462877bff (diff)
downloadgitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz
gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip
Make Nix builds work
Diffstat (limited to 'vendor/github.com/json-iterator/go/iter_skip_strict.go')
-rw-r--r--vendor/github.com/json-iterator/go/iter_skip_strict.go99
1 files changed, 99 insertions, 0 deletions
diff --git a/vendor/github.com/json-iterator/go/iter_skip_strict.go b/vendor/github.com/json-iterator/go/iter_skip_strict.go
new file mode 100644
index 0000000..6cf66d0
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_skip_strict.go
@@ -0,0 +1,99 @@
1//+build !jsoniter_sloppy
2
3package jsoniter
4
5import (
6 "fmt"
7 "io"
8)
9
10func (iter *Iterator) skipNumber() {
11 if !iter.trySkipNumber() {
12 iter.unreadByte()
13 if iter.Error != nil && iter.Error != io.EOF {
14 return
15 }
16 iter.ReadFloat64()
17 if iter.Error != nil && iter.Error != io.EOF {
18 iter.Error = nil
19 iter.ReadBigFloat()
20 }
21 }
22}
23
24func (iter *Iterator) trySkipNumber() bool {
25 dotFound := false
26 for i := iter.head; i < iter.tail; i++ {
27 c := iter.buf[i]
28 switch c {
29 case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
30 case '.':
31 if dotFound {
32 iter.ReportError("validateNumber", `more than one dot found in number`)
33 return true // already failed
34 }
35 if i+1 == iter.tail {
36 return false
37 }
38 c = iter.buf[i+1]
39 switch c {
40 case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
41 default:
42 iter.ReportError("validateNumber", `missing digit after dot`)
43 return true // already failed
44 }
45 dotFound = true
46 default:
47 switch c {
48 case ',', ']', '}', ' ', '\t', '\n', '\r':
49 if iter.head == i {
50 return false // if - without following digits
51 }
52 iter.head = i
53 return true // must be valid
54 }
55 return false // may be invalid
56 }
57 }
58 return false
59}
60
61func (iter *Iterator) skipString() {
62 if !iter.trySkipString() {
63 iter.unreadByte()
64 iter.ReadString()
65 }
66}
67
68func (iter *Iterator) trySkipString() bool {
69 for i := iter.head; i < iter.tail; i++ {
70 c := iter.buf[i]
71 if c == '"' {
72 iter.head = i + 1
73 return true // valid
74 } else if c == '\\' {
75 return false
76 } else if c < ' ' {
77 iter.ReportError("trySkipString",
78 fmt.Sprintf(`invalid control character found: %d`, c))
79 return true // already failed
80 }
81 }
82 return false
83}
84
85func (iter *Iterator) skipObject() {
86 iter.unreadByte()
87 iter.ReadObjectCB(func(iter *Iterator, field string) bool {
88 iter.Skip()
89 return true
90 })
91}
92
93func (iter *Iterator) skipArray() {
94 iter.unreadByte()
95 iter.ReadArrayCB(func(iter *Iterator) bool {
96 iter.Skip()
97 return true
98 })
99}