mirror of
https://github.com/golang/go
synced 2024-11-18 23:05:06 -07:00
cmd: remove bio.BufReader and bio.BufWriter
bio.BufReader was never used. bio.BufWriter was used to wrap an existing io.Writer, but the bio.Writer returned would not be seekable, so replace all occurences with bufio.Reader instead. Change-Id: I9c6779e35c63178aa4e104c17bb5bb8b52de0359 Reviewed-on: https://go-review.googlesource.com/21722 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
6fee4aa5c7
commit
ca397bb68e
@ -5,6 +5,7 @@
|
|||||||
package asm
|
package asm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -17,7 +18,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"cmd/asm/internal/lex"
|
"cmd/asm/internal/lex"
|
||||||
"cmd/internal/bio"
|
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
|
|||||||
pList := obj.Linknewplist(ctxt)
|
pList := obj.Linknewplist(ctxt)
|
||||||
var ok bool
|
var ok bool
|
||||||
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
|
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
|
||||||
ctxt.Bso = bio.BufWriter(os.Stdout)
|
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
||||||
defer ctxt.Bso.Flush()
|
defer ctxt.Bso.Flush()
|
||||||
failed := false
|
failed := false
|
||||||
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
||||||
@ -272,7 +272,7 @@ func testErrors(t *testing.T, goarch, file string) {
|
|||||||
pList := obj.Linknewplist(ctxt)
|
pList := obj.Linknewplist(ctxt)
|
||||||
var ok bool
|
var ok bool
|
||||||
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
|
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
|
||||||
ctxt.Bso = bio.BufWriter(os.Stdout)
|
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
||||||
defer ctxt.Bso.Flush()
|
defer ctxt.Bso.Flush()
|
||||||
failed := false
|
failed := false
|
||||||
var errBuf bytes.Buffer
|
var errBuf bytes.Buffer
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@ -32,11 +33,6 @@ func main() {
|
|||||||
|
|
||||||
flags.Parse()
|
flags.Parse()
|
||||||
|
|
||||||
// Create object file, write header.
|
|
||||||
fd, err := os.Create(*flags.OutputFile)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
ctxt := obj.Linknew(architecture.LinkArch)
|
ctxt := obj.Linknew(architecture.LinkArch)
|
||||||
if *flags.PrintOut {
|
if *flags.PrintOut {
|
||||||
ctxt.Debugasm = 1
|
ctxt.Debugasm = 1
|
||||||
@ -46,9 +42,14 @@ func main() {
|
|||||||
if *flags.Shared || *flags.Dynlink {
|
if *flags.Shared || *flags.Dynlink {
|
||||||
ctxt.Flag_shared = 1
|
ctxt.Flag_shared = 1
|
||||||
}
|
}
|
||||||
ctxt.Bso = bio.BufWriter(os.Stdout)
|
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
||||||
defer ctxt.Bso.Flush()
|
defer ctxt.Bso.Flush()
|
||||||
output := bio.BufWriter(fd)
|
|
||||||
|
// Create object file, write header.
|
||||||
|
output, err := bio.Create(*flags.OutputFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
fmt.Fprintf(output, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
|
fmt.Fprintf(output, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
|
||||||
fmt.Fprintf(output, "!\n")
|
fmt.Fprintf(output, "!\n")
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ importer.
|
|||||||
package gc
|
package gc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/compile/internal/big"
|
"cmd/compile/internal/big"
|
||||||
"cmd/internal/bio"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
@ -124,7 +124,7 @@ const exportVersion = "v0"
|
|||||||
const exportInlined = true // default: true
|
const exportInlined = true // default: true
|
||||||
|
|
||||||
type exporter struct {
|
type exporter struct {
|
||||||
out *bio.Writer
|
out *bufio.Writer
|
||||||
pkgIndex map[*Pkg]int
|
pkgIndex map[*Pkg]int
|
||||||
typIndex map[*Type]int
|
typIndex map[*Type]int
|
||||||
inlined []*Func
|
inlined []*Func
|
||||||
@ -136,7 +136,7 @@ type exporter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export writes the exportlist for localpkg to out and returns the number of bytes written.
|
// export writes the exportlist for localpkg to out and returns the number of bytes written.
|
||||||
func export(out *bio.Writer, trace bool) int {
|
func export(out *bufio.Writer, trace bool) int {
|
||||||
p := exporter{
|
p := exporter{
|
||||||
out: out,
|
out: out,
|
||||||
pkgIndex: make(map[*Pkg]int),
|
pkgIndex: make(map[*Pkg]int),
|
||||||
|
@ -384,7 +384,7 @@ func dumpexport() {
|
|||||||
if debugFormat {
|
if debugFormat {
|
||||||
// save a copy of the export data
|
// save a copy of the export data
|
||||||
var copy bytes.Buffer
|
var copy bytes.Buffer
|
||||||
bcopy := bio.BufWriter(©)
|
bcopy := bufio.NewWriter(©)
|
||||||
size = export(bcopy, Debug_export != 0)
|
size = export(bcopy, Debug_export != 0)
|
||||||
bcopy.Flush() // flushing to bytes.Buffer cannot fail
|
bcopy.Flush() // flushing to bytes.Buffer cannot fail
|
||||||
if n, err := bout.Write(copy.Bytes()); n != size || err != nil {
|
if n, err := bout.Write(copy.Bytes()); n != size || err != nil {
|
||||||
@ -407,7 +407,7 @@ func dumpexport() {
|
|||||||
pkgs = savedPkgs
|
pkgs = savedPkgs
|
||||||
pkgMap = savedPkgMap
|
pkgMap = savedPkgMap
|
||||||
} else {
|
} else {
|
||||||
size = export(bout, Debug_export != 0)
|
size = export(bout.Writer(), Debug_export != 0)
|
||||||
}
|
}
|
||||||
exportf("\n$$\n")
|
exportf("\n$$\n")
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package gc
|
package gc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"cmd/compile/internal/ssa"
|
"cmd/compile/internal/ssa"
|
||||||
"cmd/internal/bio"
|
"cmd/internal/bio"
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
@ -288,7 +289,7 @@ var Ctxt *obj.Link
|
|||||||
|
|
||||||
var writearchive int
|
var writearchive int
|
||||||
|
|
||||||
var bstdout *bio.Writer
|
var bstdout *bufio.Writer
|
||||||
|
|
||||||
var Nacl bool
|
var Nacl bool
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ package gc
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"cmd/compile/internal/ssa"
|
"cmd/compile/internal/ssa"
|
||||||
"cmd/internal/bio"
|
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
"flag"
|
"flag"
|
||||||
@ -104,7 +103,7 @@ func Main() {
|
|||||||
|
|
||||||
Ctxt = obj.Linknew(Thearch.LinkArch)
|
Ctxt = obj.Linknew(Thearch.LinkArch)
|
||||||
Ctxt.DiagFunc = Yyerror
|
Ctxt.DiagFunc = Yyerror
|
||||||
bstdout = bio.BufWriter(os.Stdout)
|
bstdout = bufio.NewWriter(os.Stdout)
|
||||||
Ctxt.Bso = bstdout
|
Ctxt.Bso = bstdout
|
||||||
|
|
||||||
localpkg = mkpkg("")
|
localpkg = mkpkg("")
|
||||||
|
@ -51,18 +51,6 @@ func Open(name string) (*Reader, error) {
|
|||||||
return &Reader{f: f, r: bufio.NewReader(f)}, nil
|
return &Reader{f: f, r: bufio.NewReader(f)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BufWriter returns a Writer on top of w.
|
|
||||||
// TODO(dfc) remove this method and replace caller with bufio.Writer.
|
|
||||||
func BufWriter(w io.Writer) *Writer {
|
|
||||||
return &Writer{w: bufio.NewWriter(w)}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BufWriter returns a Reader on top of r.
|
|
||||||
// TODO(dfc) remove this method and replace caller with bufio.Reader.
|
|
||||||
func BufReader(r io.Reader) *Reader {
|
|
||||||
return &Reader{r: bufio.NewReader(r)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Writer) Write(p []byte) (int, error) {
|
func (w *Writer) Write(p []byte) (int, error) {
|
||||||
return w.w.Write(p)
|
return w.w.Write(p)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
package obj
|
package obj
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/bio"
|
"bufio"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -629,7 +629,7 @@ type Link struct {
|
|||||||
Flag_shared int32
|
Flag_shared int32
|
||||||
Flag_dynlink bool
|
Flag_dynlink bool
|
||||||
Flag_optimize bool
|
Flag_optimize bool
|
||||||
Bso *bio.Writer
|
Bso *bufio.Writer
|
||||||
Pathname string
|
Pathname string
|
||||||
Goroot string
|
Goroot string
|
||||||
Goroot_final string
|
Goroot_final string
|
||||||
|
@ -241,7 +241,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
headstring string
|
headstring string
|
||||||
// buffered output
|
// buffered output
|
||||||
Bso *bio.Writer
|
Bso *bufio.Writer
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(dfc) outBuf duplicates bio.Writer
|
// TODO(dfc) outBuf duplicates bio.Writer
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
package ld
|
package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/bio"
|
"bufio"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -165,10 +165,9 @@ type Link struct {
|
|||||||
Headtype int
|
Headtype int
|
||||||
Arch *sys.Arch
|
Arch *sys.Arch
|
||||||
Debugvlog int32
|
Debugvlog int32
|
||||||
|
Bso *bufio.Writer
|
||||||
Bso *bio.Writer
|
Windows int32
|
||||||
Windows int32
|
Goroot string
|
||||||
Goroot string
|
|
||||||
|
|
||||||
// Symbol lookup based on name and indexed by version.
|
// Symbol lookup based on name and indexed by version.
|
||||||
Hash []map[string]*LSym
|
Hash []map[string]*LSym
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
package ld
|
package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/bio"
|
"bufio"
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
"flag"
|
"flag"
|
||||||
@ -46,7 +46,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Ldmain() {
|
func Ldmain() {
|
||||||
Bso = bio.BufWriter(os.Stdout)
|
Bso = bufio.NewWriter(os.Stdout)
|
||||||
|
|
||||||
Ctxt = linknew(SysArch)
|
Ctxt = linknew(SysArch)
|
||||||
Ctxt.Diag = Diag
|
Ctxt.Diag = Diag
|
||||||
|
Loading…
Reference in New Issue
Block a user