51 lines
1.7 KiB
Diff
51 lines
1.7 KiB
Diff
|
https://sources.debian.org/src/golang-gopkg-yaml.v3/3.0.1-3/debian/patches/0001-Fix-0b-on-32-bit-systems.patch/
|
||
|
|
||
|
From: Shengjing Zhu <zhsj@debian.org>
|
||
|
Date: Fri, 16 Apr 2021 00:40:09 +0800
|
||
|
Subject: Fix -0b on 32-bit systems
|
||
|
|
||
|
Origin: backport, https://github.com/go-yaml/yaml/pull/442
|
||
|
---
|
||
|
decode_test.go | 7 ++++---
|
||
|
resolve.go | 2 +-
|
||
|
2 files changed, 5 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/decode_test.go b/decode_test.go
|
||
|
index 51f5070..9cac74c 100644
|
||
|
--- a/decode_test.go
|
||
|
+++ b/decode_test.go
|
||
|
@@ -175,9 +175,6 @@ var unmarshalTests = []struct {
|
||
|
}, {
|
||
|
"bin: -0b101010",
|
||
|
map[string]interface{}{"bin": -42},
|
||
|
- }, {
|
||
|
- "bin: -0b1000000000000000000000000000000000000000000000000000000000000000",
|
||
|
- map[string]interface{}{"bin": -9223372036854775808},
|
||
|
}, {
|
||
|
"decimal: +685_230",
|
||
|
map[string]int{"decimal": 685230},
|
||
|
@@ -357,6 +354,10 @@ var unmarshalTests = []struct {
|
||
|
"int64_min: -9223372036854775808",
|
||
|
map[string]int64{"int64_min": math.MinInt64},
|
||
|
},
|
||
|
+ {
|
||
|
+ "int64_min_base2: -0b1000000000000000000000000000000000000000000000000000000000000000",
|
||
|
+ map[string]int64{"int64_min_base2": math.MinInt64},
|
||
|
+ },
|
||
|
{
|
||
|
"int64_neg_base2: -0b111111111111111111111111111111111111111111111111111111111111111",
|
||
|
map[string]int64{"int64_neg_base2": -math.MaxInt64},
|
||
|
diff --git a/resolve.go b/resolve.go
|
||
|
index 64ae888..1b7d8c3 100644
|
||
|
--- a/resolve.go
|
||
|
+++ b/resolve.go
|
||
|
@@ -223,7 +223,7 @@ func resolve(tag string, in string) (rtag string, out interface{}) {
|
||
|
} else if strings.HasPrefix(plain, "-0b") {
|
||
|
intv, err := strconv.ParseInt("-"+plain[3:], 2, 64)
|
||
|
if err == nil {
|
||
|
- if true || intv == int64(int(intv)) {
|
||
|
+ if intv == int64(int(intv)) {
|
||
|
return intTag, int(intv)
|
||
|
} else {
|
||
|
return intTag, intv
|