diff --git a/doc/progs/cat.go b/doc/progs/cat.go index c06a730cefa..1f6c0f9df65 100644 --- a/doc/progs/cat.go +++ b/doc/progs/cat.go @@ -15,7 +15,7 @@ func cat(f *file.File) { const NBUF = 512; var buf [NBUF]byte; for { - switch nr, er := f.Read(buf); true { + switch nr, er := f.Read(&buf); true { case nr < 0: fmt.Fprintf(os.Stderr, "error reading from %s: %s\n", f.String(), er.String()); sys.Exit(1); diff --git a/doc/progs/cat_rot13.go b/doc/progs/cat_rot13.go index 618ae911167..aba8b4c7fb0 100644 --- a/doc/progs/cat_rot13.go +++ b/doc/progs/cat_rot13.go @@ -57,7 +57,7 @@ func cat(r reader) { r = newRotate13(r) } for { - switch nr, er := r.Read(buf); { + switch nr, er := r.Read(&buf); { case nr < 0: fmt.Fprintf(os.Stderr, "error reading from %s: %s\n", r.String(), er.String()); sys.Exit(1); diff --git a/doc/progs/sum.go b/doc/progs/sum.go index 19600af066a..f087ca3e5c4 100644 --- a/doc/progs/sum.go +++ b/doc/progs/sum.go @@ -16,6 +16,6 @@ func sum(a []int) int { // returns an int func main() { - s := sum([3]int{1,2,3}); // a slice of the array is passed to sum + s := sum(&[3]int{1,2,3}); // a slice of the array is passed to sum fmt.Print(s, "\n"); } diff --git a/src/lib/exec.go b/src/lib/exec.go index 425b94eb3ac..6808b95542e 100644 --- a/src/lib/exec.go +++ b/src/lib/exec.go @@ -96,7 +96,7 @@ func Run(argv0 string, argv, envv []string, stdin, stdout, stderr int) (p *Cmd, } // Run command. - p.Pid, err = os.ForkExec(argv0, argv, envv, fd); + p.Pid, err = os.ForkExec(argv0, argv, envv, &fd); if err != nil { goto Error; } diff --git a/src/lib/exec_test.go b/src/lib/exec_test.go index f4038fbc236..e67c75da3a0 100644 --- a/src/lib/exec_test.go +++ b/src/lib/exec_test.go @@ -19,7 +19,7 @@ func TestRunCat(t *testing.T) { io.WriteString(cmd.Stdin, "hello, world\n"); cmd.Stdin.Close(); var buf [64]byte; - n, err1 := io.Readn(cmd.Stdout, buf); + n, err1 := io.Readn(cmd.Stdout, &buf); if err1 != nil && err1 != io.ErrEOF { t.Fatalf("reading from /bin/cat: %v", err1); } @@ -38,7 +38,7 @@ func TestRunEcho(t *testing.T) { t.Fatalf("opencmd /bin/echo: %v", err); } var buf [64]byte; - n, err1 := io.Readn(cmd.Stdout, buf); + n, err1 := io.Readn(cmd.Stdout, &buf); if err1 != nil && err1 != io.ErrEOF { t.Fatalf("reading from /bin/echo: %v", err1); } diff --git a/src/lib/go/scanner.go b/src/lib/go/scanner.go index e35cc5c7223..ea5f13769c9 100644 --- a/src/lib/go/scanner.go +++ b/src/lib/go/scanner.go @@ -104,7 +104,7 @@ func charString(ch int) string { case '\v': s = `\v`; case '\\': s = `\\`; case '\'': s = `\'`; - default : s = utf8.EncodeRuneToString(ch); + default : s = string(ch); } return "'" + s + "' (U+" + strconv.Itob(ch, 16) + ")"; } diff --git a/src/lib/hash/md5.go b/src/lib/hash/md5.go index ab3201ffb8b..d9fc6157dc5 100644 --- a/src/lib/hash/md5.go +++ b/src/lib/hash/md5.go @@ -51,7 +51,7 @@ func (d *Digest) Write(p []byte) (nn int, err *os.Error) { } d.nx += n; if d.nx == _Chunk { - _Block(d, d.x); + _Block(d, &d.x); d.nx = 0; } p = p[n:len(p)]; diff --git a/src/lib/hash/sha1.go b/src/lib/hash/sha1.go index 0bf284ef1ac..788eda860ec 100644 --- a/src/lib/hash/sha1.go +++ b/src/lib/hash/sha1.go @@ -53,7 +53,7 @@ func (d *Digest) Write(p []byte) (nn int, err *os.Error) { } d.nx += n; if d.nx == _Chunk { - _Block(d, d.x); + _Block(d, &d.x); d.nx = 0; } p = p[n:len(p)]; diff --git a/src/lib/http/fs.go b/src/lib/http/fs.go index d93859dd25c..23a994aa0d7 100644 --- a/src/lib/http/fs.go +++ b/src/lib/http/fs.go @@ -142,7 +142,7 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) { } else { // read first chunk to decide between utf-8 text and binary var buf [1024]byte; - n, err := io.Readn(f, buf); + n, err := io.Readn(f, &buf); b := buf[0:n]; if isText(b) { c.SetHeader("Content-Type", "text-plain; charset=utf-8"); diff --git a/src/lib/io/pipe_test.go b/src/lib/io/pipe_test.go index df2ed89417b..3358ef20329 100644 --- a/src/lib/io/pipe_test.go +++ b/src/lib/io/pipe_test.go @@ -26,7 +26,7 @@ func checkWrite(t *testing.T, w io.Write, data []byte, c chan int) { func TestPipe1(t *testing.T) { c := make(chan int); r, w := io.Pipe(); - var buf [64]byte; + var buf = make([]byte, 64); go checkWrite(t, w, io.StringBytes("hello, world"), c); n, err := r.Read(buf); if err != nil { @@ -41,7 +41,7 @@ func TestPipe1(t *testing.T) { } func reader(t *testing.T, r io.Read, c chan int) { - var buf [64]byte; + var buf = make([]byte, 64); for { n, err := r.Read(buf); if err != nil { @@ -59,7 +59,7 @@ func TestPipe2(t *testing.T) { c := make(chan int); r, w := io.Pipe(); go reader(t, r, c); - var buf [64]byte; + var buf = make([]byte, 64); for i := 0; i < 5; i++ { p := buf[0:5+i*10]; n, err := w.Write(p); @@ -91,12 +91,12 @@ func writer(w io.WriteClose, buf []byte, c chan pipeReturn) { func TestPipe3(t *testing.T) { c := make(chan pipeReturn); r, w := io.Pipe(); - var wdat [128]byte; + var wdat = make([]byte, 128); for i := 0; i < len(wdat); i++ { wdat[i] = byte(i); } go writer(w, wdat, c); - var rdat [1024]byte; + var rdat = make([]byte, 1024); tot := 0; for n := 1; n <= 256; n *= 2 { nn, err := r.Read(rdat[tot:tot+n]); @@ -148,7 +148,7 @@ func testPipeReadClose(t *testing.T, async bool) { } else { delayClose(t, w, c); } - var buf [64]byte; + var buf = make([]byte, 64); n, err := r.Read(buf); <-c; if err != nil { diff --git a/src/lib/net/fd.go b/src/lib/net/fd.go index c098c20b20f..8b26efed503 100644 --- a/src/lib/net/fd.go +++ b/src/lib/net/fd.go @@ -265,8 +265,8 @@ func (s *pollServer) Run() { } if fd == s.pr.Fd() { // Drain our wakeup pipe. - for nn, e := s.pr.Read(scratch); nn > 0; { - nn, e = s.pr.Read(scratch) + for nn, e := s.pr.Read(&scratch); nn > 0; { + nn, e = s.pr.Read(&scratch) } // Read from channels @@ -287,9 +287,9 @@ func (s *pollServer) Run() { } } +var wakeupbuf [1]byte; func (s *pollServer) Wakeup() { - var b [1]byte; - s.pw.Write(b) + s.pw.Write(&wakeupbuf) } func (s *pollServer) WaitRead(fd *netFD) { diff --git a/src/lib/net/fd_darwin.go b/src/lib/net/fd_darwin.go index 74f0f486779..c543755b97f 100644 --- a/src/lib/net/fd_darwin.go +++ b/src/lib/net/fd_darwin.go @@ -49,7 +49,7 @@ func (p *pollster) AddFD(fd int64, mode int, repeat bool) *os.Error { ev.Flags |= syscall.EV_ONESHOT } - n, e := syscall.Kevent(p.kq, events, events, nil); + n, e := syscall.Kevent(p.kq, &events, &events, nil); if e != 0 { return os.ErrnoToError(e) } @@ -78,7 +78,7 @@ func (p *pollster) DelFD(fd int64, mode int) { // EV_RECEIPT - generate fake EV_ERROR as result of add, // rather than waiting for real event ev.Flags = syscall.EV_DELETE | syscall.EV_RECEIPT; - syscall.Kevent(p.kq, events, events, nil); + syscall.Kevent(p.kq, &events, &events, nil); } func (p *pollster) WaitFD(nsec int64) (fd int64, mode int, err *os.Error) { @@ -91,7 +91,7 @@ func (p *pollster) WaitFD(nsec int64) (fd int64, mode int, err *os.Error) { t.Sec = nsec / 1e9; t.Nsec = uint64(nsec % 1e9); } - nn, e := syscall.Kevent(p.kq, nil, p.eventbuf, t); + nn, e := syscall.Kevent(p.kq, nil, &p.eventbuf, t); if e != 0 { if e == syscall.EINTR { continue diff --git a/src/lib/net/tcpserver_test.go b/src/lib/net/tcpserver_test.go index 820220b0338..11b13664b1a 100644 --- a/src/lib/net/tcpserver_test.go +++ b/src/lib/net/tcpserver_test.go @@ -15,7 +15,7 @@ func runEcho(fd io.ReadWrite, done chan<- int) { var buf [1024]byte; for { - n, err := fd.Read(buf); + n, err := fd.Read(&buf); if err != nil || n == 0 { break; } @@ -58,7 +58,7 @@ func connect(t *testing.T, network, addr string) { t.Fatalf("fd.Write(%q) = %d, %v", b, n, errno); } - n, errno = fd.Read(b1); + n, errno = fd.Read(&b1); if n != len(b) { t.Fatalf("fd.Read() = %d, %v", n, errno); } diff --git a/src/lib/net/timeout_test.go b/src/lib/net/timeout_test.go index e1ce9178906..d94b049402f 100644 --- a/src/lib/net/timeout_test.go +++ b/src/lib/net/timeout_test.go @@ -20,7 +20,7 @@ func testTimeout(t *testing.T, network, addr string) { t0 := time.Nanoseconds(); fd.SetReadTimeout(1e8); // 100ms var b [100]byte; - n, err1 := fd.Read(b); + n, err1 := fd.Read(&b); t1 := time.Nanoseconds(); if n != 0 || err1 != os.EAGAIN { t.Errorf("fd.Read on %s %s did not return 0, EAGAIN: %v, %v", network, addr, n, err1); diff --git a/src/lib/os/os_test.go b/src/lib/os/os_test.go index 93a2c5e089b..7349b22476d 100644 --- a/src/lib/os/os_test.go +++ b/src/lib/os/os_test.go @@ -38,7 +38,7 @@ func size(name string, t *testing.T) uint64 { var buf [100]byte; len := 0; for { - n, e := file.Read(buf); + n, e := file.Read(&buf); if n < 0 || e != nil { t.Fatal("read failed:", err); } diff --git a/src/lib/sort_test.go b/src/lib/sort_test.go index aa80aa10e36..d6c8f90e968 100644 --- a/src/lib/sort_test.go +++ b/src/lib/sort_test.go @@ -48,8 +48,8 @@ func TestSortStringArray(t *testing.T) { func TestSortInts(t *testing.T) { data := ints; - sort.SortInts(data); - if !sort.IntsAreSorted(data) { + sort.SortInts(&data); + if !sort.IntsAreSorted(&data) { t.Errorf("sorted %v", ints); t.Errorf(" got %v", data); } @@ -57,8 +57,8 @@ func TestSortInts(t *testing.T) { func TestSortFloats(t *testing.T) { data := floats; - sort.SortFloats(data); - if !sort.FloatsAreSorted(data) { + sort.SortFloats(&data); + if !sort.FloatsAreSorted(&data) { t.Errorf("sorted %v", floats); t.Errorf(" got %v", data); } @@ -66,8 +66,8 @@ func TestSortFloats(t *testing.T) { func TestSortStrings(t *testing.T) { data := strings; - sort.SortStrings(data); - if !sort.StringsAreSorted(data) { + sort.SortStrings(&data); + if !sort.StringsAreSorted(&data) { t.Errorf("sorted %v", strings); t.Errorf(" got %v", data); } diff --git a/src/lib/tabwriter/tabwriter.go b/src/lib/tabwriter/tabwriter.go index 26679740bb1..fa0437d0894 100644 --- a/src/lib/tabwriter/tabwriter.go +++ b/src/lib/tabwriter/tabwriter.go @@ -249,7 +249,7 @@ func (b *Writer) writePadding(textw, cellw int) (err *os.Error) { } for n > len(b.padbytes) { - err = b.write0(b.padbytes); + err = b.write0(&b.padbytes); if err != nil { goto exit; } diff --git a/src/lib/utf8.go b/src/lib/utf8.go index 448f4819cc5..ff55df80210 100644 --- a/src/lib/utf8.go +++ b/src/lib/utf8.go @@ -256,17 +256,6 @@ func EncodeRune(rune int, p []byte) int { return 4; } -// EncodeRuneToString returns the UTF-8 encoding of the rune. -func EncodeRuneToString(rune int) string { - if rune < _Rune1Max { - return string([1]byte{byte(rune)}) - } - - var buf [UTFMax]byte; - size := EncodeRune(rune, buf); - return string(buf[0:size]); -} - // RuneCount returns the number of runes in p. Erroneous and short // encodings are treated as single runes of width 1 byte. func RuneCount(p []byte) int { diff --git a/src/lib/utf8_test.go b/src/lib/utf8_test.go index 966b2c97515..1f29cb82d92 100644 --- a/src/lib/utf8_test.go +++ b/src/lib/utf8_test.go @@ -90,7 +90,7 @@ func TestEncodeRune(t *testing.T) { m := utf8map[i]; b := bytes(m.str); var buf [10]byte; - n := utf8.EncodeRune(m.rune, buf); + n := utf8.EncodeRune(m.rune, &buf); b1 := buf[0:n]; if !equalBytes(b, b1) { t.Errorf("EncodeRune(0x%04x) = %q want %q", m.rune, b1, b); @@ -98,17 +98,6 @@ func TestEncodeRune(t *testing.T) { } } -func TestEncodeRuneToString(t *testing.T) { - for i := 0; i < len(utf8map); i++ { - m := utf8map[i]; - s := m.str; - s1 := utf8.EncodeRuneToString(m.rune); - if s != s1 { - t.Errorf("EncodeRuneToString(0x%04x) = %s want %s", m.rune, s1, s); - } - } -} - func TestDecodeRune(t *testing.T) { for i := 0; i < len(utf8map); i++ { m := utf8map[i]; diff --git a/test/fixedbugs/bug045.go b/test/fixedbugs/bug045.go index 88c005d32da..d8a712c6dab 100644 --- a/test/fixedbugs/bug045.go +++ b/test/fixedbugs/bug045.go @@ -13,7 +13,7 @@ type T struct { func main() { var ta []*T; - ta = *new([1]*T); // TODO: the first * shouldn't be necessary + ta = new([1]*T); ta[0] = nil; } /* diff --git a/test/fixedbugs/bug059.go b/test/fixedbugs/bug059.go index 21c078361bb..44f60fedbcb 100644 --- a/test/fixedbugs/bug059.go +++ b/test/fixedbugs/bug059.go @@ -23,7 +23,7 @@ func main() { as := new([2]string); as[0] = "0"; as[1] = "1"; - m["0"] = *as; + m["0"] = as; a := m["0"]; a[0] = "x"; diff --git a/test/ken/array.go b/test/ken/array.go index e1a3aed3a86..809d243a42c 100644 --- a/test/ken/array.go +++ b/test/ken/array.go @@ -96,8 +96,8 @@ func testpdpf1() { a := new([40]int); - setpd(*a); - res(sumpd(*a), 0, 40); + setpd(a); + res(sumpd(a), 0, 40); b := (*a)[5:30]; res(sumpd(b), 5, 30); @@ -109,8 +109,8 @@ testpdpf2() { var a [80]int; - setpd(a); - res(sumpd(a), 0, 80); + setpd(&a); + res(sumpd(&a), 0, 80); } // generate bounds error with ptr dynamic diff --git a/test/ken/rob2.go b/test/ken/rob2.go index 1b4d86e6f2a..29be2efcc18 100644 --- a/test/ken/rob2.go +++ b/test/ken/rob2.go @@ -241,7 +241,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument slist.atom.integer = i; slist.isstring = false; } else { - slist.atom.str = string(tokenbuf)[0:tokenlen]; + slist.atom.str = string(tokenbuf[0:tokenlen]); slist.isstring = true; } slist.isatom = true; diff --git a/usr/gri/pretty/platform.go b/usr/gri/pretty/platform.go index ed680305247..90b9d5ebb96 100644 --- a/usr/gri/pretty/platform.go +++ b/usr/gri/pretty/platform.go @@ -43,7 +43,7 @@ func readfile(filename string) ([]byte, *OS.Error) { return []byte{}, err; } var buf [1<<20]byte; - n, err1 := IO.Readn(f, buf); + n, err1 := IO.Readn(f, &buf); f.Close(); if err1 == IO.ErrEOF { err1 = nil; diff --git a/usr/gri/pretty/utils.go b/usr/gri/pretty/utils.go index 1b925b4833b..baacc75de53 100644 --- a/usr/gri/pretty/utils.go +++ b/usr/gri/pretty/utils.go @@ -87,5 +87,5 @@ func IntToString(x, base int) string { buf[i] = '-'; } - return string(buf)[i : len(buf)]; + return string(buf[i : len(buf)]); }