From d29d9b8b35622fef8c3eb253b7ad6bb46cbbc6a9 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 4 Nov 2009 23:20:49 -0800 Subject: gofmt-ify strconv (and remove an empty line at the end of a file) R=rsc http://go/go-review/1017046 --- src/pkg/strconv/atof_test.go | 8 +-- src/pkg/strconv/atoi_test.go | 8 +-- src/pkg/strconv/decimal.go | 119 +++++++++++++++++++++--------------------- src/pkg/strconv/ftoa_test.go | 6 +-- src/pkg/strconv/itoa_test.go | 4 +- src/pkg/strconv/quote_test.go | 6 +-- 6 files changed, 75 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/pkg/strconv/atof_test.go b/src/pkg/strconv/atof_test.go index c0779d361..f918650f3 100644 --- a/src/pkg/strconv/atof_test.go +++ b/src/pkg/strconv/atof_test.go @@ -5,10 +5,10 @@ package strconv_test import ( - "os"; - "reflect"; - . "strconv"; - "testing"; + "os"; + "reflect"; + . "strconv"; + "testing"; ) type atofTest struct { diff --git a/src/pkg/strconv/atoi_test.go b/src/pkg/strconv/atoi_test.go index 34eadaad5..a3c61fcb8 100644 --- a/src/pkg/strconv/atoi_test.go +++ b/src/pkg/strconv/atoi_test.go @@ -5,10 +5,10 @@ package strconv_test import ( - "os"; - "reflect"; - . "strconv"; - "testing"; + "os"; + "reflect"; + . "strconv"; + "testing"; ) type atoui64Test struct { diff --git a/src/pkg/strconv/decimal.go b/src/pkg/strconv/decimal.go index 72165ea02..1f0205ca3 100644 --- a/src/pkg/strconv/decimal.go +++ b/src/pkg/strconv/decimal.go @@ -16,10 +16,10 @@ import "bytes" type decimal struct { // TODO(rsc): Can make d[] a bit smaller and add // truncated bool; - d [2000] byte; // digits - nd int; // number of digits used - dp int; // decimal point -}; + d [2000]byte; // digits + nd int; // number of digits used + dp int; // decimal point +} func (a *decimal) String() string { n := 10 + a.nd; @@ -42,20 +42,20 @@ func (a *decimal) String() string { w++; buf[w] = '.'; w++; - w += digitZero(buf[w:w+-a.dp]); - w += bytes.Copy(buf[w:w+a.nd], a.d[0:a.nd]); + w += digitZero(buf[w : w + -a.dp]); + w += bytes.Copy(buf[w : w + a.nd], a.d[0 : a.nd]); case a.dp < a.nd: // decimal point in middle of digits - w += bytes.Copy(buf[w:w+a.dp], a.d[0:a.dp]); + w += bytes.Copy(buf[w : w + a.dp], a.d[0 : a.dp]); buf[w] = '.'; w++; - w += bytes.Copy(buf[w:w+a.nd-a.dp], a.d[a.dp:a.nd]); + w += bytes.Copy(buf[w : w + a.nd - a.dp], a.d[a.dp : a.nd]); default: // zeros fill space between digits and decimal point - w += bytes.Copy(buf[w:w+a.nd], a.d[0:a.nd]); - w += digitZero(buf[w:w+a.dp-a.nd]); + w += bytes.Copy(buf[w : w + a.nd], a.d[0 : a.nd]); + w += digitZero(buf[w : w + a.dp - a.nd]); } return string(buf[0:w]); } @@ -78,7 +78,7 @@ func digitZero(dst []byte) int { // (They are meaningless; the decimal point is tracked // independent of the number of digits.) func trim(a *decimal) { - for a.nd > 0 && a.d[a.nd-1] == '0' { + for a.nd > 0 && a.d[a.nd - 1] == '0' { a.nd--; } if a.nd == 0 { @@ -95,14 +95,14 @@ func (a *decimal) Assign(v uint64) { for v > 0 { v1 := v/10; v -= 10*v1; - buf[n] = byte(v + '0'); + buf[n] = byte(v+'0'); n++; v = v1; } // Reverse again to produce forward decimal in a.d. a.nd = 0; - for n--; n>=0; n-- { + for n--; n >= 0; n-- { a.d[a.nd] = buf[n]; a.nd++; } @@ -141,7 +141,7 @@ func rightShift(a *decimal, k uint) { break; } c := int(a.d[r]); - n = n*10 + c-'0'; + n = n*10 + c - '0'; } a.dp -= r-1; @@ -152,7 +152,7 @@ func rightShift(a *decimal, k uint) { n -= dig<= 0; r-- { - n += (int(a.d[r])-'0') << k; + n += (int(a.d[r])-'0')<= '5'; @@ -341,7 +341,7 @@ func (a *decimal) RoundUp(nd int) *decimal { // round up for i := nd-1; i >= 0; i-- { c := a.d[i]; - if c < '9' { // can stop after this digit + if c < '9' { // can stop after this digit a.d[i]++; a.nd = i+1; return a; @@ -375,4 +375,3 @@ func (a *decimal) RoundedInteger() uint64 { } return n; } - diff --git a/src/pkg/strconv/ftoa_test.go b/src/pkg/strconv/ftoa_test.go index 45cdfbfc9..7262b25a6 100644 --- a/src/pkg/strconv/ftoa_test.go +++ b/src/pkg/strconv/ftoa_test.go @@ -5,9 +5,9 @@ package strconv_test import ( - "math"; - . "strconv"; - "testing"; + "math"; + . "strconv"; + "testing"; ) type ftoaTest struct { diff --git a/src/pkg/strconv/itoa_test.go b/src/pkg/strconv/itoa_test.go index 38243f0e8..b8e7ee3ab 100644 --- a/src/pkg/strconv/itoa_test.go +++ b/src/pkg/strconv/itoa_test.go @@ -5,8 +5,8 @@ package strconv_test import ( - . "strconv"; - "testing"; + . "strconv"; + "testing"; ) type itob64Test struct { diff --git a/src/pkg/strconv/quote_test.go b/src/pkg/strconv/quote_test.go index c15e62622..7f8391491 100644 --- a/src/pkg/strconv/quote_test.go +++ b/src/pkg/strconv/quote_test.go @@ -5,9 +5,9 @@ package strconv_test import ( - "os"; - . "strconv"; - "testing"; + "os"; + . "strconv"; + "testing"; ) type quoteTest struct { -- cgit v1.2.3