From 7337a63f5a068f10b201c64052a241ebc8de84ec Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Thu, 16 Oct 2014 05:58:50 -0700 Subject: [PATCH] Use MaxInt instead of MaxInt64 for ints This is causing an integer overflow on 386 go builds, because ints are int32 and not int64 on this platform. --- match_test.go | 7 +++---- queryparser.go | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/match_test.go b/match_test.go index c594eb5..fc2adc6 100644 --- a/match_test.go +++ b/match_test.go @@ -2,7 +2,6 @@ package toml import ( "fmt" - "math" "testing" ) @@ -110,7 +109,7 @@ func TestPathSliceStart(t *testing.T) { assertPath(t, "$[123:]", buildPath( - newMatchSliceFn(123, math.MaxInt64, 1), + newMatchSliceFn(123, MaxInt, 1), )) } @@ -134,7 +133,7 @@ func TestPathSliceStartStep(t *testing.T) { assertPath(t, "$[123::7]", buildPath( - newMatchSliceFn(123, math.MaxInt64, 7), + newMatchSliceFn(123, MaxInt, 7), )) } @@ -150,7 +149,7 @@ func TestPathSliceStep(t *testing.T) { assertPath(t, "$[::7]", buildPath( - newMatchSliceFn(0, math.MaxInt64, 7), + newMatchSliceFn(0, MaxInt, 7), )) } diff --git a/queryparser.go b/queryparser.go index be6954f..8c0de8d 100644 --- a/queryparser.go +++ b/queryparser.go @@ -9,9 +9,10 @@ package toml import ( "fmt" - "math" ) +const MaxInt = int(^uint(0) >> 1) + type queryParser struct { flow chan token tokensBuffer []token @@ -203,7 +204,7 @@ loop: // labeled loop for easy breaking func (p *queryParser) parseSliceExpr() queryParserStateFn { // init slice to grab all elements - start, end, step := 0, math.MaxInt64, 1 + start, end, step := 0, MaxInt, 1 // parse optional start tok := p.getToken()