mirror of
https://github.com/golang/go
synced 2024-11-20 04:14:49 -07:00
changes &x -> x[0:] for array to slice conversion
R=gri CC=golang-dev https://golang.org/cl/1326042
This commit is contained in:
parent
7ee6d44e4f
commit
bb84f4b5d2
@ -1035,7 +1035,7 @@ func isTextFile(path string) bool {
|
|||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
var buf [1024]byte
|
var buf [1024]byte
|
||||||
n, err := f.Read(&buf)
|
n, err := f.Read(buf[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func (b *Buffer) grow(n int) int {
|
|||||||
if len(b.buf)+n > cap(b.buf) {
|
if len(b.buf)+n > cap(b.buf) {
|
||||||
var buf []byte
|
var buf []byte
|
||||||
if b.buf == nil && n <= len(b.bootstrap) {
|
if b.buf == nil && n <= len(b.bootstrap) {
|
||||||
buf = &b.bootstrap
|
buf = b.bootstrap[0:]
|
||||||
} else {
|
} else {
|
||||||
// not enough space anywhere
|
// not enough space anywhere
|
||||||
buf = make([]byte, 2*cap(b.buf)+n)
|
buf = make([]byte, 2*cap(b.buf)+n)
|
||||||
@ -181,7 +181,7 @@ func (b *Buffer) WriteRune(r int) (n int, err os.Error) {
|
|||||||
b.WriteByte(byte(r))
|
b.WriteByte(byte(r))
|
||||||
return 1, nil
|
return 1, nil
|
||||||
}
|
}
|
||||||
n = utf8.EncodeRune(r, &b.runeBytes)
|
n = utf8.EncodeRune(r, b.runeBytes[0:])
|
||||||
b.Write(b.runeBytes[0:n])
|
b.Write(b.runeBytes[0:n])
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ var initDecoderTests = []*InitDecoderTest{
|
|||||||
|
|
||||||
// Static Huffman codes (RFC 1951 section 3.2.6)
|
// Static Huffman codes (RFC 1951 section 3.2.6)
|
||||||
&InitDecoderTest{
|
&InitDecoderTest{
|
||||||
&fixedHuffmanBits,
|
fixedHuffmanBits[0:],
|
||||||
fixedHuffmanDecoder,
|
fixedHuffmanDecoder,
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
@ -126,7 +126,7 @@ func (w *huffmanBitWriter) flushBits() {
|
|||||||
w.bytes[n] = byte(bits)
|
w.bytes[n] = byte(bits)
|
||||||
w.bytes[n+1] = byte(bits >> 8)
|
w.bytes[n+1] = byte(bits >> 8)
|
||||||
if n += 2; n >= len(w.bytes) {
|
if n += 2; n >= len(w.bytes) {
|
||||||
_, w.err = w.w.Write(&w.bytes)
|
_, w.err = w.w.Write(w.bytes[0:])
|
||||||
n = 0
|
n = 0
|
||||||
}
|
}
|
||||||
w.nbytes = n
|
w.nbytes = n
|
||||||
|
@ -290,7 +290,7 @@ func (f *decompressor) readHuffman() os.Error {
|
|||||||
for i := nclen; i < len(codeOrder); i++ {
|
for i := nclen; i < len(codeOrder); i++ {
|
||||||
f.codebits[codeOrder[i]] = 0
|
f.codebits[codeOrder[i]] = 0
|
||||||
}
|
}
|
||||||
if !f.h1.init(&f.codebits) {
|
if !f.h1.init(f.codebits[0:]) {
|
||||||
return CorruptInputError(f.roffset)
|
return CorruptInputError(f.roffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func testFileLevel(t *testing.T, fn string, level int) {
|
|||||||
defer zlibw.Close()
|
defer zlibw.Close()
|
||||||
var b [1024]byte
|
var b [1024]byte
|
||||||
for {
|
for {
|
||||||
n, err0 := raw.Read(&b)
|
n, err0 := raw.Read(b[0:])
|
||||||
if err0 != nil && err0 != os.EOF {
|
if err0 != nil && err0 != os.EOF {
|
||||||
t.Errorf("%s (level=%d): %v", fn, level, err0)
|
t.Errorf("%s (level=%d): %v", fn, level, err0)
|
||||||
return
|
return
|
||||||
|
@ -67,7 +67,7 @@ func TestECBEncrypter(t *testing.T) {
|
|||||||
for frag := 0; frag < 2; frag++ {
|
for frag := 0; frag < 2; frag++ {
|
||||||
c := &IncCipher{block, 0, true}
|
c := &IncCipher{block, 0, true}
|
||||||
b.Reset()
|
b.Reset()
|
||||||
r := bytes.NewBuffer(&plain)
|
r := bytes.NewBuffer(plain[0:])
|
||||||
w := NewECBEncrypter(c, b)
|
w := NewECBEncrypter(c, b)
|
||||||
|
|
||||||
// copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ...
|
// copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ...
|
||||||
@ -100,7 +100,7 @@ func TestECBEncrypter(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(data) != string(&crypt) {
|
if string(data) != string(crypt[0:]) {
|
||||||
t.Errorf("block=%d frag=%d: want %x got %x", block, frag, data, crypt)
|
t.Errorf("block=%d frag=%d: want %x got %x", block, frag, data, crypt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func testXorWriter(t *testing.T, maxio int) {
|
|||||||
for frag := 0; frag < 2; frag++ {
|
for frag := 0; frag < 2; frag++ {
|
||||||
test := fmt.Sprintf("block=%d frag=%d maxio=%d", block, frag, maxio)
|
test := fmt.Sprintf("block=%d frag=%d maxio=%d", block, frag, maxio)
|
||||||
b.Reset()
|
b.Reset()
|
||||||
r := bytes.NewBuffer(&plain)
|
r := bytes.NewBuffer(plain[0:])
|
||||||
s := newIncStream(block)
|
s := newIncStream(block)
|
||||||
w := newXorWriter(s, b)
|
w := newXorWriter(s, b)
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
package blowfish
|
package blowfish
|
||||||
|
|
||||||
func expandKey(key []byte, c *Cipher) {
|
func expandKey(key []byte, c *Cipher) {
|
||||||
copy(&c.p, &p)
|
copy(c.p[0:], p[0:])
|
||||||
copy(&c.s0, &s0)
|
copy(c.s0[0:], s0[0:])
|
||||||
copy(&c.s1, &s1)
|
copy(c.s1[0:], s1[0:])
|
||||||
copy(&c.s2, &s2)
|
copy(c.s2[0:], s2[0:])
|
||||||
copy(&c.s3, &s3)
|
copy(c.s3[0:], s3[0:])
|
||||||
|
|
||||||
j := 0
|
j := 0
|
||||||
for i := 0; i < 18; i++ {
|
for i := 0; i < 18; i++ {
|
||||||
|
@ -71,9 +71,9 @@ func (c *Cipher) Decrypt(src, dst []byte) {
|
|||||||
// Reset zeros the key data, so that it will no longer
|
// Reset zeros the key data, so that it will no longer
|
||||||
// appear in the process's memory.
|
// appear in the process's memory.
|
||||||
func (c *Cipher) Reset() {
|
func (c *Cipher) Reset() {
|
||||||
zero(&c.p)
|
zero(c.p[0:])
|
||||||
zero(&c.s0)
|
zero(c.s0[0:])
|
||||||
zero(&c.s1)
|
zero(c.s1[0:])
|
||||||
zero(&c.s2)
|
zero(c.s2[0:])
|
||||||
zero(&c.s3)
|
zero(c.s3[0:])
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
|||||||
}
|
}
|
||||||
d.nx += n
|
d.nx += n
|
||||||
if d.nx == _Chunk {
|
if d.nx == _Chunk {
|
||||||
_Block(d, &d.x)
|
_Block(d, d.x[0:])
|
||||||
d.nx = 0
|
d.nx = 0
|
||||||
}
|
}
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
|
@ -60,7 +60,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
|||||||
}
|
}
|
||||||
d.nx += n
|
d.nx += n
|
||||||
if d.nx == _Chunk {
|
if d.nx == _Chunk {
|
||||||
_Block(d, &d.x)
|
_Block(d, d.x[0:])
|
||||||
d.nx = 0
|
d.nx = 0
|
||||||
}
|
}
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
|
@ -81,15 +81,15 @@ func (r *reader) Read(b []byte) (n int, err os.Error) {
|
|||||||
|
|
||||||
for len(b) > 0 {
|
for len(b) > 0 {
|
||||||
if r.budget == 0 {
|
if r.budget == 0 {
|
||||||
_, err := io.ReadFull(r.entropy, &r.seed)
|
_, err := io.ReadFull(r.entropy, r.seed[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return n - len(b), err
|
return n - len(b), err
|
||||||
}
|
}
|
||||||
_, err = io.ReadFull(r.entropy, &r.key)
|
_, err = io.ReadFull(r.entropy, r.key[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return n - len(b), err
|
return n - len(b), err
|
||||||
}
|
}
|
||||||
r.cipher, err = aes.NewCipher(&r.key)
|
r.cipher, err = aes.NewCipher(r.key[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return n - len(b), err
|
return n - len(b), err
|
||||||
}
|
}
|
||||||
@ -112,17 +112,17 @@ func (r *reader) Read(b []byte) (n int, err os.Error) {
|
|||||||
r.time[5] = byte(ns >> 16)
|
r.time[5] = byte(ns >> 16)
|
||||||
r.time[6] = byte(ns >> 8)
|
r.time[6] = byte(ns >> 8)
|
||||||
r.time[7] = byte(ns)
|
r.time[7] = byte(ns)
|
||||||
r.cipher.Encrypt(&r.time, &r.time)
|
r.cipher.Encrypt(r.time[0:], r.time[0:])
|
||||||
for i := 0; i < aes.BlockSize; i++ {
|
for i := 0; i < aes.BlockSize; i++ {
|
||||||
r.dst[i] = r.time[i] ^ r.seed[i]
|
r.dst[i] = r.time[i] ^ r.seed[i]
|
||||||
}
|
}
|
||||||
r.cipher.Encrypt(&r.dst, &r.dst)
|
r.cipher.Encrypt(r.dst[0:], r.dst[0:])
|
||||||
for i := 0; i < aes.BlockSize; i++ {
|
for i := 0; i < aes.BlockSize; i++ {
|
||||||
r.seed[i] = r.time[i] ^ r.dst[i]
|
r.seed[i] = r.time[i] ^ r.dst[i]
|
||||||
}
|
}
|
||||||
r.cipher.Encrypt(&r.seed, &r.seed)
|
r.cipher.Encrypt(r.seed[0:], r.seed[0:])
|
||||||
|
|
||||||
m := copy(b, &r.dst)
|
m := copy(b, r.dst[0:])
|
||||||
b = b[m:]
|
b = b[m:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
|||||||
}
|
}
|
||||||
d.nx += n
|
d.nx += n
|
||||||
if d.nx == BlockSize {
|
if d.nx == BlockSize {
|
||||||
_Block(d, &d.x)
|
_Block(d, d.x[0:])
|
||||||
d.nx = 0
|
d.nx = 0
|
||||||
}
|
}
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
|
@ -62,7 +62,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
|||||||
}
|
}
|
||||||
d.nx += n
|
d.nx += n
|
||||||
if d.nx == _Chunk {
|
if d.nx == _Chunk {
|
||||||
_Block(d, &d.x)
|
_Block(d, d.x[0:])
|
||||||
d.nx = 0
|
d.nx = 0
|
||||||
}
|
}
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
|
@ -104,7 +104,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
|||||||
}
|
}
|
||||||
d.nx += n
|
d.nx += n
|
||||||
if d.nx == _Chunk {
|
if d.nx == _Chunk {
|
||||||
_Block(d, &d.x)
|
_Block(d, d.x[0:])
|
||||||
d.nx = 0
|
d.nx = 0
|
||||||
}
|
}
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
|
@ -104,7 +104,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
|
|||||||
}
|
}
|
||||||
d.nx += n
|
d.nx += n
|
||||||
if d.nx == _Chunk {
|
if d.nx == _Chunk {
|
||||||
_Block(d, &d.x)
|
_Block(d, d.x[0:])
|
||||||
d.nx = 0
|
d.nx = 0
|
||||||
}
|
}
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
|
@ -171,7 +171,7 @@ func (hc *halfConn) decrypt(b *block) (bool, alert) {
|
|||||||
remoteMAC := payload[n:]
|
remoteMAC := payload[n:]
|
||||||
|
|
||||||
hc.mac.Reset()
|
hc.mac.Reset()
|
||||||
hc.mac.Write(&hc.seq)
|
hc.mac.Write(hc.seq[0:])
|
||||||
hc.incSeq()
|
hc.incSeq()
|
||||||
hc.mac.Write(b.data)
|
hc.mac.Write(b.data)
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ func (hc *halfConn) encrypt(b *block) (bool, alert) {
|
|||||||
// mac
|
// mac
|
||||||
if hc.mac != nil {
|
if hc.mac != nil {
|
||||||
hc.mac.Reset()
|
hc.mac.Reset()
|
||||||
hc.mac.Write(&hc.seq)
|
hc.mac.Write(hc.seq[0:])
|
||||||
hc.incSeq()
|
hc.incSeq()
|
||||||
hc.mac.Write(b.data)
|
hc.mac.Write(b.data)
|
||||||
mac := hc.mac.Sum()
|
mac := hc.mac.Sum()
|
||||||
|
@ -166,7 +166,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
|
|||||||
sr := io.NewSectionReader(r, 0, 1<<63-1)
|
sr := io.NewSectionReader(r, 0, 1<<63-1)
|
||||||
// Read and decode ELF identifier
|
// Read and decode ELF identifier
|
||||||
var ident [16]uint8
|
var ident [16]uint8
|
||||||
if _, err := r.ReadAt(&ident, 0); err != nil {
|
if _, err := r.ReadAt(ident[0:], 0); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if ident[0] != '\x7f' || ident[1] != 'E' || ident[2] != 'L' || ident[3] != 'F' {
|
if ident[0] != '\x7f' || ident[1] != 'E' || ident[2] != 'L' || ident[3] != 'F' {
|
||||||
|
@ -117,7 +117,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
if e.nbuf < 4 {
|
if e.nbuf < 4 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nout := Encode(&e.out, &e.buf)
|
nout := Encode(e.out[0:], e.buf[0:])
|
||||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||||
return n, e.err
|
return n, e.err
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
}
|
}
|
||||||
nn -= nn % 4
|
nn -= nn % 4
|
||||||
if nn > 0 {
|
if nn > 0 {
|
||||||
nout := Encode(&e.out, p[0:nn])
|
nout := Encode(e.out[0:], p[0:nn])
|
||||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||||
return n, e.err
|
return n, e.err
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
func (e *encoder) Close() os.Error {
|
func (e *encoder) Close() os.Error {
|
||||||
// If there's anything left in the buffer, flush it out
|
// If there's anything left in the buffer, flush it out
|
||||||
if e.err == nil && e.nbuf > 0 {
|
if e.err == nil && e.nbuf > 0 {
|
||||||
nout := Encode(&e.out, e.buf[0:e.nbuf])
|
nout := Encode(e.out[0:], e.buf[0:e.nbuf])
|
||||||
e.nbuf = 0
|
e.nbuf = 0
|
||||||
_, e.err = e.w.Write(e.out[0:nout])
|
_, e.err = e.w.Write(e.out[0:nout])
|
||||||
}
|
}
|
||||||
@ -275,10 +275,10 @@ func (d *decoder) Read(p []byte) (n int, err os.Error) {
|
|||||||
// Decode leftover input from last read.
|
// Decode leftover input from last read.
|
||||||
var nn, nsrc, ndst int
|
var nn, nsrc, ndst int
|
||||||
if d.nbuf > 0 {
|
if d.nbuf > 0 {
|
||||||
ndst, nsrc, d.err = Decode(&d.outbuf, d.buf[0:d.nbuf], d.readErr != nil)
|
ndst, nsrc, d.err = Decode(d.outbuf[0:], d.buf[0:d.nbuf], d.readErr != nil)
|
||||||
if ndst > 0 {
|
if ndst > 0 {
|
||||||
d.out = d.outbuf[0:ndst]
|
d.out = d.outbuf[0:ndst]
|
||||||
d.nbuf = copy(&d.buf, d.buf[nsrc:d.nbuf])
|
d.nbuf = copy(d.buf[0:], d.buf[nsrc:d.nbuf])
|
||||||
continue // copy out and return
|
continue // copy out and return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
if e.nbuf < 3 {
|
if e.nbuf < 3 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.enc.Encode(&e.out, &e.buf)
|
e.enc.Encode(e.out[0:], e.buf[0:])
|
||||||
if _, e.err = e.w.Write(e.out[0:4]); e.err != nil {
|
if _, e.err = e.w.Write(e.out[0:4]); e.err != nil {
|
||||||
return n, e.err
|
return n, e.err
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
}
|
}
|
||||||
nn -= nn % 3
|
nn -= nn % 3
|
||||||
if nn > 0 {
|
if nn > 0 {
|
||||||
e.enc.Encode(&e.out, p[0:nn])
|
e.enc.Encode(e.out[0:], p[0:nn])
|
||||||
if _, e.err = e.w.Write(e.out[0 : nn/3*4]); e.err != nil {
|
if _, e.err = e.w.Write(e.out[0 : nn/3*4]); e.err != nil {
|
||||||
return n, e.err
|
return n, e.err
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
func (e *encoder) Close() os.Error {
|
func (e *encoder) Close() os.Error {
|
||||||
// If there's anything left in the buffer, flush it out
|
// If there's anything left in the buffer, flush it out
|
||||||
if e.err == nil && e.nbuf > 0 {
|
if e.err == nil && e.nbuf > 0 {
|
||||||
e.enc.Encode(&e.out, e.buf[0:e.nbuf])
|
e.enc.Encode(e.out[0:], e.buf[0:e.nbuf])
|
||||||
e.nbuf = 0
|
e.nbuf = 0
|
||||||
_, e.err = e.w.Write(e.out[0:4])
|
_, e.err = e.w.Write(e.out[0:4])
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ func (d *decoder) Read(p []byte) (n int, err os.Error) {
|
|||||||
nr := d.nbuf / 4 * 4
|
nr := d.nbuf / 4 * 4
|
||||||
nw := d.nbuf / 4 * 3
|
nw := d.nbuf / 4 * 3
|
||||||
if nw > len(p) {
|
if nw > len(p) {
|
||||||
nw, d.end, d.err = d.enc.decode(&d.outbuf, d.buf[0:nr])
|
nw, d.end, d.err = d.enc.decode(d.outbuf[0:], d.buf[0:nr])
|
||||||
d.out = d.outbuf[0:nw]
|
d.out = d.outbuf[0:nw]
|
||||||
n = copy(p, d.out)
|
n = copy(p, d.out)
|
||||||
d.out = d.out[n:]
|
d.out = d.out[n:]
|
||||||
|
@ -177,7 +177,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
if e.nbuf < 52 {
|
if e.nbuf < 52 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nout := Encode(&e.out, &e.buf)
|
nout := Encode(e.out[0:], e.buf[0:])
|
||||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||||
return n, e.err
|
return n, e.err
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
nn = len(p) / 52 * 52
|
nn = len(p) / 52 * 52
|
||||||
}
|
}
|
||||||
if nn > 0 {
|
if nn > 0 {
|
||||||
nout := Encode(&e.out, p[0:nn])
|
nout := Encode(e.out[0:], p[0:nn])
|
||||||
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
if _, e.err = e.w.Write(e.out[0:nout]); e.err != nil {
|
||||||
return n, e.err
|
return n, e.err
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
|
|||||||
func (e *encoder) Close() os.Error {
|
func (e *encoder) Close() os.Error {
|
||||||
// If there's anything left in the buffer, flush it out
|
// If there's anything left in the buffer, flush it out
|
||||||
if e.err == nil && e.nbuf > 0 {
|
if e.err == nil && e.nbuf > 0 {
|
||||||
nout := Encode(&e.out, e.buf[0:e.nbuf])
|
nout := Encode(e.out[0:], e.buf[0:e.nbuf])
|
||||||
e.nbuf = 0
|
e.nbuf = 0
|
||||||
_, e.err = e.w.Write(e.out[0:nout])
|
_, e.err = e.w.Write(e.out[0:nout])
|
||||||
}
|
}
|
||||||
@ -265,12 +265,12 @@ func (d *decoder) Read(p []byte) (n int, err os.Error) {
|
|||||||
if nl < 0 {
|
if nl < 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nn, d.err = Decode(&d.outbuf, d.buf[0:nl+1])
|
nn, d.err = Decode(d.outbuf[0:], d.buf[0:nl+1])
|
||||||
if e, ok := d.err.(CorruptInputError); ok {
|
if e, ok := d.err.(CorruptInputError); ok {
|
||||||
d.err = CorruptInputError(int64(e) + d.off)
|
d.err = CorruptInputError(int64(e) + d.off)
|
||||||
}
|
}
|
||||||
d.out = d.outbuf[0:nn]
|
d.out = d.outbuf[0:nn]
|
||||||
d.nbuf = copy(&d.buf, d.buf[nl+1:d.nbuf])
|
d.nbuf = copy(d.buf[0:], d.buf[nl+1:d.nbuf])
|
||||||
d.off += int64(nl + 1)
|
d.off += int64(nl + 1)
|
||||||
}
|
}
|
||||||
panic("unreacahable")
|
panic("unreacahable")
|
||||||
|
@ -95,7 +95,7 @@ func Run(argv0 string, argv, envv []string, dir string, stdin, stdout, stderr in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run command.
|
// Run command.
|
||||||
p.Pid, err = os.ForkExec(argv0, argv, envv, dir, &fd)
|
p.Pid, err = os.ForkExec(argv0, argv, envv, dir, fd[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
goto Error
|
goto Error
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ func (f *fmt) fmt_boolean(v bool) {
|
|||||||
// integer; interprets prec but not wid. Once formatted, result is sent to pad()
|
// integer; interprets prec but not wid. Once formatted, result is sent to pad()
|
||||||
// and then flags are cleared.
|
// and then flags are cleared.
|
||||||
func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) {
|
func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) {
|
||||||
var buf []byte = &f.intbuf
|
var buf []byte = f.intbuf[0:]
|
||||||
negative := signedness == signed && a < 0
|
negative := signedness == signed && a < 0
|
||||||
if negative {
|
if negative {
|
||||||
a = -a
|
a = -a
|
||||||
|
@ -201,7 +201,7 @@ func (p *pp) add(c int) {
|
|||||||
if c < utf8.RuneSelf {
|
if c < utf8.RuneSelf {
|
||||||
p.buf.WriteByte(byte(c))
|
p.buf.WriteByte(byte(c))
|
||||||
} else {
|
} else {
|
||||||
w := utf8.EncodeRune(c, &p.runeBuf)
|
w := utf8.EncodeRune(c, p.runeBuf[0:])
|
||||||
p.buf.Write(p.runeBuf[0:w])
|
p.buf.Write(p.runeBuf[0:w])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func (r readRune) ReadRune() (rune int, size int, err os.Error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !utf8.FullRune(&r.buf) {
|
if !utf8.FullRune(r.buf[0:]) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if c, w := utf8.DecodeRune(r.buf[0:size]); w == size {
|
if c, w := utf8.DecodeRune(r.buf[0:size]); w == size {
|
||||||
|
@ -709,7 +709,7 @@ func (p *printer) writeWhitespace(n int) {
|
|||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
data[0] = byte(ch)
|
data[0] = byte(ch)
|
||||||
p.write(&data)
|
p.write(data[0:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) {
|
|||||||
} else {
|
} else {
|
||||||
// read first chunk to decide between utf-8 text and binary
|
// read first chunk to decide between utf-8 text and binary
|
||||||
var buf [1024]byte
|
var buf [1024]byte
|
||||||
n, _ := io.ReadFull(f, &buf)
|
n, _ := io.ReadFull(f, buf[0:])
|
||||||
b := buf[0:n]
|
b := buf[0:n]
|
||||||
if isText(b) {
|
if isText(b) {
|
||||||
c.SetHeader("Content-Type", "text-plain; charset=utf-8")
|
c.SetHeader("Content-Type", "text-plain; charset=utf-8")
|
||||||
|
@ -248,8 +248,8 @@ func (s *pollServer) Run() {
|
|||||||
}
|
}
|
||||||
if fd == s.pr.Fd() {
|
if fd == s.pr.Fd() {
|
||||||
// Drain our wakeup pipe.
|
// Drain our wakeup pipe.
|
||||||
for nn, _ := s.pr.Read(&scratch); nn > 0; {
|
for nn, _ := s.pr.Read(scratch[0:]); nn > 0; {
|
||||||
nn, _ = s.pr.Read(&scratch)
|
nn, _ = s.pr.Read(scratch[0:])
|
||||||
}
|
}
|
||||||
// Read from channels
|
// Read from channels
|
||||||
for fd, ok := <-s.cr; ok; fd, ok = <-s.cr {
|
for fd, ok := <-s.cr; ok; fd, ok = <-s.cr {
|
||||||
@ -271,7 +271,7 @@ func (s *pollServer) Run() {
|
|||||||
|
|
||||||
var wakeupbuf [1]byte
|
var wakeupbuf [1]byte
|
||||||
|
|
||||||
func (s *pollServer) Wakeup() { s.pw.Write(&wakeupbuf) }
|
func (s *pollServer) Wakeup() { s.pw.Write(wakeupbuf[0:]) }
|
||||||
|
|
||||||
func (s *pollServer) WaitRead(fd *netFD) {
|
func (s *pollServer) WaitRead(fd *netFD) {
|
||||||
s.cr <- fd
|
s.cr <- fd
|
||||||
|
@ -46,7 +46,7 @@ func (p *pollster) AddFD(fd int, mode int, repeat bool) os.Error {
|
|||||||
}
|
}
|
||||||
syscall.SetKevent(ev, fd, kmode, flags)
|
syscall.SetKevent(ev, fd, kmode, flags)
|
||||||
|
|
||||||
n, e := syscall.Kevent(p.kq, &events, &events, nil)
|
n, e := syscall.Kevent(p.kq, events[0:], events[0:], nil)
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
return os.NewSyscallError("kevent", e)
|
return os.NewSyscallError("kevent", e)
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ func (p *pollster) DelFD(fd int, mode int) {
|
|||||||
// EV_RECEIPT - generate fake EV_ERROR as result of add,
|
// EV_RECEIPT - generate fake EV_ERROR as result of add,
|
||||||
// rather than waiting for real event
|
// rather than waiting for real event
|
||||||
syscall.SetKevent(ev, fd, kmode, syscall.EV_DELETE|syscall.EV_RECEIPT)
|
syscall.SetKevent(ev, fd, kmode, syscall.EV_DELETE|syscall.EV_RECEIPT)
|
||||||
syscall.Kevent(p.kq, &events, &events, nil)
|
syscall.Kevent(p.kq, events[0:], events[0:], nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
||||||
@ -84,7 +84,7 @@ func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
|||||||
}
|
}
|
||||||
*t = syscall.NsecToTimespec(nsec)
|
*t = syscall.NsecToTimespec(nsec)
|
||||||
}
|
}
|
||||||
nn, e := syscall.Kevent(p.kq, nil, &p.eventbuf, t)
|
nn, e := syscall.Kevent(p.kq, nil, p.eventbuf[0:], t)
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
if e == syscall.EINTR {
|
if e == syscall.EINTR {
|
||||||
continue
|
continue
|
||||||
|
@ -113,9 +113,9 @@ func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
|
|||||||
if nsec > 0 {
|
if nsec > 0 {
|
||||||
msec = int((nsec + 1e6 - 1) / 1e6)
|
msec = int((nsec + 1e6 - 1) / 1e6)
|
||||||
}
|
}
|
||||||
n, e := syscall.EpollWait(p.epfd, &evarray, msec)
|
n, e := syscall.EpollWait(p.epfd, evarray[0:], msec)
|
||||||
for e == syscall.EAGAIN || e == syscall.EINTR {
|
for e == syscall.EAGAIN || e == syscall.EINTR {
|
||||||
n, e = syscall.EpollWait(p.epfd, &evarray, msec)
|
n, e = syscall.EpollWait(p.epfd, evarray[0:], msec)
|
||||||
}
|
}
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
return -1, 0, os.NewSyscallError("epoll_wait", e)
|
return -1, 0, os.NewSyscallError("epoll_wait", e)
|
||||||
|
@ -103,9 +103,9 @@ func getip(fd int, remote bool) (ip []byte, port int, ok bool) {
|
|||||||
}
|
}
|
||||||
switch sa := sa.(type) {
|
switch sa := sa.(type) {
|
||||||
case *syscall.SockaddrInet4:
|
case *syscall.SockaddrInet4:
|
||||||
return &sa.Addr, sa.Port, true
|
return sa.Addr[0:], sa.Port, true
|
||||||
case *syscall.SockaddrInet6:
|
case *syscall.SockaddrInet6:
|
||||||
return &sa.Addr, sa.Port, true
|
return sa.Addr[0:], sa.Port, true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func runEcho(fd io.ReadWriter, done chan<- int) {
|
|||||||
var buf [1024]byte
|
var buf [1024]byte
|
||||||
|
|
||||||
for {
|
for {
|
||||||
n, err := fd.Read(&buf)
|
n, err := fd.Read(buf[0:])
|
||||||
if err != nil || n == 0 {
|
if err != nil || n == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func connect(t *testing.T, network, addr string, isEmpty bool) {
|
|||||||
t.Fatalf("fd.Write(%q) = %d, %v", b, n, err1)
|
t.Fatalf("fd.Write(%q) = %d, %v", b, n, err1)
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err1 = fd.Read(&b1)
|
n, err1 = fd.Read(b1[0:])
|
||||||
if n != len(b) || err1 != nil {
|
if n != len(b) || err1 != nil {
|
||||||
t.Fatalf("fd.Read() = %d, %v (want %d, nil)", n, err1, len(b))
|
t.Fatalf("fd.Read() = %d, %v (want %d, nil)", n, err1, len(b))
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ func runPacket(t *testing.T, network, addr string, listening chan<- string, done
|
|||||||
c.SetReadTimeout(10e6) // 10ms
|
c.SetReadTimeout(10e6) // 10ms
|
||||||
var buf [1000]byte
|
var buf [1000]byte
|
||||||
for {
|
for {
|
||||||
n, addr, err := c.ReadFrom(&buf)
|
n, addr, err := c.ReadFrom(buf[0:])
|
||||||
if e, ok := err.(Error); ok && e.Timeout() {
|
if e, ok := err.(Error); ok && e.Timeout() {
|
||||||
if done <- 1 {
|
if done <- 1 {
|
||||||
break
|
break
|
||||||
|
@ -155,9 +155,9 @@ func (e *UnknownSocketError) String() string {
|
|||||||
func sockaddrToString(sa syscall.Sockaddr) (name string, err os.Error) {
|
func sockaddrToString(sa syscall.Sockaddr) (name string, err os.Error) {
|
||||||
switch a := sa.(type) {
|
switch a := sa.(type) {
|
||||||
case *syscall.SockaddrInet4:
|
case *syscall.SockaddrInet4:
|
||||||
return joinHostPort(IP(&a.Addr).String(), itoa(a.Port)), nil
|
return joinHostPort(IP(a.Addr[0:]).String(), itoa(a.Port)), nil
|
||||||
case *syscall.SockaddrInet6:
|
case *syscall.SockaddrInet6:
|
||||||
return joinHostPort(IP(&a.Addr).String(), itoa(a.Port)), nil
|
return joinHostPort(IP(a.Addr[0:]).String(), itoa(a.Port)), nil
|
||||||
case *syscall.SockaddrUnix:
|
case *syscall.SockaddrUnix:
|
||||||
return a.Name, nil
|
return a.Name, nil
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ func testTimeout(t *testing.T, network, addr string, readFrom bool) {
|
|||||||
var n int
|
var n int
|
||||||
var err1 os.Error
|
var err1 os.Error
|
||||||
if readFrom {
|
if readFrom {
|
||||||
n, _, err1 = fd.(PacketConn).ReadFrom(&b)
|
n, _, err1 = fd.(PacketConn).ReadFrom(b[0:])
|
||||||
} else {
|
} else {
|
||||||
n, err1 = fd.Read(&b)
|
n, err1 = fd.Read(b[0:])
|
||||||
}
|
}
|
||||||
t1 := time.Nanoseconds()
|
t1 := time.Nanoseconds()
|
||||||
what := "Read"
|
what := "Read"
|
||||||
|
@ -57,7 +57,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]))
|
bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]))
|
||||||
var name = string(bytes[0:clen(bytes)])
|
var name = string(bytes[0:clen(bytes[0:])])
|
||||||
if name == "." || name == ".." { // Useless names
|
if name == "." || name == ".." { // Useless names
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ func Pipe() (r *File, w *File, err Error) {
|
|||||||
|
|
||||||
// See ../syscall/exec.go for description of lock.
|
// See ../syscall/exec.go for description of lock.
|
||||||
syscall.ForkLock.RLock()
|
syscall.ForkLock.RLock()
|
||||||
e := syscall.Pipe(&p)
|
e := syscall.Pipe(p[0:])
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
syscall.ForkLock.RUnlock()
|
syscall.ForkLock.RUnlock()
|
||||||
return nil, nil, NewSyscallError("pipe", e)
|
return nil, nil, NewSyscallError("pipe", e)
|
||||||
@ -418,7 +418,7 @@ func Chtimes(name string, atime_ns int64, mtime_ns int64) Error {
|
|||||||
var utimes [2]syscall.Timeval
|
var utimes [2]syscall.Timeval
|
||||||
utimes[0] = syscall.NsecToTimeval(atime_ns)
|
utimes[0] = syscall.NsecToTimeval(atime_ns)
|
||||||
utimes[1] = syscall.NsecToTimeval(mtime_ns)
|
utimes[1] = syscall.NsecToTimeval(mtime_ns)
|
||||||
if e := syscall.Utimes(name, &utimes); e != 0 {
|
if e := syscall.Utimes(name, utimes[0:]); e != 0 {
|
||||||
return &PathError{"chtimes", name, Errno(e)}
|
return &PathError{"chtimes", name, Errno(e)}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -42,7 +42,7 @@ func size(name string, t *testing.T) int64 {
|
|||||||
var buf [100]byte
|
var buf [100]byte
|
||||||
len := 0
|
len := 0
|
||||||
for {
|
for {
|
||||||
n, e := file.Read(&buf)
|
n, e := file.Read(buf[0:])
|
||||||
len += n
|
len += n
|
||||||
if e == EOF {
|
if e == EOF {
|
||||||
break
|
break
|
||||||
|
@ -16,7 +16,7 @@ func Hostname() (name string, err Error) {
|
|||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
var buf [512]byte // Enough for a DNS name.
|
var buf [512]byte // Enough for a DNS name.
|
||||||
n, err := f.Read(&buf)
|
n, err := f.Read(buf[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func ParseGitBinary(raw []byte) (Diff, os.Error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var buf [1]byte
|
var buf [1]byte
|
||||||
m, err := z.Read(&buf)
|
m, err := z.Read(buf[0:])
|
||||||
if m != 0 || err != os.EOF {
|
if m != 0 || err != os.EOF {
|
||||||
return nil, os.NewError("Git binary literal longer than expected")
|
return nil, os.NewError("Git binary literal longer than expected")
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ var strings = [...]string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "
|
|||||||
|
|
||||||
func TestSortIntArray(t *testing.T) {
|
func TestSortIntArray(t *testing.T) {
|
||||||
data := ints
|
data := ints
|
||||||
a := IntArray(&data)
|
a := IntArray(data[0:])
|
||||||
Sort(a)
|
Sort(a)
|
||||||
if !IsSorted(a) {
|
if !IsSorted(a) {
|
||||||
t.Errorf("sorted %v", ints)
|
t.Errorf("sorted %v", ints)
|
||||||
@ -28,7 +28,7 @@ func TestSortIntArray(t *testing.T) {
|
|||||||
|
|
||||||
func TestSortFloatArray(t *testing.T) {
|
func TestSortFloatArray(t *testing.T) {
|
||||||
data := floats
|
data := floats
|
||||||
a := FloatArray(&data)
|
a := FloatArray(data[0:])
|
||||||
Sort(a)
|
Sort(a)
|
||||||
if !IsSorted(a) {
|
if !IsSorted(a) {
|
||||||
t.Errorf("sorted %v", floats)
|
t.Errorf("sorted %v", floats)
|
||||||
@ -38,7 +38,7 @@ func TestSortFloatArray(t *testing.T) {
|
|||||||
|
|
||||||
func TestSortStringArray(t *testing.T) {
|
func TestSortStringArray(t *testing.T) {
|
||||||
data := strings
|
data := strings
|
||||||
a := StringArray(&data)
|
a := StringArray(data[0:])
|
||||||
Sort(a)
|
Sort(a)
|
||||||
if !IsSorted(a) {
|
if !IsSorted(a) {
|
||||||
t.Errorf("sorted %v", strings)
|
t.Errorf("sorted %v", strings)
|
||||||
@ -48,8 +48,8 @@ func TestSortStringArray(t *testing.T) {
|
|||||||
|
|
||||||
func TestSortInts(t *testing.T) {
|
func TestSortInts(t *testing.T) {
|
||||||
data := ints
|
data := ints
|
||||||
SortInts(&data)
|
SortInts(data[0:])
|
||||||
if !IntsAreSorted(&data) {
|
if !IntsAreSorted(data[0:]) {
|
||||||
t.Errorf("sorted %v", ints)
|
t.Errorf("sorted %v", ints)
|
||||||
t.Errorf(" got %v", data)
|
t.Errorf(" got %v", data)
|
||||||
}
|
}
|
||||||
@ -57,8 +57,8 @@ func TestSortInts(t *testing.T) {
|
|||||||
|
|
||||||
func TestSortFloats(t *testing.T) {
|
func TestSortFloats(t *testing.T) {
|
||||||
data := floats
|
data := floats
|
||||||
SortFloats(&data)
|
SortFloats(data[0:])
|
||||||
if !FloatsAreSorted(&data) {
|
if !FloatsAreSorted(data[0:]) {
|
||||||
t.Errorf("sorted %v", floats)
|
t.Errorf("sorted %v", floats)
|
||||||
t.Errorf(" got %v", data)
|
t.Errorf(" got %v", data)
|
||||||
}
|
}
|
||||||
@ -66,8 +66,8 @@ func TestSortFloats(t *testing.T) {
|
|||||||
|
|
||||||
func TestSortStrings(t *testing.T) {
|
func TestSortStrings(t *testing.T) {
|
||||||
data := strings
|
data := strings
|
||||||
SortStrings(&data)
|
SortStrings(data[0:])
|
||||||
if !StringsAreSorted(&data) {
|
if !StringsAreSorted(data[0:]) {
|
||||||
t.Errorf("sorted %v", strings)
|
t.Errorf("sorted %v", strings)
|
||||||
t.Errorf(" got %v", data)
|
t.Errorf(" got %v", data)
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri
|
|||||||
ForkLock.Lock()
|
ForkLock.Lock()
|
||||||
|
|
||||||
// Allocate child status pipe close on exec.
|
// Allocate child status pipe close on exec.
|
||||||
if err = Pipe(&p); err != 0 {
|
if err = Pipe(p[0:]); err != 0 {
|
||||||
goto error
|
goto error
|
||||||
}
|
}
|
||||||
if _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != 0 {
|
if _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != 0 {
|
||||||
|
@ -68,7 +68,7 @@ const ImplementsGetwd = true
|
|||||||
//sys Getcwd(buf []byte) (n int, errno int)
|
//sys Getcwd(buf []byte) (n int, errno int)
|
||||||
func Getwd() (wd string, errno int) {
|
func Getwd() (wd string, errno int) {
|
||||||
var buf [PathMax]byte
|
var buf [PathMax]byte
|
||||||
n, err := Getcwd(&buf)
|
n, err := Getcwd(buf[0:])
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -442,7 +442,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in
|
|||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return n, errno
|
return n, errno
|
||||||
}
|
}
|
||||||
copied := copy(out, &buf)
|
copied := copy(out, buf[0:])
|
||||||
n += copied
|
n += copied
|
||||||
out = out[copied:]
|
out = out[copied:]
|
||||||
}
|
}
|
||||||
@ -497,7 +497,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c
|
|||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
return n, errno
|
return n, errno
|
||||||
}
|
}
|
||||||
copy(&buf, data)
|
copy(buf[0:], data)
|
||||||
word := *((*uintptr)(unsafe.Pointer(&buf[0])))
|
word := *((*uintptr)(unsafe.Pointer(&buf[0])))
|
||||||
errno = ptrace(pokeReq, pid, addr+uintptr(n), word)
|
errno = ptrace(pokeReq, pid, addr+uintptr(n), word)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
|
@ -16,7 +16,7 @@ func runSyslog(c net.PacketConn, done chan<- string) {
|
|||||||
var buf [4096]byte
|
var buf [4096]byte
|
||||||
var rcvd string = ""
|
var rcvd string = ""
|
||||||
for {
|
for {
|
||||||
n, _, err := c.ReadFrom(&buf)
|
n, _, err := c.ReadFrom(buf[0:])
|
||||||
if err != nil || n == 0 {
|
if err != nil || n == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ func (b *Writer) writePadding(textw, cellw int, useTabs bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// padding is done with non-tab characters
|
// padding is done with non-tab characters
|
||||||
b.writeN(&b.padbytes, cellw-textw)
|
b.writeN(b.padbytes[0:], cellw-textw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ func TestEncodeRune(t *testing.T) {
|
|||||||
m := utf8map[i]
|
m := utf8map[i]
|
||||||
b := makeBytes(m.str)
|
b := makeBytes(m.str)
|
||||||
var buf [10]byte
|
var buf [10]byte
|
||||||
n := EncodeRune(m.rune, &buf)
|
n := EncodeRune(m.rune, buf[0:])
|
||||||
b1 := buf[0:n]
|
b1 := buf[0:n]
|
||||||
if !bytes.Equal(b, b1) {
|
if !bytes.Equal(b, b1) {
|
||||||
t.Errorf("EncodeRune(%#04x) = %q want %q", m.rune, b1, b)
|
t.Errorf("EncodeRune(%#04x) = %q want %q", m.rune, b1, b)
|
||||||
|
Loading…
Reference in New Issue
Block a user