Fix parsing integer 0
This commit is contained in:
@@ -8,7 +8,7 @@ Development branch. Probably does not work.
|
|||||||
|
|
||||||
- [x] Unmarshal into maps.
|
- [x] Unmarshal into maps.
|
||||||
- [x] Support Array Tables.
|
- [x] Support Array Tables.
|
||||||
- [x] Unmarshal into pointers.
|
- [x] Unmarshal into pointers.
|
||||||
- [x] Support Date / times.
|
- [x] Support Date / times.
|
||||||
- [ ] Support Unmarshaler interface.
|
- [ ] Support Unmarshaler interface.
|
||||||
- [x] Support struct tags annotations.
|
- [x] Support struct tags annotations.
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ func TestEmptytomlUnmarshal(t *testing.T) {
|
|||||||
String: "",
|
String: "",
|
||||||
StringList: []string{},
|
StringList: []string{},
|
||||||
Ptr: nil,
|
Ptr: nil,
|
||||||
Map: map[string]string{},
|
Map: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
result := emptyMarshalTestStruct{}
|
result := emptyMarshalTestStruct{}
|
||||||
|
|||||||
@@ -977,17 +977,21 @@ func (p *parser) scanIntOrFloat(node *ast.Node, b []byte) ([]byte, error) {
|
|||||||
case 'b':
|
case 'b':
|
||||||
isValidRune = isValidBinaryRune
|
isValidRune = isValidBinaryRune
|
||||||
default:
|
default:
|
||||||
return b, fmt.Errorf("unknown number base: %c. possible options are x (hex) o (octal) b (binary)", b[1])
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 2
|
if isValidRune != nil {
|
||||||
for ; i < len(b); i++ {
|
i += 2
|
||||||
if !isValidRune(b[i]) {
|
for ; i < len(b); i++ {
|
||||||
node.Kind = ast.Integer
|
if !isValidRune(b[i]) {
|
||||||
node.Data = b[:i]
|
break
|
||||||
return b[i:], nil
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.Kind = ast.Integer
|
||||||
|
node.Data = b[:i]
|
||||||
|
return b[i:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
isFloat := false
|
isFloat := false
|
||||||
|
|||||||
Reference in New Issue
Block a user