Fix the issue of snbt being unable to handle nested Tag*Arrays in TagCompound

This commit is contained in:
Tnze
2023-04-23 23:00:24 +08:00
parent d4d9653038
commit a511ad3d2a
2 changed files with 3 additions and 2 deletions

View File

@ -234,7 +234,7 @@ func stateArrayT(s *scanner, c byte) int {
return scanSkipSpace return scanSkipSpace
} }
if c == ']' { // empty array if c == ']' { // empty array
return scanEndValue return stateEndValue(s, c)
} }
return stateBeginValue(s, c) return stateBeginValue(s, c)
} }

View File

@ -9,7 +9,7 @@ func TestSNBT_checkScanCode(t *testing.T) {
// t.SkipNow() // t.SkipNow()
var s scanner var s scanner
s.reset() s.reset()
for _, c := range []byte(`{b:[vanilla],c:0D}`) { for _, c := range []byte(`{a:[B;]}`) {
t.Logf("[%c] - %d", c, s.step(&s, c)) t.Logf("[%c] - %d", c, s.step(&s, c))
} }
t.Logf("[%c] - %d", ' ', s.eof()) t.Logf("[%c] - %d", ' ', s.eof())
@ -74,6 +74,7 @@ func TestSNBT_list(t *testing.T) {
`[B,C,D]`, `[L, "abc"]`, // List of string (like array) `[B,C,D]`, `[L, "abc"]`, // List of string (like array)
`[B; 01B, 02B, 3B, 10B, 127B]`, // Array `[B; 01B, 02B, 3B, 10B, 127B]`, // Array
`[I;]`, `[B; ]`, // Empty array `[I;]`, `[B; ]`, // Empty array
`{a:[],b:[B;]}`, // List or Array in TagCompound
} }
var s scanner var s scanner
scan := func(str string) bool { scan := func(str string) bool {