]> Cypherpunks repositories - gostls13.git/commitdiff
big: update for fmt interface changes
authorRuss Cox <rsc@golang.org>
Wed, 26 Oct 2011 05:21:49 +0000 (22:21 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 26 Oct 2011 05:21:49 +0000 (22:21 -0700)
Nothing terribly interesting here.

R=gri
CC=golang-dev
https://golang.org/cl/5305046

src/pkg/big/int.go
src/pkg/big/nat.go
src/pkg/big/nat_test.go
src/pkg/big/rat.go

index b0dde1e6e372505b99c804adc800fea9e8d2a002..db13d20f71c3875c21b1c4a27d8ff151d23011a6 100644 (file)
@@ -302,7 +302,7 @@ func (x *Int) String() string {
        return x.abs.decimalString()
 }
 
-func charset(ch int) string {
+func charset(ch rune) string {
        switch ch {
        case 'b':
                return lowercaseDigits[0:2]
@@ -339,7 +339,7 @@ func writeMultiple(s fmt.State, text string, count int) {
 // output field width, space or zero padding, and left or
 // right justification.
 //
-func (x *Int) Format(s fmt.State, ch int) {
+func (x *Int) Format(s fmt.State, ch rune) {
        cs := charset(ch)
 
        // special cases
@@ -460,7 +460,7 @@ func (z *Int) scan(r io.RuneScanner, base int) (*Int, int, os.Error) {
 // Scan is a support routine for fmt.Scanner; it sets z to the value of
 // the scanned number. It accepts the formats 'b' (binary), 'o' (octal),
 // 'd' (decimal), 'x' (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
-func (z *Int) Scan(s fmt.ScanState, ch int) os.Error {
+func (z *Int) Scan(s fmt.ScanState, ch rune) os.Error {
        s.SkipSpace() // skip leading space characters
        base := 0
        switch ch {
index c0769d88a91ae40f53e472154bda8a9f3104a8df..fa0d7e72277c482fd5c10b779266488213cf6640 100644 (file)
@@ -589,15 +589,15 @@ func (x nat) bitLen() int {
 // MaxBase is the largest number base accepted for string conversions.
 const MaxBase = 'z' - 'a' + 10 + 1 // = hexValue('z') + 1
 
-func hexValue(ch int) Word {
+func hexValue(ch rune) Word {
        d := MaxBase + 1 // illegal base
        switch {
        case '0' <= ch && ch <= '9':
-               d = ch - '0'
+               d = int(ch - '0')
        case 'a' <= ch && ch <= 'z':
-               d = ch - 'a' + 10
+               d = int(ch - 'a' + 10)
        case 'A' <= ch && ch <= 'Z':
-               d = ch - 'A' + 10
+               d = int(ch - 'A' + 10)
        }
        return Word(d)
 }
index 4f5732824c5b4fe8ec4606a424c3944c114ae659..ab34c6ec189fd47c154066adfb6661670db5f94b 100644 (file)
@@ -231,7 +231,7 @@ var natScanTests = []struct {
        x    nat    // expected nat
        b    int    // expected base
        ok   bool   // expected success
-       next int    // next character (or 0, if at EOF)
+       next rune   // next character (or 0, if at EOF)
 }{
        // error: illegal base
        {base: -1},
index 6b8606272065d243cc086b46197638071ad548b8..1940a05494da0454211c031add8129fdc6c11e97 100644 (file)
@@ -249,13 +249,13 @@ func (z *Rat) Quo(x, y *Rat) *Rat {
        return z.norm()
 }
 
-func ratTok(ch int) bool {
+func ratTok(ch rune) bool {
        return strings.IndexRune("+-/0123456789.eE", ch) >= 0
 }
 
 // Scan is a support routine for fmt.Scanner. It accepts the formats
 // 'e', 'E', 'f', 'F', 'g', 'G', and 'v'. All formats are equivalent.
-func (z *Rat) Scan(s fmt.ScanState, ch int) os.Error {
+func (z *Rat) Scan(s fmt.ScanState, ch rune) os.Error {
        tok, err := s.Token(true, ratTok)
        if err != nil {
                return err