]> Cypherpunks repositories - gostls13.git/commitdiff
cgo, goyacc, go/build, html, http, path, path/filepath, testing/quick, test: use...
authorRuss Cox <rsc@golang.org>
Wed, 26 Oct 2011 05:20:02 +0000 (22:20 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 26 Oct 2011 05:20:02 +0000 (22:20 -0700)
Nothing terribly interesting here.

R=golang-dev, bradfitz, gri, r
CC=golang-dev
https://golang.org/cl/5300043

20 files changed:
src/cmd/cgo/gcc.go
src/cmd/cgo/util.go
src/cmd/goyacc/goyacc.go
src/pkg/go/build/dir.go
src/pkg/html/entity.go
src/pkg/html/escape.go
src/pkg/http/cgi/host.go
src/pkg/path/filepath/match.go
src/pkg/path/match.go
src/pkg/syscall/exec_windows.go
src/pkg/syscall/syscall_windows.go
src/pkg/testing/quick/quick.go
test/convlit.go
test/fixedbugs/bug204.go
test/ken/string.go
test/range.go
test/solitaire.go
test/string_lit.go
test/stringrange.go
test/utf.go

index 1864eed09afb2407bf8fa10c2cfc614a60347c8a..97297a86045e5c1f2dc4229776fbc53ee765488a 100644 (file)
@@ -71,7 +71,7 @@ func (p *Package) ParseFlags(f *File, srcfile string) {
 NextLine:
        for _, line := range linesIn {
                l := strings.TrimSpace(line)
-               if len(l) < 5 || l[:4] != "#cgo" || !unicode.IsSpace(int(l[4])) {
+               if len(l) < 5 || l[:4] != "#cgo" || !unicode.IsSpace(rune(l[4])) {
                        linesOut = append(linesOut, line)
                        continue
                }
@@ -193,28 +193,28 @@ func pkgConfig(packages []string) (cflags, ldflags []string, err os.Error) {
 //
 func splitQuoted(s string) (r []string, err os.Error) {
        var args []string
-       arg := make([]int, len(s))
+       arg := make([]rune, len(s))
        escaped := false
        quoted := false
-       quote := 0
+       quote := rune(0)
        i := 0
-       for _, rune := range s {
+       for _, r := range s {
                switch {
                case escaped:
                        escaped = false
-               case rune == '\\':
+               case r == '\\':
                        escaped = true
                        continue
                case quote != 0:
-                       if rune == quote {
+                       if r == quote {
                                quote = 0
                                continue
                        }
-               case rune == '"' || rune == '\'':
+               case r == '"' || r == '\'':
                        quoted = true
-                       quote = rune
+                       quote = r
                        continue
-               case unicode.IsSpace(rune):
+               case unicode.IsSpace(r):
                        if quoted || i > 0 {
                                quoted = false
                                args = append(args, string(arg[:i]))
@@ -222,7 +222,7 @@ func splitQuoted(s string) (r []string, err os.Error) {
                        }
                        continue
                }
-               arg[i] = rune
+               arg[i] = r
                i++
        }
        if quoted || i > 0 {
index e79b0e1bfae55fd1685309dd32ddc1d0eb6542f5..a9c4e8fde7c47964717f7dcb915dc001d3ed600e 100644 (file)
@@ -102,7 +102,7 @@ func creat(name string) *os.File {
        return f
 }
 
-func slashToUnderscore(c int) int {
+func slashToUnderscore(c rune) rune {
        if c == '/' || c == '\\' || c == ':' {
                c = '_'
        }
index 4ce0c73703efb2a5681614700579e25dc2561d0b..d1a90798123f50f98a71a43830d7013e3c672b18 100644 (file)
@@ -813,7 +813,8 @@ func defin(nt int, s string) int {
 var peekline = 0
 
 func gettok() int {
-       var i, match, c int
+       var i int
+       var match, c rune
 
        tokname = ""
        for {
@@ -919,25 +920,25 @@ func gettok() int {
 
                getword(c)
                // find a reserved word
-               for c = 0; c < len(resrv); c++ {
-                       if tokname == resrv[c].name {
+               for i := range resrv {
+                       if tokname == resrv[i].name {
                                if tokflag {
                                        fmt.Printf(">>> %%%v %v %v\n", tokname,
-                                               resrv[c].value-PRIVATE, lineno)
+                                               resrv[i].value-PRIVATE, lineno)
                                }
-                               return resrv[c].value
+                               return resrv[i].value
                        }
                }
                errorf("invalid escape, or illegal reserved word: %v", tokname)
 
        case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
-               numbval = c - '0'
+               numbval = int(c - '0')
                for {
                        c = getrune(finput)
                        if !isdigit(c) {
                                break
                        }
-                       numbval = numbval*10 + c - '0'
+                       numbval = numbval*10 + int(c-'0')
                }
                ungetrune(finput, c)
                if tokflag {
@@ -953,7 +954,7 @@ func gettok() int {
                if tokflag {
                        fmt.Printf(">>> OPERATOR %v %v\n", string(c), lineno)
                }
-               return c
+               return int(c)
        }
 
        // look ahead to distinguish IDENTIFIER from IDENTCOLON
@@ -982,7 +983,7 @@ func gettok() int {
        return IDENTIFIER
 }
 
-func getword(c int) {
+func getword(c rune) {
        tokname = ""
        for isword(c) || isdigit(c) || c == '_' || c == '.' || c == '$' {
                tokname += string(c)
@@ -1107,7 +1108,7 @@ func cpycode() {
 // skipcom is called after reading a '/'
 //
 func skipcom() int {
-       var c int
+       var c rune
 
        c = getrune(finput)
        if c == '/' {
@@ -1221,7 +1222,7 @@ loop:
                        j := 0
                        if isdigit(c) {
                                for isdigit(c) {
-                                       j = j*10 + c - '0'
+                                       j = j*10 + int(c-'0')
                                        c = getrune(finput)
                                }
                                ungetrune(finput, c)
@@ -2837,10 +2838,10 @@ func others() {
        fmt.Fprintf(ftable, "%d,\n}\n", 0)
 
        // copy parser text
-       c = getrune(finput)
-       for c != EOF {
-               ftable.WriteRune(c)
-               c = getrune(finput)
+       ch := getrune(finput)
+       for ch != EOF {
+               ftable.WriteRune(ch)
+               ch = getrune(finput)
        }
 
        // copy yaccpar
@@ -2976,11 +2977,11 @@ func prlook(p Lkset) {
 //
 // utility routines
 //
-var peekrune int
+var peekrune rune
 
-func isdigit(c int) bool { return c >= '0' && c <= '9' }
+func isdigit(c rune) bool { return c >= '0' && c <= '9' }
 
-func isword(c int) bool {
+func isword(c rune) bool {
        return c >= 0xa0 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
 }
 
@@ -3010,8 +3011,8 @@ func putrune(f *bufio.Writer, c int) {
        }
 }
 
-func getrune(f *bufio.Reader) int {
-       var r int
+func getrune(f *bufio.Reader) rune {
+       var r rune
 
        if peekrune != 0 {
                if peekrune == EOF {
@@ -3033,7 +3034,7 @@ func getrune(f *bufio.Reader) int {
        return c
 }
 
-func ungetrune(f *bufio.Reader, c int) {
+func ungetrune(f *bufio.Reader, c rune) {
        if f != finput {
                panic("ungetc - not finput")
        }
index 3ee10ab3484448eb8d21c69e22852e7a7de9bce7..b67f999b7662cf7370c2cac219e08e55aaa3ced0 100644 (file)
@@ -461,10 +461,10 @@ func safeName(s string) bool {
 //
 func splitQuoted(s string) (r []string, err os.Error) {
        var args []string
-       arg := make([]int, len(s))
+       arg := make([]rune, len(s))
        escaped := false
        quoted := false
-       quote := 0
+       quote := rune(0)
        i := 0
        for _, rune := range s {
                switch {
index 21263e22d8c3b336a2ebf4dcc2fe43ce62be818f..bd83075235999368865ad74c31314ef16c1ed6d7 100644 (file)
@@ -13,7 +13,7 @@ const longestEntityWithoutSemicolon = 6
 //
 // Note that the HTML5 list is larger than the HTML4 list at
 // http://www.w3.org/TR/html4/sgml/entities.html
-var entity = map[string]int{
+var entity = map[string]rune{
        "AElig;":                           '\U000000C6',
        "AMP;":                             '\U00000026',
        "Aacute;":                          '\U000000C1',
@@ -2155,7 +2155,7 @@ var entity = map[string]int{
 }
 
 // HTML entities that are two unicode codepoints.
-var entity2 = map[string][2]int{
+var entity2 = map[string][2]rune{
        // TODO(nigeltao): Handle replacements that are wider than their names.
        // "nLt;":                     {'\u226A', '\u20D2'},
        // "nGt;":                     {'\u226B', '\u20D2'},
index e9edc474da51373728a0396d9fd13b414e9569d6..69e0028e445bdd40c66917ea7841963133806356 100644 (file)
@@ -14,7 +14,7 @@ import (
 // These replacements permit compatibility with old numeric entities that 
 // assumed Windows-1252 encoding.
 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#consume-a-character-reference
-var replacementTable = [...]int{
+var replacementTable = [...]rune{
        '\u20AC', // First entry is what 0x80 should be replaced with.
        '\u0081',
        '\u201A',
@@ -79,23 +79,23 @@ func unescapeEntity(b []byte, dst, src int, attribute bool) (dst1, src1 int) {
                        i++
                }
 
-               x := 0
+               x := rune(0)
                for i < len(s) {
                        c = s[i]
                        i++
                        if hex {
                                if '0' <= c && c <= '9' {
-                                       x = 16*x + int(c) - '0'
+                                       x = 16*x + rune(c) - '0'
                                        continue
                                } else if 'a' <= c && c <= 'f' {
-                                       x = 16*x + int(c) - 'a' + 10
+                                       x = 16*x + rune(c) - 'a' + 10
                                        continue
                                } else if 'A' <= c && c <= 'F' {
-                                       x = 16*x + int(c) - 'A' + 10
+                                       x = 16*x + rune(c) - 'A' + 10
                                        continue
                                }
                        } else if '0' <= c && c <= '9' {
-                               x = 10*x + int(c) - '0'
+                               x = 10*x + rune(c) - '0'
                                continue
                        }
                        if c != ';' {
index 9ea4c9d8bf2ededd9393d1ad4372100b13678e05..365a712dfa85b2bb57512b4a80a6940da5d92405 100644 (file)
@@ -333,18 +333,18 @@ func (h *Handler) handleInternalRedirect(rw http.ResponseWriter, req *http.Reque
        h.PathLocationHandler.ServeHTTP(rw, newReq)
 }
 
-func upperCaseAndUnderscore(rune int) int {
+func upperCaseAndUnderscore(r rune) rune {
        switch {
-       case rune >= 'a' && rune <= 'z':
-               return rune - ('a' - 'A')
-       case rune == '-':
+       case r >= 'a' && r <= 'z':
+               return r - ('a' - 'A')
+       case r == '-':
                return '_'
-       case rune == '=':
+       case r == '=':
                // Maybe not part of the CGI 'spec' but would mess up
                // the environment in any case, as Go represents the
                // environment as a slice of "key=value" strings.
                return '_'
        }
        // TODO: other transformations in spec or practice?
-       return rune
+       return r
 }
index 0ccc87e65607393b821d956c5143e20940003260..15c84a7e9850ad3bf991455485debe90796f81c7 100644 (file)
@@ -136,7 +136,7 @@ func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) {
                                        chunk = chunk[1:]
                                        break
                                }
-                               var lo, hi int
+                               var lo, hi rune
                                if lo, chunk, err = getEsc(chunk); err != nil {
                                        return
                                }
@@ -183,7 +183,7 @@ func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) {
 }
 
 // getEsc gets a possibly-escaped character from chunk, for a character class.
-func getEsc(chunk string) (r int, nchunk string, err os.Error) {
+func getEsc(chunk string) (r rune, nchunk string, err os.Error) {
        if len(chunk) == 0 || chunk[0] == '-' || chunk[0] == ']' {
                err = ErrBadPattern
                return
index efb8c5ce7fcf075d81ce04cb3101b10eadc2f298..e9d032799fe7a8ca5676a1e06b6c7add193c982c 100644 (file)
@@ -136,7 +136,7 @@ func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) {
                                        chunk = chunk[1:]
                                        break
                                }
-                               var lo, hi int
+                               var lo, hi rune
                                if lo, chunk, err = getEsc(chunk); err != nil {
                                        return
                                }
@@ -183,7 +183,7 @@ func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) {
 }
 
 // getEsc gets a possibly-escaped character from chunk, for a character class.
-func getEsc(chunk string) (r int, nchunk string, err os.Error) {
+func getEsc(chunk string) (r rune, nchunk string, err os.Error) {
        if len(chunk) == 0 || chunk[0] == '-' || chunk[0] == ']' {
                err = ErrBadPattern
                return
index e8b540ad1603e6e247adf1aecfd3e59edc967dd7..e4fafdb9924a5411abfc76b9de0dea70160f1231 100644 (file)
@@ -100,7 +100,7 @@ func makeCmdLine(args []string) string {
 // Last bytes are two UCS-2 NULs, or four NUL bytes.
 func createEnvBlock(envv []string) *uint16 {
        if len(envv) == 0 {
-               return &utf16.Encode([]int("\x00\x00"))[0]
+               return &utf16.Encode([]rune("\x00\x00"))[0]
        }
        length := 0
        for _, s := range envv {
@@ -118,7 +118,7 @@ func createEnvBlock(envv []string) *uint16 {
        }
        copy(b[i:i+1], []byte{0})
 
-       return &utf16.Encode([]int(string(b)))[0]
+       return &utf16.Encode([]rune(string(b)))[0]
 }
 
 func CloseOnExec(fd Handle) {
index 25e90eb6f3696c8ae1edb434918a44c1772ce19b..ea62df6a1f228a3d50cfec10b7656bbaa8b51491 100644 (file)
@@ -56,7 +56,7 @@ func main() {
 
 // StringToUTF16 returns the UTF-16 encoding of the UTF-8 string s,
 // with a terminating NUL added.
-func StringToUTF16(s string) []uint16 { return utf16.Encode([]int(s + "\x00")) }
+func StringToUTF16(s string) []uint16 { return utf16.Encode([]rune(s + "\x00")) }
 
 // UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s,
 // with a terminating NUL removed.
index 756a60e1352bf15bbec1892a4c16eccd126dc40c..9ec1925de3d36739c5eb70fcca010d2c7a41038c 100644 (file)
@@ -123,9 +123,9 @@ func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool) {
                return s, true
        case reflect.String:
                numChars := rand.Intn(complexSize)
-               codePoints := make([]int, numChars)
+               codePoints := make([]rune, numChars)
                for i := 0; i < numChars; i++ {
-                       codePoints[i] = rand.Intn(0x10ffff)
+                       codePoints[i] = rune(rand.Intn(0x10ffff))
                }
                return reflect.ValueOf(string(codePoints)), true
        case reflect.Struct:
index 90ac5490c84d2531fd8c97b78f2fe59f72f99128..2e3b15bda10a03af97966593375f3e7cdecac69b 100644 (file)
@@ -36,7 +36,7 @@ var good3 int = 1e9
 var good4 float64 = 1e20
 
 // explicit conversion of string is okay
-var _ = []int("abc")
+var _ = []rune("abc")
 var _ = []byte("abc")
 
 // implicit is not
@@ -47,20 +47,20 @@ var _ []byte = "abc" // ERROR "cannot use|incompatible|invalid"
 type Tstring string
 
 var ss Tstring = "abc"
-var _ = []int(ss)
+var _ = []rune(ss)
 var _ = []byte(ss)
 
 // implicit is still not
-var _ []int = ss  // ERROR "cannot use|incompatible|invalid"
+var _ []rune = ss // ERROR "cannot use|incompatible|invalid"
 var _ []byte = ss // ERROR "cannot use|incompatible|invalid"
 
 // named slice is not
-type Tint []int
+type Trune []rune
 type Tbyte []byte
 
-var _ = Tint("abc")  // ERROR "convert|incompatible|invalid"
+var _ = Trune("abc") // ERROR "convert|incompatible|invalid"
 var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid"
 
 // implicit is still not
-var _ Tint = "abc"  // ERROR "cannot use|incompatible|invalid"
+var _ Trune = "abc" // ERROR "cannot use|incompatible|invalid"
 var _ Tbyte = "abc" // ERROR "cannot use|incompatible|invalid"
index d4534c27c56672b16079c195a9d5af8718c9cb9f..adf0aafd6b2773874075ef75616e67e6e3b5dc2a 100644 (file)
@@ -7,18 +7,18 @@
 package main
 
 func main() {
-       nchar := 0;
-       a := []int { '日', '本', '語', 0xFFFD };
+       nchar := 0
+       a := []rune{'日', '本', '語', 0xFFFD}
        for _, char := range "日本語\xc0" {
                if nchar >= len(a) {
-                       println("BUG");
-                       break;
+                       println("BUG")
+                       break
                }
                if char != a[nchar] {
-                       println("expected", a[nchar], "got", char);
-                       println("BUG");
-                       break;
+                       println("expected", a[nchar], "got", char)
+                       println("BUG")
+                       break
                }
-               nchar++;
+               nchar++
        }
 }
index cbedad4e882e9a7e651f9ee7d9fd0f5bdf5b7a2f..b74bd7d6f1c1dcefa607fdcfc985c8fd6d949068 100644 (file)
@@ -95,7 +95,7 @@ func main() {
        }
 
        /* create string with int array */
-       var z2 [3]int
+       var z2 [3]rune
        z2[0] = 'a'
        z2[1] = '\u1234'
        z2[2] = 'c'
index 91ccd6307a56de463ad6f5bd456fb644bf8f0d17..84119450b281fe589f1622172be90eced182a5a8 100644 (file)
@@ -172,7 +172,7 @@ func makestring() string {
 }
 
 func teststring() {
-       s := 0
+       var s rune
        nmake = 0
        for _, v := range makestring() {
                s += v
@@ -208,7 +208,7 @@ func teststring1() {
 
 func makemap() map[int]int {
        nmake++
-       return map[int]int{0:'a', 1:'b', 2:'c', 3:'d', 4:'☺'}
+       return map[int]int{0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: '☺'}
 }
 
 func testmap() {
index c789bf24a0fc40f887412dc40dcf15f00a38dfa6..473a1d12d7d7f25eff50f7e21b1de78a0c40af60 100644 (file)
@@ -14,7 +14,7 @@ const N = 11 + 1 // length of a board row (+1 for newline)
 // The board must be surrounded by 2 illegal fields in each direction
 // so that move() doesn't need to check the board boundaries. Periods
 // represent illegal fields, ● are pegs, and ○ are holes.
-var board = []int(
+var board = []rune(
        `...........
 ...........
 ....●●●....
@@ -28,7 +28,6 @@ var board = []int(
 ...........
 `)
 
-
 // center is the position of the center hole if there is a single one;
 // otherwise it is -1.
 var center int
@@ -46,7 +45,6 @@ func init() {
        }
 }
 
-
 var moves int // number of times move is called
 
 // move tests if there is a peg at position pos that can jump over another peg
@@ -63,7 +61,6 @@ func move(pos, dir int) bool {
        return false
 }
 
-
 // unmove reverts a previously executed valid move.
 func unmove(pos, dir int) {
        board[pos] = '●'
@@ -71,7 +68,6 @@ func unmove(pos, dir int) {
        board[pos+2*dir] = '○'
 }
 
-
 // solve tries to find a sequence of moves such that there is only one peg left
 // at the end; if center is >= 0, that last peg must be in the center position.
 // If a solution is found, solve prints the board after each move in a backward
@@ -110,7 +106,6 @@ func solve() bool {
        return false
 }
 
-
 func main() {
        if !solve() {
                println("no solution found")
index 4358dd8e822205a43d31cdfad5001c9e6cd1081d..c702a05e91fa6a07fd9e65cad9a0c0cbe17b643a 100644 (file)
@@ -35,14 +35,14 @@ func assert(a, b, c string) {
 }
 
 const (
-       gx1 = "aä本☺"
-       gx2 = "aä\xFF\xFF本☺"
+       gx1    = "aä本☺"
+       gx2    = "aä\xFF\xFF本☺"
        gx2fix = "aä\uFFFD\uFFFD本☺"
 )
 
 var (
-       gr1 = []int(gx1)
-       gr2 = []int(gx2)
+       gr1 = []rune(gx1)
+       gr2 = []rune(gx2)
        gb1 = []byte(gx1)
        gb2 = []byte(gx2)
 )
@@ -93,26 +93,26 @@ func main() {
 
        // test large runes. perhaps not the most logical place for this test.
        var r int32
-       r = 0x10ffff;   // largest rune value
+       r = 0x10ffff // largest rune value
        s = string(r)
        assert(s, "\xf4\x8f\xbf\xbf", "largest rune")
        r = 0x10ffff + 1
        s = string(r)
        assert(s, "\xef\xbf\xbd", "too-large rune")
 
-       assert(string(gr1), gx1, "global ->[]int")
-       assert(string(gr2), gx2fix, "global invalid ->[]int")
+       assert(string(gr1), gx1, "global ->[]rune")
+       assert(string(gr2), gx2fix, "global invalid ->[]rune")
        assert(string(gb1), gx1, "->[]byte")
        assert(string(gb2), gx2, "global invalid ->[]byte")
 
        var (
-               r1 = []int(gx1)
-               r2 = []int(gx2)
+               r1 = []rune(gx1)
+               r2 = []rune(gx2)
                b1 = []byte(gx1)
                b2 = []byte(gx2)
        )
-       assert(string(r1), gx1, "->[]int")
-       assert(string(r2), gx2fix, "invalid ->[]int")
+       assert(string(r1), gx1, "->[]rune")
+       assert(string(r2), gx2fix, "invalid ->[]rune")
        assert(string(b1), gx1, "->[]byte")
        assert(string(b2), gx2, "invalid ->[]byte")
 
index d5ada2628dfbf8930cc0b61cc593f2f241bb7ea1..924022b48e723712463d9d57141aef92f38e980f 100644 (file)
@@ -14,23 +14,24 @@ import (
 
 func main() {
        s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx"
-       expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' }
+       expect := []rune{0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x'}
        offset := 0
-       var i, c int
+       var i int
+       var c rune
        ok := true
        cnum := 0
        for i, c = range s {
-               rune, size := utf8.DecodeRuneInString(s[i:len(s)])  // check it another way
+               r, size := utf8.DecodeRuneInString(s[i:len(s)]) // check it another way
                if i != offset {
                        fmt.Printf("unexpected offset %d not %d\n", i, offset)
                        ok = false
                }
-               if rune != expect[cnum] {
-                       fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, rune, expect[cnum])
+               if r != expect[cnum] {
+                       fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, r, expect[cnum])
                        ok = false
                }
                if c != expect[cnum] {
-                       fmt.Printf("unexpected rune %d from range: %x not %x\n", i, rune, expect[cnum])
+                       fmt.Printf("unexpected rune %d from range: %x not %x\n", i, r, expect[cnum])
                        ok = false
                }
                offset += size
index a93fc293416ef31ace5d7dad6eaca7c3666d3d36..ed8a983d8f109c9c3b216817fe787f019bdd84af 100644 (file)
@@ -9,7 +9,7 @@ package main
 import "utf8"
 
 func main() {
-       var chars [6] int
+       var chars [6]rune
        chars[0] = 'a'
        chars[1] = 'b'
        chars[2] = 'c'
@@ -21,16 +21,22 @@ func main() {
                s += string(chars[i])
        }
        var l = len(s)
-       for w, i, j := 0,0,0; i < l; i += w {
-               var r int
+       for w, i, j := 0, 0, 0; i < l; i += w {
+               var r rune
                r, w = utf8.DecodeRuneInString(s[i:len(s)])
-               if w == 0 { panic("zero width in string") }
-               if r != chars[j] { panic("wrong value from string") }
+               if w == 0 {
+                       panic("zero width in string")
+               }
+               if r != chars[j] {
+                       panic("wrong value from string")
+               }
                j++
        }
        // encoded as bytes:  'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e
        const L = 12
-       if L != l { panic("wrong length constructing array") }
+       if L != l {
+               panic("wrong length constructing array")
+       }
        a := make([]byte, L)
        a[0] = 'a'
        a[1] = 'b'
@@ -44,11 +50,15 @@ func main() {
        a[9] = 0xe8
        a[10] = 0xaa
        a[11] = 0x9e
-       for w, i, j := 0,0,0; i < L; i += w {
-               var r int
+       for w, i, j := 0, 0, 0; i < L; i += w {
+               var r rune
                r, w = utf8.DecodeRune(a[i:L])
-               if w == 0 { panic("zero width in bytes") }
-               if r != chars[j] { panic("wrong value from bytes") }
+               if w == 0 {
+                       panic("zero width in bytes")
+               }
+               if r != chars[j] {
+                       panic("wrong value from bytes")
+               }
                j++
        }
 }