Fix parsing integer 0

This commit is contained in:
Thomas Pelletier
2021-03-23 09:02:48 -04:00
parent b8da9d1854
commit e78ccff9a4
3 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ Development branch. Probably does not work.
- [x] Unmarshal into maps.
- [x] Support Array Tables.
- [x] Unmarshal into pointers.
- [x] Unmarshal into pointers.
- [x] Support Date / times.
- [ ] Support Unmarshaler interface.
- [x] Support struct tags annotations.
@@ -439,7 +439,7 @@ func TestEmptytomlUnmarshal(t *testing.T) {
String: "",
StringList: []string{},
Ptr: nil,
Map: map[string]string{},
Map: nil,
}
result := emptyMarshalTestStruct{}
+11 -7
View File
@@ -977,17 +977,21 @@ func (p *parser) scanIntOrFloat(node *ast.Node, b []byte) ([]byte, error) {
case 'b':
isValidRune = isValidBinaryRune
default:
return b, fmt.Errorf("unknown number base: %c. possible options are x (hex) o (octal) b (binary)", b[1])
i++
}
i += 2
for ; i < len(b); i++ {
if !isValidRune(b[i]) {
node.Kind = ast.Integer
node.Data = b[:i]
return b[i:], nil
if isValidRune != nil {
i += 2
for ; i < len(b); i++ {
if !isValidRune(b[i]) {
break
}
}
}
node.Kind = ast.Integer
node.Data = b[:i]
return b[i:], nil
}
isFloat := false