Skip to content

Commit e134c1d

Browse files
committed
use base 10 to parse integers
The new parsing code passes base 0 to strconv which causes it to interpret leading 0 as indicating an octal number. This is not what we want; in particular Pebble has a lot of tests which use file numbers with leading 0s.
1 parent f84f9e5 commit e134c1d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

datadriven.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,14 +879,14 @@ func parseArgVal(s string, dest reflect.Value) error {
879879
dest.SetBool(b)
880880

881881
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
882-
n, err := strconv.ParseInt(s, 0, int(t.Bits()))
882+
n, err := strconv.ParseInt(s, 10, int(t.Bits()))
883883
if err != nil {
884884
return fmt.Errorf("parse %q as %s: %w", s, t, err)
885885
}
886886
dest.SetInt(n)
887887

888888
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
889-
n, err := strconv.ParseUint(s, 0, int(t.Bits()))
889+
n, err := strconv.ParseUint(s, 10, int(t.Bits()))
890890
if err != nil {
891891
return fmt.Errorf("parse %q as %s: %w", s, t, err)
892892
}

datadriven_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func TestScanArgsSingle(t *testing.T) {
326326
----
327327
[]uint64{0x1, 0x2, 0x3, 0x4}
328328
329-
[]int64 vals=(0xA, 0x10)
329+
[]int64 vals=(10, 000016)
330330
----
331331
[]int64{10, 16}
332332

0 commit comments

Comments
 (0)