Skip to content

Commit

Permalink
libgo: Update to weekly.2011-11-18.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182266 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ian committed Dec 12, 2011
1 parent dc15d51 commit 46bc1fe
Show file tree
Hide file tree
Showing 223 changed files with 6,346 additions and 3,972 deletions.
2 changes: 1 addition & 1 deletion libgo/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2f4482b89a6b
b4a91b693374

The first line of this file holds the Mercurial revision number of the
last merge done from the master library sources.
11 changes: 7 additions & 4 deletions libgo/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ go_math_files = \
go_mime_files = \
go/mime/grammar.go \
go/mime/mediatype.go \
go/mime/type.go
go/mime/type.go \
go/mime/type_unix.go

if LIBGO_IS_RTEMS
go_net_fd_os_file = go/net/fd_select.go
Expand Down Expand Up @@ -770,7 +771,6 @@ go_os_files = \
$(go_os_dir_file) \
go/os/dir.go \
go/os/env.go \
go/os/env_unix.go \
go/os/error.go \
go/os/error_posix.go \
go/os/exec.go \
Expand Down Expand Up @@ -1156,6 +1156,7 @@ go_exp_sql_files = \
go/exp/sql/sql.go
go_exp_ssh_files = \
go/exp/ssh/channel.go \
go/exp/ssh/cipher.go \
go/exp/ssh/client.go \
go/exp/ssh/client_auth.go \
go/exp/ssh/common.go \
Expand All @@ -1164,10 +1165,11 @@ go_exp_ssh_files = \
go/exp/ssh/server.go \
go/exp/ssh/server_shell.go \
go/exp/ssh/session.go \
go/exp/ssh/tcpip.go \
go/exp/ssh/transport.go
go_exp_terminal_files = \
go/exp/terminal/shell.go \
go/exp/terminal/terminal.go
go/exp/terminal/terminal.go \
go/exp/terminal/util.go
go_exp_types_files = \
go/exp/types/check.go \
go/exp/types/const.go \
Expand Down Expand Up @@ -1546,6 +1548,7 @@ syscall_netlink_file =
endif

go_base_syscall_files = \
go/syscall/env_unix.go \
go/syscall/libcall_support.go \
go/syscall/libcall_posix.go \
go/syscall/socket.go \
Expand Down
11 changes: 7 additions & 4 deletions libgo/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,8 @@ go_math_files = \
go_mime_files = \
go/mime/grammar.go \
go/mime/mediatype.go \
go/mime/type.go
go/mime/type.go \
go/mime/type_unix.go

# By default use select with pipes. Most systems should have
# something better.
Expand Down Expand Up @@ -1103,7 +1104,6 @@ go_os_files = \
$(go_os_dir_file) \
go/os/dir.go \
go/os/env.go \
go/os/env_unix.go \
go/os/error.go \
go/os/error_posix.go \
go/os/exec.go \
Expand Down Expand Up @@ -1521,6 +1521,7 @@ go_exp_sql_files = \

go_exp_ssh_files = \
go/exp/ssh/channel.go \
go/exp/ssh/cipher.go \
go/exp/ssh/client.go \
go/exp/ssh/client_auth.go \
go/exp/ssh/common.go \
Expand All @@ -1529,11 +1530,12 @@ go_exp_ssh_files = \
go/exp/ssh/server.go \
go/exp/ssh/server_shell.go \
go/exp/ssh/session.go \
go/exp/ssh/tcpip.go \
go/exp/ssh/transport.go

go_exp_terminal_files = \
go/exp/terminal/shell.go \
go/exp/terminal/terminal.go
go/exp/terminal/terminal.go \
go/exp/terminal/util.go

go_exp_types_files = \
go/exp/types/check.go \
Expand Down Expand Up @@ -1890,6 +1892,7 @@ go_unicode_utf8_files = \
# Support for netlink sockets and messages.
@LIBGO_IS_LINUX_TRUE@syscall_netlink_file = go/syscall/netlink_linux.go
go_base_syscall_files = \
go/syscall/env_unix.go \
go/syscall/libcall_support.go \
go/syscall/libcall_posix.go \
go/syscall/socket.go \
Expand Down
7 changes: 3 additions & 4 deletions libgo/go/bufio/bufio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"io"
"io/ioutil"
"os"
"strings"
"testing"
"testing/iotest"
Expand Down Expand Up @@ -425,9 +424,9 @@ var errorWriterTests = []errorWriterTest{
{0, 1, nil, io.ErrShortWrite},
{1, 2, nil, io.ErrShortWrite},
{1, 1, nil, nil},
{0, 1, os.EPIPE, os.EPIPE},
{1, 2, os.EPIPE, os.EPIPE},
{1, 1, os.EPIPE, os.EPIPE},
{0, 1, io.ErrClosedPipe, io.ErrClosedPipe},
{1, 2, io.ErrClosedPipe, io.ErrClosedPipe},
{1, 1, io.ErrClosedPipe, io.ErrClosedPipe},
}

func TestWriteErrors(t *testing.T) {
Expand Down
12 changes: 11 additions & 1 deletion libgo/go/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ type rune rune
// invocation.
type Type int

// Type1 is here for the purposes of documentation only. It is a stand-in
// for any Go type, but represents the same type for any given function
// invocation.
type Type1 int

// IntegerType is here for the purposes of documentation only. It is a stand-in
// for any integer type: int, uint, int8 etc.
type IntegerType int
Expand Down Expand Up @@ -119,6 +124,11 @@ func append(slice []Type, elems ...Type) []Type
// len(src) and len(dst).
func copy(dst, src []Type) int

// The delete built-in function deletes the element with the specified key
// (m[key]) from the map. If there is no such element, delete is a no-op.
// If m is nil, delete panics.
func delete(m map[Type]Type1, key Type)

// The len built-in function returns the length of v, according to its type:
// Array: the number of elements in v.
// Pointer to array: the number of elements in *v (even if v is nil).
Expand Down Expand Up @@ -171,7 +181,7 @@ func complex(r, i FloatType) ComplexType
// The return value will be floating point type corresponding to the type of c.
func real(c ComplexType) FloatType

// The imaginary built-in function returns the imaginary part of the complex
// The imag built-in function returns the imaginary part of the complex
// number c. The return value will be floating point type corresponding to
// the type of c.
func imag(c ComplexType) FloatType
Expand Down
63 changes: 32 additions & 31 deletions libgo/go/bytes/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,48 +662,49 @@ func TestRunes(t *testing.T) {
}

type TrimTest struct {
f func([]byte, string) []byte
f string
in, cutset, out string
}

var trimTests = []TrimTest{
{Trim, "abba", "a", "bb"},
{Trim, "abba", "ab", ""},
{TrimLeft, "abba", "ab", ""},
{TrimRight, "abba", "ab", ""},
{TrimLeft, "abba", "a", "bba"},
{TrimRight, "abba", "a", "abb"},
{Trim, "<tag>", "<>", "tag"},
{Trim, "* listitem", " *", "listitem"},
{Trim, `"quote"`, `"`, "quote"},
{Trim, "\u2C6F\u2C6F\u0250\u0250\u2C6F\u2C6F", "\u2C6F", "\u0250\u0250"},
{"Trim", "abba", "a", "bb"},
{"Trim", "abba", "ab", ""},
{"TrimLeft", "abba", "ab", ""},
{"TrimRight", "abba", "ab", ""},
{"TrimLeft", "abba", "a", "bba"},
{"TrimRight", "abba", "a", "abb"},
{"Trim", "<tag>", "<>", "tag"},
{"Trim", "* listitem", " *", "listitem"},
{"Trim", `"quote"`, `"`, "quote"},
{"Trim", "\u2C6F\u2C6F\u0250\u0250\u2C6F\u2C6F", "\u2C6F", "\u0250\u0250"},
//empty string tests
{Trim, "abba", "", "abba"},
{Trim, "", "123", ""},
{Trim, "", "", ""},
{TrimLeft, "abba", "", "abba"},
{TrimLeft, "", "123", ""},
{TrimLeft, "", "", ""},
{TrimRight, "abba", "", "abba"},
{TrimRight, "", "123", ""},
{TrimRight, "", "", ""},
{TrimRight, "☺\xc0", "☺", "☺\xc0"},
{"Trim", "abba", "", "abba"},
{"Trim", "", "123", ""},
{"Trim", "", "", ""},
{"TrimLeft", "abba", "", "abba"},
{"TrimLeft", "", "123", ""},
{"TrimLeft", "", "", ""},
{"TrimRight", "abba", "", "abba"},
{"TrimRight", "", "123", ""},
{"TrimRight", "", "", ""},
{"TrimRight", "☺\xc0", "☺", "☺\xc0"},
}

func TestTrim(t *testing.T) {
for _, tc := range trimTests {
actual := string(tc.f([]byte(tc.in), tc.cutset))
var name string
switch tc.f {
case Trim:
name = "Trim"
case TrimLeft:
name = "TrimLeft"
case TrimRight:
name = "TrimRight"
name := tc.f
var f func([]byte, string) []byte
switch name {
case "Trim":
f = Trim
case "TrimLeft":
f = TrimLeft
case "TrimRight":
f = TrimRight
default:
t.Error("Undefined trim function")
t.Error("Undefined trim function %s", name)
}
actual := string(f([]byte(tc.in), tc.cutset))
if actual != tc.out {
t.Errorf("%s(%q, %q) = %q; want %q", name, tc.in, tc.cutset, actual, tc.out)
}
Expand Down
5 changes: 3 additions & 2 deletions libgo/go/compress/lzw/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"errors"
"fmt"
"io"
"os"
)

// Order specifies the bit ordering in an LZW data stream.
Expand Down Expand Up @@ -212,8 +211,10 @@ func (d *decoder) flush() {
d.o = 0
}

var errClosed = errors.New("compress/lzw: reader/writer is closed")

func (d *decoder) Close() error {
d.err = os.EINVAL // in case any Reads come along
d.err = errClosed // in case any Reads come along
return nil
}

Expand Down
17 changes: 9 additions & 8 deletions libgo/go/compress/lzw/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"os"
)

// A writer is a buffered, flushable writer.
Expand Down Expand Up @@ -49,8 +48,9 @@ const (
type encoder struct {
// w is the writer that compressed bytes are written to.
w writer
// write, bits, nBits and width are the state for converting a code stream
// into a byte stream.
// order, write, bits, nBits and width are the state for
// converting a code stream into a byte stream.
order Order
write func(*encoder, uint32) error
bits uint32
nBits uint
Expand All @@ -64,7 +64,7 @@ type encoder struct {
// call. It is equal to invalidCode if there was no such call.
savedCode uint32
// err is the first error encountered during writing. Closing the encoder
// will make any future Write calls return os.EINVAL.
// will make any future Write calls return errClosed
err error
// table is the hash table from 20-bit keys to 12-bit values. Each table
// entry contains key<<12|val and collisions resolve by linear probing.
Expand Down Expand Up @@ -191,13 +191,13 @@ loop:
// flush e's underlying writer.
func (e *encoder) Close() error {
if e.err != nil {
if e.err == os.EINVAL {
if e.err == errClosed {
return nil
}
return e.err
}
// Make any future calls to Write return os.EINVAL.
e.err = os.EINVAL
// Make any future calls to Write return errClosed.
e.err = errClosed
// Write the savedCode if valid.
if e.savedCode != invalidCode {
if err := e.write(e, e.savedCode); err != nil {
Expand All @@ -214,7 +214,7 @@ func (e *encoder) Close() error {
}
// Write the final bits.
if e.nBits > 0 {
if e.write == (*encoder).writeMSB {
if e.order == MSB {
e.bits >>= 24
}
if err := e.w.WriteByte(uint8(e.bits)); err != nil {
Expand Down Expand Up @@ -250,6 +250,7 @@ func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser {
lw := uint(litWidth)
return &encoder{
w: bw,
order: order,
write: write,
width: 1 + lw,
litWidth: lw,
Expand Down
4 changes: 0 additions & 4 deletions libgo/go/compress/lzw/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ func testFile(t *testing.T, fn string, order Order, litWidth int) {
return
}
_, err1 := lzww.Write(b[:n])
if err1 == os.EPIPE {
// Fail, but do not report the error, as some other (presumably reportable) error broke the pipe.
return
}
if err1 != nil {
t.Errorf("%s (order=%d litWidth=%d): %v", fn, order, litWidth, err1)
return
Expand Down
4 changes: 0 additions & 4 deletions libgo/go/compress/zlib/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ func testLevelDict(t *testing.T, fn string, b0 []byte, level int, d string) {
}
defer zlibw.Close()
_, err = zlibw.Write(b0)
if err == os.EPIPE {
// Fail, but do not report the error, as some other (presumably reported) error broke the pipe.
return
}
if err != nil {
t.Errorf("%s (level=%d, dict=%q): %v", fn, level, d, err)
return
Expand Down
2 changes: 1 addition & 1 deletion libgo/go/crypto/aes/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewCipher(key []byte) (*Cipher, error) {
}

// BlockSize returns the AES block size, 16 bytes.
// It is necessary to satisfy the Cipher interface in the
// It is necessary to satisfy the Block interface in the
// package "crypto/cipher".
func (c *Cipher) BlockSize() int { return BlockSize }

Expand Down
2 changes: 1 addition & 1 deletion libgo/go/crypto/blowfish/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewSaltedCipher(key, salt []byte) (*Cipher, error) {
}

// BlockSize returns the Blowfish block size, 8 bytes.
// It is necessary to satisfy the Cipher interface in the
// It is necessary to satisfy the Block interface in the
// package "crypto/cipher".
func (c *Cipher) BlockSize() int { return BlockSize }

Expand Down
12 changes: 6 additions & 6 deletions libgo/go/crypto/rand/rand_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ func (r *rngReader) Read(b []byte) (n int, err error) {
if r.prov == 0 {
const provType = syscall.PROV_RSA_FULL
const flags = syscall.CRYPT_VERIFYCONTEXT | syscall.CRYPT_SILENT
errno := syscall.CryptAcquireContext(&r.prov, nil, nil, provType, flags)
if errno != 0 {
err := syscall.CryptAcquireContext(&r.prov, nil, nil, provType, flags)
if err != nil {
r.mu.Unlock()
return 0, os.NewSyscallError("CryptAcquireContext", errno)
return 0, os.NewSyscallError("CryptAcquireContext", err)
}
}
r.mu.Unlock()
errno := syscall.CryptGenRandom(r.prov, uint32(len(b)), &b[0])
if errno != 0 {
return 0, os.NewSyscallError("CryptGenRandom", errno)
err = syscall.CryptGenRandom(r.prov, uint32(len(b)), &b[0])
if err != nil {
return 0, os.NewSyscallError("CryptGenRandom", err)
}
return len(b), nil
}
Loading

0 comments on commit 46bc1fe

Please sign in to comment.