Commit 9c63abc9 by Ian Lance Taylor

libgo: Update to weekly 2011-11-09.

From-SVN: r182073
parent 37428023
......@@ -18,7 +18,7 @@ import (
"fmt"
"io"
"os"
"template"
"text/template"
)
func main() {
......
......@@ -9,14 +9,14 @@
package main
import (
"cmath"
"fmt"
"math"
"math/cmplx"
)
type Test struct{
f, g complex128
out complex128
type Test struct {
f, g complex128
out complex128
}
var nan = math.NaN()
......@@ -25,9 +25,9 @@ var negzero = math.Copysign(0, -1)
func calike(a, b complex128) bool {
switch {
case cmath.IsInf(a) && cmath.IsInf(b):
case cmplx.IsInf(a) && cmplx.IsInf(b):
return true
case cmath.IsNaN(a) && cmath.IsNaN(b):
case cmplx.IsNaN(a) && cmplx.IsNaN(b):
return true
}
return a == b
......@@ -36,7 +36,7 @@ func calike(a, b complex128) bool {
func main() {
bad := false
for _, t := range tests {
x := t.f/t.g
x := t.f / t.g
if !calike(x, t.out) {
if !bad {
fmt.Printf("BUG\n")
......
......@@ -10,8 +10,8 @@
package main
import (
"http"
"io/ioutil" // GCCGO_ERROR "imported and not used"
"net/http"
"os"
)
......
......@@ -6,7 +6,7 @@
package main
import "rand"
import "math/rand"
const Count = 1e5
......
......@@ -6,7 +6,7 @@
package main
import "rand"
import "math/rand"
const Count = 1e5
......
......@@ -10,7 +10,7 @@ package main
import (
"flag"
"rand"
"math/rand"
"runtime"
"unsafe"
)
......
......@@ -9,28 +9,29 @@ package main
import (
"fmt"
"os"
"utf8"
"unicode/utf8"
)
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
......
......@@ -6,10 +6,10 @@
package main
import "utf8"
import "unicode/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++
}
}
780c85032b17
2f4482b89a6b
The first line of this file holds the Mercurial revision number of the
last merge done from the master library sources.
......@@ -29,7 +29,7 @@ var (
// tr := tar.NewReader(r)
// for {
// hdr, err := tr.Next()
// if err == os.EOF {
// if err == io.EOF {
// // end of tar archive
// break
// }
......@@ -200,7 +200,7 @@ func (tr *Reader) readHeader() *Header {
}
// Read reads from the current entry in the tar archive.
// It returns 0, os.EOF when it reaches the end of that entry,
// It returns 0, io.EOF when it reaches the end of that entry,
// until Next is called to advance to the next entry.
func (tr *Reader) Read(b []byte) (n int, err error) {
if tr.nb == 0 {
......
......@@ -7,10 +7,10 @@ package zip
import (
"bufio"
"compress/flate"
"encoding/binary"
"errors"
"hash"
"hash/crc32"
"encoding/binary"
"io"
"io/ioutil"
"os"
......@@ -60,6 +60,7 @@ func OpenReader(name string) (*ReadCloser, error) {
f.Close()
return nil, err
}
r.f = f
return r, nil
}
......
......@@ -98,7 +98,11 @@ func readTestZip(t *testing.T, zt ZipTest) {
if err == FormatError {
return
}
defer z.Close()
defer func() {
if err := z.Close(); err != nil {
t.Errorf("error %q when closing zip file", err)
}
}()
// bail here if no Files expected to be tested
// (there may actually be files in the zip, but we don't care)
......
......@@ -7,7 +7,7 @@ package zip
import (
"bytes"
"io/ioutil"
"rand"
"math/rand"
"testing"
)
......
......@@ -11,7 +11,7 @@ import (
"bytes"
"io"
"strconv"
"utf8"
"unicode/utf8"
)
const (
......@@ -135,7 +135,7 @@ func (b *Reader) Peek(n int) ([]byte, error) {
// It returns the number of bytes read into p.
// It calls Read at most once on the underlying Reader,
// hence n may be less than len(p).
// At EOF, the count will be zero and err will be os.EOF.
// At EOF, the count will be zero and err will be io.EOF.
func (b *Reader) Read(p []byte) (n int, err error) {
n = len(p)
if n == 0 {
......@@ -246,7 +246,7 @@ func (b *Reader) Buffered() int { return b.w - b.r }
// returning a slice pointing at the bytes in the buffer.
// The bytes stop being valid at the next read call.
// If ReadSlice encounters an error before finding a delimiter,
// it returns all the data in the buffer and the error itself (often os.EOF).
// it returns all the data in the buffer and the error itself (often io.EOF).
// ReadSlice fails with error ErrBufferFull if the buffer fills without a delim.
// Because the data returned from ReadSlice will be overwritten
// by the next I/O operation, most clients should use
......@@ -312,6 +312,9 @@ func (b *Reader) ReadLine() (line []byte, isPrefix bool, err error) {
}
if len(line) == 0 {
if err != nil {
line = nil
}
return
}
err = nil
......@@ -329,7 +332,7 @@ func (b *Reader) ReadLine() (line []byte, isPrefix bool, err error) {
// ReadBytes reads until the first occurrence of delim in the input,
// returning a slice containing the data up to and including the delimiter.
// If ReadBytes encounters an error before finding a delimiter,
// it returns the data read before the error and the error itself (often os.EOF).
// it returns the data read before the error and the error itself (often io.EOF).
// ReadBytes returns err != nil if and only if the returned data does not end in
// delim.
func (b *Reader) ReadBytes(delim byte) (line []byte, err error) {
......@@ -376,7 +379,7 @@ func (b *Reader) ReadBytes(delim byte) (line []byte, err error) {
// ReadString reads until the first occurrence of delim in the input,
// returning a string containing the data up to and including the delimiter.
// If ReadString encounters an error before finding a delimiter,
// it returns the data read before the error and the error itself (often os.EOF).
// it returns the data read before the error and the error itself (often io.EOF).
// ReadString returns err != nil if and only if the returned data does not end in
// delim.
func (b *Reader) ReadString(delim byte) (line string, err error) {
......
......@@ -14,7 +14,7 @@ import (
"strings"
"testing"
"testing/iotest"
"utf8"
"unicode/utf8"
)
// Reads from a reader and rot13s the result.
......@@ -698,6 +698,17 @@ func TestLinesAfterRead(t *testing.T) {
}
}
func TestReadLineNonNilLineOrError(t *testing.T) {
r := NewReader(strings.NewReader("line 1\n"))
for i := 0; i < 2; i++ {
l, _, err := r.ReadLine()
if l != nil && err != nil {
t.Fatalf("on line %d/2; ReadLine=%#v, %v; want non-nil line or Error, but not both",
i+1, l, err)
}
}
}
type readLineResult struct {
line []byte
isPrefix bool
......
......@@ -3,13 +3,89 @@
// license that can be found in the LICENSE file.
/*
Package builtin provides documentation for Go's built-in functions.
The functions documented here are not actually in package builtin
Package builtin provides documentation for Go's predeclared identifiers.
The items documented here are not actually in package builtin
but their descriptions here allow godoc to present documentation
for the language's special functions.
for the language's special identifiers.
*/
package builtin
// bool is the set of boolean values, true and false.
type bool bool
// uint8 is the set of all unsigned 8-bit integers.
// Range: 0 through 255.
type uint8 uint8
// uint16 is the set of all unsigned 16-bit integers.
// Range: 0 through 65535.
type uint16 uint16
// uint32 is the set of all unsigned 32-bit integers.
// Range: 0 through 4294967295.
type uint32 uint32
// uint64 is the set of all unsigned 64-bit integers.
// Range: 0 through 18446744073709551615.
type uint64 uint64
// int8 is the set of all signed 8-bit integers.
// Range: -128 through 127.
type int8 int8
// int16 is the set of all signed 16-bit integers.
// Range: -32768 through 32767.
type int16 int16
// int32 is the set of all signed 32-bit integers.
// Range: -2147483648 through 2147483647.
type int32 int32
// int64 is the set of all signed 64-bit integers.
// Range: -9223372036854775808 through 9223372036854775807.
type int64 int64
// float32 is the set of all IEEE-754 32-bit floating-point numbers.
type float32 float32
// float64 is the set of all IEEE-754 64-bit floating-point numbers.
type float64 float64
// complex64 is the set of all complex numbers with float32 real and
// imaginary parts.
type complex64 complex64
// complex128 is the set of all complex numbers with float64 real and
// imaginary parts.
type complex128 complex128
// string is the set of all strings of 8-bit bytes, conventionally but not
// necessarily representing UTF-8-encoded text. A string may be empty, but
// not nil. Values of string type are immutable.
type string string
// int is a signed integer type that is at least 32 bits in size. It is a
// distinct type, however, and not an alias for, say, int32.
type int int
// uint is an unsigned integer type that is at least 32 bits in size. It is a
// distinct type, however, and not an alias for, say, uint32.
type uint uint
// uintptr is an integer type that is large enough to hold the bit pattern of
// any pointer.
type uintptr uintptr
// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is
// used, by convention, to distinguish byte values from 8-bit unsigned
// integer values.
type byte byte
// rune is an alias for int and is equivalent to int in all ways. It is
// used, by convention, to distinguish character values from integer values.
// In a future version of Go, it will change to an alias of int32.
type rune rune
// Type 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.
......@@ -21,11 +97,11 @@ type IntegerType int
// FloatType is here for the purposes of documentation only. It is a stand-in
// for either float type: float32 or float64.
type FloatType int
type FloatType float32
// ComplexType is here for the purposes of documentation only. It is a
// stand-in for either complex type: complex64 or complex128.
type ComplexType int
type ComplexType complex64
// The append built-in function appends elements to the end of a slice. If
// it has sufficient capacity, the destination is resliced to accommodate the
......@@ -133,3 +209,9 @@ func panic(v interface{})
// nil. Thus the return value from recover reports whether the goroutine is
// panicking.
func recover() interface{}
// The error built-in interface type is the conventional interface for
// representing an error condition, with the nil value representing no error.
type error interface {
Error() string
}
......@@ -9,7 +9,7 @@ package bytes
import (
"errors"
"io"
"utf8"
"unicode/utf8"
)
// A Buffer is a variable-sized buffer of bytes with Read and Write methods.
......@@ -117,7 +117,7 @@ const MinRead = 512
// ReadFrom reads data from r until EOF and appends it to the buffer.
// The return value n is the number of bytes read.
// Any error except os.EOF encountered during the read
// Any error except io.EOF encountered during the read
// is also returned.
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
b.lastRead = opInvalid
......@@ -200,7 +200,7 @@ func (b *Buffer) WriteRune(r rune) (n int, err error) {
// Read reads the next len(p) bytes from the buffer or until the buffer
// is drained. The return value n is the number of bytes read. If the
// buffer has no data to return, err is os.EOF even if len(p) is zero;
// buffer has no data to return, err is io.EOF even if len(p) is zero;
// otherwise it is nil.
func (b *Buffer) Read(p []byte) (n int, err error) {
b.lastRead = opInvalid
......@@ -236,7 +236,7 @@ func (b *Buffer) Next(n int) []byte {
}
// ReadByte reads and returns the next byte from the buffer.
// If no byte is available, it returns error os.EOF.
// If no byte is available, it returns error io.EOF.
func (b *Buffer) ReadByte() (c byte, err error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) {
......@@ -252,7 +252,7 @@ func (b *Buffer) ReadByte() (c byte, err error) {
// ReadRune reads and returns the next UTF-8-encoded
// Unicode code point from the buffer.
// If no bytes are available, the error returned is os.EOF.
// If no bytes are available, the error returned is io.EOF.
// If the bytes are an erroneous UTF-8 encoding, it
// consumes one byte and returns U+FFFD, 1.
func (b *Buffer) ReadRune() (r rune, size int, err error) {
......@@ -307,7 +307,7 @@ func (b *Buffer) UnreadByte() error {
// ReadBytes reads until the first occurrence of delim in the input,
// returning a slice containing the data up to and including the delimiter.
// If ReadBytes encounters an error before finding a delimiter,
// it returns the data read before the error and the error itself (often os.EOF).
// it returns the data read before the error and the error itself (often io.EOF).
// ReadBytes returns err != nil if and only if the returned data does not end in
// delim.
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
......@@ -326,7 +326,7 @@ func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
// ReadString reads until the first occurrence of delim in the input,
// returning a string containing the data up to and including the delimiter.
// If ReadString encounters an error before finding a delimiter,
// it returns the data read before the error and the error itself (often os.EOF).
// it returns the data read before the error and the error itself (often io.EOF).
// ReadString returns err != nil if and only if the returned data does not end
// in delim.
func (b *Buffer) ReadString(delim byte) (line string, err error) {
......
......@@ -7,9 +7,9 @@ package bytes_test
import (
. "bytes"
"io"
"rand"
"math/rand"
"testing"
"utf8"
"unicode/utf8"
)
const N = 10000 // make this bigger for a larger (and slower) test
......
......@@ -8,7 +8,7 @@ package bytes
import (
"unicode"
"utf8"
"unicode/utf8"
)
// Compare returns an integer comparing the two byte arrays lexicographically.
......@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
return n
}
// Contains returns whether subslice is within b.
func Contains(b, subslice []byte) bool {
return Index(b, subslice) != -1
}
// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func Index(s, sep []byte) int {
n := len(sep)
......
......@@ -9,7 +9,7 @@ import (
"reflect"
"testing"
"unicode"
"utf8"
"unicode/utf8"
)
func eq(a, b []string) bool {
......
......@@ -37,7 +37,7 @@ func newBitReader(r io.Reader) bitReader {
// ReadBits64 reads the given number of bits and returns them in the
// least-significant part of a uint64. In the event of an error, it returns 0
// and the error can be obtained by calling Error().
// and the error can be obtained by calling Err().
func (br *bitReader) ReadBits64(bits uint) (n uint64) {
for bits > br.bits {
b, err := br.r.ReadByte()
......@@ -82,6 +82,6 @@ func (br *bitReader) ReadBit() bool {
return n != 0
}
func (br *bitReader) Error() error {
func (br *bitReader) Err() error {
return br.err
}
......@@ -80,7 +80,7 @@ func (bz2 *reader) Read(buf []byte) (n int, err error) {
if !bz2.setupDone {
err = bz2.setup()
brErr := bz2.br.Error()
brErr := bz2.br.Err()
if brErr != nil {
err = brErr
}
......@@ -91,7 +91,7 @@ func (bz2 *reader) Read(buf []byte) (n int, err error) {
}
n, err = bz2.read(buf)
brErr := bz2.br.Error()
brErr := bz2.br.Err()
if brErr != nil {
err = brErr
}
......
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279434907632338298807531952510190115738341879307021540891499348841675092447614606680822648001684774118537423454424371075390777449920695517027618386062613313845830007520449338265602976067371132007093287091274437470472306969772093101416928368190255151086574637721112523897844250569536967707854499699679468644549059879316368892300987931277361782154249992295763514822082698951936680331825288693984964651058209392398294887933203625094431173012381970684161403970198376793206832823764648042953118023287825098194558153017567173613320698112509961818815930416903515988885193458072738667385894228792284998920868058257492796104841984443634632449684875602336248270419786232090021609902353043699418491463140934317381436405462531520961836908887070167683964243781405927145635490613031072085103837505101157477041718986106873969655212671546889570350354021234078498193343210681701210056278802351930332247450158539047304199577770935036604169973297250886876966403555707162268447162560798826517871341951246652010305921236677194325278675398558944896970964097545918569563802363701621120477427228364896134225164450781824423529486363721417402388934412479635743702637552944483379980161254922785092577825620926226483262779333865664816277251640191059004916449982893150566047258027786318641551956532442586982946959308019152987211725563475463964479101459040905862984967912874068705048958586717479854667757573205681288459205413340539220001137863009455606881667400169842055804033637953764520304024322566135278369511778838638744396625322498506549958862342818997077332761717839280349465014345588970719425863987727547109629537415211151368350627526023264847287039207643100595841166120545297030236472549296669381151373227536450988890313602057248176585118063036442812314965507047510254465011727211555194866850800368532281831521960037356252794495158284188294787610852639813955990067376482922443752871846245780361929819713991475644882626039033814418232625150974827987779964373089970388867782271383605772978824125611907176639465070633045279546618550966661856647097113444740160704626215680717481877844371436988218559670959102596862002353718588748569652200050311734392073211390803293634479727355955277349071783793421637012050054513263835440001863239914907054797780566978533580489669062951194324730995876552368128590413832411607226029983305353708761389396391779574540161372236187893652605381558415871869255386061647798340254351284396129460352913325942794904337299085731580290958631382683291477116396337092400316894586360606458459251269946557248391865642097526850823075442545993769170419777800853627309417101634349076964237222943523661255725088147792231519747780605696725380171807763603462459278778465850656050780844211529697521890874019660906651803516501792504619501366585436632712549639908549144200014574760819302212066024330096412704894390397177195180699086998606636583232278709376502260149291011517177635944602023249300280401867723910288097866605651183260043688508817157238669842242201024950551881694803221002515426494639812873677658927688163598312477886520141174110913601164995076629077943646005851941998560162647907615321038727557126992518275687989302761761146162549356495903798045838182323368612016243736569846703785853305275833337939907521660692380533698879565137285593883499894707416181550125397064648171946708348197214488898790676503795903669672494992545279033729636162658976039498576741397359441023744329709355477982629614591442936451428617158587339746791897571211956187385783644758448423555581050025611492391518893099463428413936080383091662818811503715284967059741625628236092168075150177725387402564253470879089137291722828611515915683725241630772254406337875931059826760944203261924285317018781772960235413060672136046000389661093647095141417185777014180606443636815464440053316087783143174440811949422975599314011888683314832802706553833004693290115744147563139997221703804617092894579096271662260740718749975359212756084414737823303270330168237193648002173285734935947564334129943024850235732214597843282641421684878721673367010615094243456984401873312810107945127223737886126058165668053714396127888732527373890392890506865324138062796025930387727697783792868409325365880733988457218746021005311483351323850047827169376218004904795597959290591655470505777514308175112698985188408718564026035305583737832422924185625644255022672155980274012617971928047139600689163828665277009752767069777036439260224372841840883251848770472638440379530166905465937461619323840363893131364327137688841026811219891275223056256756254701725086349765367288605966752740868627407912856576996313789753034660616669804218267724560530660773899624218340859882071864682623215080288286359746839654358856685503773131296587975810501214916207656769950659715344763470320853215603674828608378656803073062657633469774295634643716709397193060876963495328846833613038829431040800296873869117066666146800015121143442256023874474325250769387077775193299942137277211258843608715834835626961661980572526612206797540621062080649882918454395301529982092503005498257043390553570168653120526495614857249257386206917403695213533732531666345466588597286659451136441370331393672118569553952108458407244323835586063106806964924851232632699514603596037297253198368423363904632136710116192821711150282801604488058802382031981493096369596735832742024988245684941273860566491352526706046234450549227581151709314921879592718001940968866986837037302200475314338181092708030017205935530520700706072233999463990571311587099635777359027196285061146514837526209565346713290025994397663114545902685898979115837093419370441155121920117164880566945938131183843765620627846310490346293950029458341164824114969758326011800731699437393506966295712410273239138741754923071862454543222039552735295240245903805744502892246886285336542213815722131163288112052146489805180092024719391710555390113943316681515828843687606961102505171007392762385553386272553538830960671644662370922646809671254061869502143176211668140097595281493907222601112681153108387317617323235263605838173151034595736538223534992935822836851007810884634349983518404451704270189381994243410090575376257767571118090088164183319201962623416288166521374717325477727783488774366518828752156685719506371936565390389449366421764003121527870222366463635755503565576948886549500270853923617105502131147413744106134445544192101336172996285694899193369184729478580729156088510396781959429833186480756083679551496636448965592948187851784038773326247051945050419847742014183947731202815886845707290544057510601285258056594703046836344592652552137008068752009593453607316226118728173928074623094685367823106097921599360019946237993434210687813497346959246469752506246958616909178573976595199392993995567542714654910456860702099012606818704984178079173924071945996323060254707901774527513186809982284730860766536866855516467702911336827563107223346726113705490795365834538637196235856312618387156774118738527722922594743373785695538456246801013905727871016512966636764451872465653730402443684140814488732957847348490003019477888020460324660842875351848364959195082888323206522128104190448047247949291342284951970022601310430062410717971502793433263407995960531446053230488528972917659876016667811937932372453857209607582277178483361613582612896226118129455927462767137794487586753657544861407611931125958512655759734573015333642630767985443385761715333462325270572005303988289499034259566232975782488735029259166825894456894655992658454762694528780516501720674785417887982276806536650641910973434528878338621726156269582654478205672987756426325321594294418039943217000090542650763095588465895171709147607437136893319469090981904501290307099566226620303182649365733698419555776963787624918852865686607600566025605445711337286840205574416030837052312242587223438854123179481388550075689381124935386318635287083799845692619981794523364087429591180747453419551420351726184200845509170845682368200897739455842679214273477560879644279202708312150156406341341617166448069815483764491573900121217041547872591998943825364950514771379399147205219529079396137621107238494290616357604596231253506068537651423115349665683715116604220796394466621163255157729070978473156278277598788136491951257483328793771571459091064841642678309949723674420175862269402159407924480541255360431317992696739157542419296607312393763542139230617876753958711436104089409966089471418340698362993675362621545247298464213752891079884381306095552622720837518629837066787224430195793793786072107254277289071732854874374355781966511716618330881129120245204048682200072344035025448202834254187884653602591506445271657700044521097735585897622655484941621714989532383421600114062950718490427789258552743035221396835679018076406042138307308774460170842688272261177180842664333651780002171903449234264266292261456004337383868335555343453004264818473989215627086095650629340405264943244261445665921291225648893569655009154306426134252668472594914314239398845432486327461842846655985332312210466259890141712103446084271616619001257195870793217569698544013397622096749454185407118446433946990162698351607848924514058940946395267807354579700307051163682519487701189764002827648414160587206184185297189154019688253289309149665345753571427318482016384644832499037886069008072709327673127581966563941148961716832980455139729506687604740915420428429993541025829113502241690769431668574242522509026939034814856451303069925199590436384028429267412573422447765584177886171737265462085498294498946787350929581652632072258992368768457017823038096567883112289305809140572610865884845873101658151167533327674887014829167419701512559782572707406431808601428149024146780472327597684269633935773542930186739439716388611764209004068663398856841681003872389214483176070116684503887212364367043314091155733280182977988736590916659612402021778558854876176161989370794380056663364884365089144805571039765214696027662583599051987042300179465536788
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632788659361533818279682303019520353018529689957736225994138912497217752834791315155748572424541506959508295331168617278558890750983817546374649393192550604009277016711390098488240128583616035637076601047101819429555961989467678374494482553797747268471040475346462080466842590694912933136770289891521047521620569660240580381501935112533824300355876402474964732639141992726042699227967823547816360093417216412199245863150302861829745557067498385054945885869269956909272107975093029553211653449872027559602364806654991198818347977535663698074265425278625518184175746728909777727938000816470600161452491921732172147723501414419735685481613611573525521334757418494684385233239073941433345477624168625189835694855620992192221842725502542568876717904946016534668049886272327917860857843838279679766814541009538837863609506800642251252051173929848960841284886269456042419652850222106611863067442786220391949450471237137869609563643719172874677646575739624138908658326459958133904780275900994657640789512694683983525957098258226205224894077267194782684826014769909026401363944374553050682034962524517493996514314298091906592509372216964615157098583874105978859597729754989301617539284681382686838689427741559918559252459539594310499725246808459872736446958486538367362226260991246080512438843904512441365497627807977156914359977001296160894416948685558484063534220722258284886481584560285060168427394522674676788952521385225499546667278239864565961163548862305774564980355936345681743241125150760694794510965960940252288797108931456691368672287489405601015033086179286809208747609178249385890097149096759852613655497818931297848216829989487226588048575640142704775551323796414515237462343645428584447952658678210511413547357395231134271661021359695362314429524849371871101457654035902799344037420073105785390621983874478084784896833214457138687519435064302184531910484810053706146806749192781911979399520614196634287544406437451237181921799983910159195618146751426912397489409071864942319615679452080951465502252316038819301420937621378559566389377870830390697920773467221825625996615014215030680384477345492026054146659252014974428507325186660021324340881907104863317346496514539057962685610055081066587969981635747363840525714591028970641401109712062804390397595156771577004203378699360072305587631763594218731251471205329281918261861258673215791984148488291644706095752706957220917567116722910981690915280173506712748583222871835209353965725121083579151369882091444210067510334671103141267111369908658516398315019701651511685171437657618351556508849099898599823873455283316355076479185358932261854896321329330898570642046752590709154814165498594616371802709819943099244889575712828905923233260972997120844335732654893823911932597463667305836041428138830320382490375898524374417029132765618093773444030707469211201913020330380197621101100449293215160842444859637669838952286847831235526582131449576857262433441893039686426243410773226978028073189154411010446823252716201052652272111660396665573092547110557853763466820653109896526918620564769312570586356620185581007293606598764861179104533488503461136576867532494416680396265797877185560845529654126654085306143444318586769751456614068007002378776591344017127494704205622305389945613140711270004078547332699390814546646458807972708266830634328587856983052358089330657574067954571637752542021149557615814002501262285941302164715509792592309907965473761255176567513575178296664547791745011299614890304639947132962107340437518957359614589019389713111790429782856475032031986915140287080859904801094121472213179476477726224142548545403321571853061422881375850430633217518297986622371721591607716692547487389866549494501146540628433663937900397692656721463853067360965712091807638327166416274888800786925602902284721040317211860820419000422966171196377921337575114959501566049631862947265473642523081770367515906735023507283540567040386743513622224771589150495309844489333096340878076932599397805419341447377441842631298608099888687413260472156951623965864573021631598193195167353812974167729478672422924654366800980676928238280689964004824354037014163149658979409243237896907069779422362508221688957383798623001593776471651228935786015881617557829735233446042815126272037343146531977774160319906655418763979293344195215413418994854447345673831624993419131814809277771038638773431772075456545322077709212019051660962804909263601975988281613323166636528619326686336062735676303544776280350450777235547105859548702790814356240145171806246436267945612753181340783303362542327839449753824372058353114771199260638133467768796959703098339130771098704085913374641442822772634659470474587847787201927715280731767907707157213444730605700733492436931138350493163128404251219256517980694113528013147013047816437885185290928545201165839341965621349143415956258658655705526904965209858033850722426482939728584783163057777560688876446248246857926039535277348030480290058760758251047470916439613626760449256274204208320856611906254543372131535958450687724602901618766795240616342522577195429162991930645537799140373404328752628889639958794757291746426357455254079091451357111369410911939325191076020825202618798531887705842972591677813149699009019211697173727847684726860849003377024242916513005005168323364350389517029893922334517220138128069650117844087451960121228599371623130171144484640903890644954440061986907548516026327505298349187407866808818338510228334508504860825039302133219715518430635455007668282949304137765527939751754613953984683393638304746119966538581538420568533862186725233402830871123282789212507712629463229563989898935821167456270102183564622013496715188190973038119800497340723961036854066431939509790190699639552453005450580685501956730229219139339185680344903982059551002263535361920419947455385938102343955449597783779023742161727111723643435439478221818528624085140066604433258885698670543154706965747458550332323342107301545940516553790686627333799585115625784322988273723198987571415957811196358330059408730681216028764962867446047746491599505497374256269010490377819868359381465741268049256487985561453723478673303904688383436346553794986419270563872931748723320837601123029911367938627089438799362016295154133714248928307220126901475466847653576164773794675200490757155527819653621323926406160136358155907422020203187277605277219005561484255518792530343513984425322341576233610642506390497500865627109535919465897514131034822769306247435363256916078154781811528436679570611086153315044521274739245449454236828860613408414863776700961207151249140430272538607648236341433462351897576645216413767969031495019108575984423919862916421939949072362346468441173940326591840443780513338945257423995082965912285085558215725031071257012668302402929525220118726767562204154205161841634847565169998116141010029960783869092916030288400269104140792886215078424516709087000699282120660418371806535567252532567532861291042487761825829765157959847035622262934860034158722980534989650226291748788202734209222245339856264766914905562842503912757710284027998066365825488926488025456610172967026640765590429099456815065265305371829412703369313785178609040708667114965583434347693385781711386455873678123014587687126603489139095620099393610310291616152881384379099042317473363948045759314931405297634757481193567091101377517210080315590248530906692037671922033229094334676851422144773793937517034436619910403375111735471918550464490263655128162288244625759163330391072253837421821408835086573917715096828874782656995995744906617583441375223970968340800535598491754173818839994469748676265516582765848358845314277568790029095170283529716344562129640435231176006651012412006597558512761785838292041974844236080071930457618932349229279650198751872127267507981255470958904556357921221033346697499235630254947802490114195212382815309114079073860251522742995818072471625916685451333123948049470791191532673430282441860414263639548000448002670496248201792896476697583183271314251702969234889627668440323260927524960357996469256504936818360900323809293459588970695365349406034021665443755890045632882250545255640564482465151875471196218443965825337543885690941130315095261793780029741207665147939425902989695946995565761218656196733786236256125216320862869222103274889218654364802296780705765615144632046927906821207388377814233562823608963208068222468012248261177185896381409183903673672220888321513755600372798394004152970028783076670944474560134556417254370906979396122571429894671543578468788614445812314593571984922528471605049221242470141214780573455105008019086996033027634787081081754501193071412233908663938339529425786905076431006383519834389341596131854347546495569781038293097164651438407007073604112373599843452251610507027056235266012764848308407611830130527932054274628654036036745328651057065874882256981579367897669742205750596834408697350201410206723585020072452256326513410559240190274216248439140359989535394590944070469120914093870012645600162374288021092764579310657922955249887275846101264836999892256959688159205600101655256375678
......@@ -11,14 +11,17 @@ import "sort"
// Any type that implements heap.Interface may be used as a
// min-heap with the following invariants (established after
// Init has been called):
// Init has been called or if the data is empty or sorted):
//
// !h.Less(j, i) for 0 <= i < h.Len() and j = 2*i+1 or 2*i+2 and j < h.Len()
//
// Note that Push and Pop in this interface are for package heap's
// implementation to call. To add and remove things from the heap,
// use heap.Push and heap.Pop.
type Interface interface {
sort.Interface
Push(x interface{})
Pop() interface{}
Push(x interface{}) // add x as element Len()
Pop() interface{} // remove and return element Len() - 1.
}
// A heap must be initialized before any of the heap operations
......
......@@ -5,8 +5,8 @@
package heap_test
import (
"testing"
. "container/heap"
"testing"
)
type myHeap []int
......
......@@ -6,9 +6,9 @@
package dsa
import (
"big"
"errors"
"io"
"math/big"
)
// Parameters represents the domain parameters for a key. These parameters can
......
......@@ -5,8 +5,8 @@
package dsa
import (
"big"
"crypto/rand"
"math/big"
"testing"
)
......
......@@ -13,9 +13,9 @@ package ecdsa
// http://www.secg.org/download/aid-780/sec1-v2.pdf
import (
"big"
"crypto/elliptic"
"io"
"math/big"
)
// PublicKey represents an ECDSA public key.
......
......@@ -5,11 +5,11 @@
package ecdsa
import (
"big"
"crypto/elliptic"
"crypto/sha1"
"crypto/rand"
"crypto/sha1"
"encoding/hex"
"math/big"
"testing"
)
......
......@@ -14,8 +14,8 @@ package elliptic
// reverse the transform than to operate in affine coordinates.
import (
"big"
"io"
"math/big"
"sync"
)
......
......@@ -5,9 +5,9 @@
package elliptic
import (
"big"
"crypto/rand"
"fmt"
"math/big"
"testing"
)
......
......@@ -5,8 +5,8 @@
package hmac
import (
"hash"
"fmt"
"hash"
"testing"
)
......
......@@ -8,12 +8,12 @@
package ocsp
import (
"asn1"
"crypto"
"crypto/rsa"
_ "crypto/sha1"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"time"
)
......
......@@ -151,7 +151,7 @@ func (r *openpgpReader) Read(p []byte) (n int, err error) {
}
// Decode reads a PGP armored block from the given Reader. It will ignore
// leading garbage. If it doesn't find a block, it will return nil, os.EOF. The
// leading garbage. If it doesn't find a block, it will return nil, io.EOF. The
// given Reader is not usable after calling this function: an arbitrary amount
// of data may have been read past the end of the block.
func Decode(in io.Reader) (p *Block, err error) {
......
......@@ -13,11 +13,11 @@
package elgamal
import (
"big"
"crypto/rand"
"crypto/subtle"
"errors"
"io"
"math/big"
)
// PublicKey represents an ElGamal public key.
......
......@@ -5,9 +5,9 @@
package elgamal
import (
"big"
"bytes"
"crypto/rand"
"math/big"
"testing"
)
......
......@@ -5,13 +5,13 @@
package packet
import (
"big"
"crypto/openpgp/elgamal"
error_ "crypto/openpgp/error"
"crypto/rand"
"crypto/rsa"
"encoding/binary"
"io"
"math/big"
"strconv"
)
......
......@@ -5,11 +5,11 @@
package packet
import (
"big"
"bytes"
"crypto/rand"
"crypto/rsa"
"fmt"
"math/big"
"testing"
)
......
......@@ -7,12 +7,12 @@
package packet
import (
"big"
"crypto/aes"
"crypto/cast5"
"crypto/cipher"
error_ "crypto/openpgp/error"
"io"
"math/big"
)
// readFull is the same as io.ReadFull except that reading zero bytes returns
......
......@@ -5,7 +5,6 @@
package packet
import (
"big"
"bytes"
"crypto/cipher"
"crypto/dsa"
......@@ -16,6 +15,7 @@ import (
"crypto/sha1"
"io"
"io/ioutil"
"math/big"
"strconv"
)
......
......@@ -5,7 +5,6 @@
package packet
import (
"big"
"crypto/dsa"
"crypto/openpgp/elgamal"
error_ "crypto/openpgp/error"
......@@ -15,6 +14,7 @@ import (
"fmt"
"hash"
"io"
"math/big"
"strconv"
)
......
......@@ -6,8 +6,8 @@ package s2k
import (
"bytes"
"crypto/sha1"
"crypto/rand"
"crypto/sha1"
"encoding/hex"
"testing"
)
......
......@@ -5,8 +5,8 @@
package rand
import (
"big"
"io"
"math/big"
"os"
)
......
......@@ -5,11 +5,11 @@
package rsa
import (
"big"
"crypto"
"crypto/subtle"
"errors"
"io"
"math/big"
)
// This file implements encryption and decryption using PKCS#1 v1.5 padding.
......
......@@ -5,7 +5,6 @@
package rsa
import (
"big"
"bytes"
"crypto"
"crypto/rand"
......@@ -13,6 +12,7 @@ import (
"encoding/base64"
"encoding/hex"
"io"
"math/big"
"testing"
"testing/quick"
)
......
......@@ -8,12 +8,12 @@ package rsa
// TODO(agl): Add support for PSS padding.
import (
"big"
"crypto/rand"
"crypto/subtle"
"errors"
"hash"
"io"
"math/big"
)
var bigZero = big.NewInt(0)
......
......@@ -5,10 +5,10 @@
package rsa
import (
"big"
"bytes"
"crypto/rand"
"crypto/sha1"
"math/big"
"testing"
)
......
......@@ -471,7 +471,7 @@ Again:
// RFC suggests that EOF without an alertCloseNotify is
// an error, but popular web sites seem to do this,
// so we can't make it an error.
// if err == os.EOF {
// if err == io.EOF {
// err = io.ErrUnexpectedEOF
// }
if e, ok := err.(net.Error); !ok || !e.Temporary() {
......
......@@ -8,14 +8,14 @@
package main
import (
"big"
"crypto/x509/pkix"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"flag"
"log"
"math/big"
"os"
"time"
)
......
......@@ -5,7 +5,7 @@
package tls
import (
"rand"
"math/rand"
"reflect"
"testing"
"testing/quick"
......
......@@ -5,12 +5,12 @@
package tls
import (
"big"
"bytes"
"crypto/rsa"
"encoding/hex"
"flag"
"io"
"math/big"
"net"
"strconv"
"strings"
......
......@@ -5,7 +5,6 @@
package tls
import (
"big"
"crypto"
"crypto/elliptic"
"crypto/md5"
......@@ -14,6 +13,7 @@ import (
"crypto/x509"
"errors"
"io"
"math/big"
)
// rsaKeyAgreement implements the standard TLS key agreement where the client
......
......@@ -5,10 +5,10 @@
package x509
import (
"asn1"
"big"
"errors"
"crypto/rsa"
"encoding/asn1"
"errors"
"math/big"
)
// pkcs1PrivateKey is a structure which mirrors the PKCS#1 ASN.1 for an RSA private key.
......
......@@ -7,8 +7,8 @@
package pkix
import (
"asn1"
"big"
"encoding/asn1"
"math/big"
"time"
)
......
......@@ -6,17 +6,17 @@
package x509
import (
"asn1"
"big"
"bytes"
"crypto"
"crypto/dsa"
"crypto/rsa"
"crypto/sha1"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/pem"
"errors"
"io"
"math/big"
"time"
)
......
......@@ -5,16 +5,16 @@
package x509
import (
"asn1"
"big"
"bytes"
"crypto/dsa"
"crypto/rand"
"crypto/rsa"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/base64"
"encoding/hex"
"encoding/pem"
"math/big"
"testing"
"time"
)
......
......@@ -7,8 +7,8 @@ package gosym
import (
"debug/elf"
"os"
"testing"
"syscall"
"testing"
)
func dotest() bool {
......
......@@ -20,8 +20,8 @@ package asn1
// everything by any means.
import (
"big"
"fmt"
"math/big"
"reflect"
"time"
)
......
......@@ -5,10 +5,10 @@
package asn1
import (
"big"
"bytes"
"fmt"
"io"
"math/big"
"reflect"
"time"
)
......
......@@ -9,8 +9,8 @@ package binary
import (
"errors"
"math"
"io"
"math"
"reflect"
)
......
......@@ -7,7 +7,6 @@ package binary
import (
"bytes"
"io"
"bytes"
"math"
"reflect"
"testing"
......
......@@ -9,7 +9,7 @@ import (
"io"
"strings"
"unicode"
"utf8"
"unicode/utf8"
)
// A Writer writes records to a CSV encoded file.
......
package main
// Need to compile package gob with debug.go to build this program.
import (
"encoding/gob"
"fmt"
"os"
)
func main() {
var err error
file := os.Stdin
if len(os.Args) > 1 {
file, err = os.Open(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "dump: %s\n", err)
os.Exit(1)
}
}
gob.Debug(file)
}
......@@ -11,7 +11,7 @@ import (
"reflect"
"sync"
"unicode"
"utf8"
"unicode/utf8"
)
// userTypeInfo stores the information associated with a type the user has handed
......@@ -703,18 +703,19 @@ func RegisterName(name string, value interface{}) {
// reserved for nil
panic("attempt to register empty name")
}
base := userType(reflect.TypeOf(value)).base
// Check for incompatible duplicates.
if t, ok := nameToConcreteType[name]; ok && t != base {
panic("gob: registering duplicate types for " + name)
ut := userType(reflect.TypeOf(value))
// Check for incompatible duplicates. The name must refer to the
// same user type, and vice versa.
if t, ok := nameToConcreteType[name]; ok && t != ut.user {
panic(fmt.Sprintf("gob: registering duplicate types for %q: %s != %s", name, t, ut.user))
}
if n, ok := concreteTypeToName[base]; ok && n != name {
panic("gob: registering duplicate names for " + base.String())
if n, ok := concreteTypeToName[ut.base]; ok && n != name {
panic(fmt.Sprintf("gob: registering duplicate names for %s: %q != %q", ut.user, n, name))
}
// Store the name and type provided by the user....
nameToConcreteType[name] = reflect.TypeOf(value)
// but the flattened type in the type table, since that's what decode needs.
concreteTypeToName[base] = name
concreteTypeToName[ut.base] = name
}
// Register records a type, identified by a value for that type, under its
......
......@@ -151,3 +151,11 @@ func TestStructType(t *testing.T) {
t.Errorf("struct printed as %q; expected %q", str, expected)
}
}
// Should be OK to register the same type multiple times, as long as they're
// at the same level of indirection.
func TestRegistration(t *testing.T) {
type T struct{ a int }
Register(new(T))
Register(new(T))
}
......@@ -15,8 +15,8 @@ import (
"strconv"
"strings"
"unicode"
"utf16"
"utf8"
"unicode/utf16"
"unicode/utf8"
)
// Unmarshal parses the JSON-encoded data and stores the result
......
......@@ -17,7 +17,7 @@ import (
"sort"
"strconv"
"unicode"
"utf8"
"unicode/utf8"
)
// Marshal returns the JSON encoding of v.
......
......@@ -7,7 +7,7 @@ package json
import (
"bytes"
"math"
"rand"
"math/rand"
"reflect"
"testing"
)
......@@ -147,7 +147,7 @@ var indentErrorTests = []indentErrorTest{
{`{"X": "foo" "Y": "bar"}`, &SyntaxError{"invalid character '\"' after object key:value pair", 13}},
}
func TestIdentErrors(t *testing.T) {
func TestIndentErrors(t *testing.T) {
for i, tt := range indentErrorTests {
slice := make([]uint8, 0)
buf := bytes.NewBuffer(slice)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment