From db645a024d5b152ffa219ef51de0be0e8240af99 Mon Sep 17 00:00:00 2001 From: Volker Dobler Date: Mon, 20 Aug 2012 22:30:04 +1000 Subject: [PATCH] strconv: consistent parameter names for ParseUint If ParseUint is like ParseInt it should have the same parameter names, thus rename b to to base as in ParseInt's documentation. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/6453152 --- src/pkg/strconv/atoi.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pkg/strconv/atoi.go b/src/pkg/strconv/atoi.go index 59ef264d17c..bdd5d71f875 100644 --- a/src/pkg/strconv/atoi.go +++ b/src/pkg/strconv/atoi.go @@ -44,7 +44,7 @@ func cutoff64(base int) uint64 { } // ParseUint is like ParseInt but for unsigned numbers. -func ParseUint(s string, b int, bitSize int) (n uint64, err error) { +func ParseUint(s string, base int, bitSize int) (n uint64, err error) { var cutoff, maxVal uint64 if bitSize == 0 { @@ -57,32 +57,32 @@ func ParseUint(s string, b int, bitSize int) (n uint64, err error) { err = ErrSyntax goto Error - case 2 <= b && b <= 36: + case 2 <= base && base <= 36: // valid base; nothing to do - case b == 0: + case base == 0: // Look for octal, hex prefix. switch { case s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'): - b = 16 + base = 16 s = s[2:] if len(s) < 1 { err = ErrSyntax goto Error } case s[0] == '0': - b = 8 + base = 8 default: - b = 10 + base = 10 } default: - err = errors.New("invalid base " + Itoa(b)) + err = errors.New("invalid base " + Itoa(base)) goto Error } n = 0 - cutoff = cutoff64(b) + cutoff = cutoff64(base) maxVal = 1<= b { + if int(v) >= base { n = 0 err = ErrSyntax goto Error } if n >= cutoff { - // n*b overflows + // n*base overflows n = 1<<64 - 1 err = ErrRange goto Error } - n *= uint64(b) + n *= uint64(base) n1 := n + uint64(v) if n1 < n || n1 > maxVal {