aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/exp
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-02 19:34:41 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-02 19:34:41 +0000
commit506cf9aaead4f5519f5549a918d285365b44e989 (patch)
treefe0344f264049738dca876a6dd2f69e96621ca17 /libgo/go/exp
parentbfa9b58039ceacb1bae803fbbfb049b93540f2a7 (diff)
downloadgcc-506cf9aaead4f5519f5549a918d285365b44e989.zip
gcc-506cf9aaead4f5519f5549a918d285365b44e989.tar.gz
gcc-506cf9aaead4f5519f5549a918d285365b44e989.tar.bz2
libgo: Update to weekly.2011-11-01.
From-SVN: r181938
Diffstat (limited to 'libgo/go/exp')
-rw-r--r--libgo/go/exp/ebnf/ebnf.go2
-rw-r--r--libgo/go/exp/ebnf/parser.go4
-rw-r--r--libgo/go/exp/gui/x11/conn.go6
-rw-r--r--libgo/go/exp/norm/composition.go24
-rw-r--r--libgo/go/exp/norm/composition_test.go62
-rw-r--r--libgo/go/exp/norm/maketables.go56
-rw-r--r--libgo/go/exp/norm/maketesttables.go2
-rw-r--r--libgo/go/exp/norm/normalize_test.go8
-rw-r--r--libgo/go/exp/norm/normregtest.go22
-rw-r--r--libgo/go/exp/norm/trie_test.go12
-rw-r--r--libgo/go/exp/norm/triedata_test.go2
-rw-r--r--libgo/go/exp/norm/triegen.go4
-rw-r--r--libgo/go/exp/sql/convert_test.go2
-rw-r--r--libgo/go/exp/ssh/client.go90
-rw-r--r--libgo/go/exp/ssh/messages.go17
-rw-r--r--libgo/go/exp/ssh/server.go130
-rw-r--r--libgo/go/exp/template/html/css.go40
-rw-r--r--libgo/go/exp/template/html/css_test.go6
-rw-r--r--libgo/go/exp/template/html/escape_test.go12
-rw-r--r--libgo/go/exp/template/html/html.go2
-rw-r--r--libgo/go/exp/template/html/js.go16
-rw-r--r--libgo/go/exp/types/exportdata.go6
-rw-r--r--libgo/go/exp/types/gcimporter.go10
-rw-r--r--libgo/go/exp/types/testdata/test0.src154
-rw-r--r--libgo/go/exp/types/universe.go1
-rw-r--r--libgo/go/exp/winfsnotify/winfsnotify_test.go2
26 files changed, 432 insertions, 260 deletions
diff --git a/libgo/go/exp/ebnf/ebnf.go b/libgo/go/exp/ebnf/ebnf.go
index 2ec7f00..7070cc7 100644
--- a/libgo/go/exp/ebnf/ebnf.go
+++ b/libgo/go/exp/ebnf/ebnf.go
@@ -163,7 +163,7 @@ func (v *verifier) push(prod *Production) {
}
}
-func (v *verifier) verifyChar(x *Token) int {
+func (v *verifier) verifyChar(x *Token) rune {
s := x.String
if utf8.RuneCountInString(s) != 1 {
v.error(x.Pos(), "single char expected, found "+s)
diff --git a/libgo/go/exp/ebnf/parser.go b/libgo/go/exp/ebnf/parser.go
index 2dbbefb..dac5dd8 100644
--- a/libgo/go/exp/ebnf/parser.go
+++ b/libgo/go/exp/ebnf/parser.go
@@ -15,7 +15,7 @@ type parser struct {
errors errorList
scanner scanner.Scanner
pos scanner.Position // token position
- tok int // one token look-ahead
+ tok rune // one token look-ahead
lit string // token literal
}
@@ -42,7 +42,7 @@ func (p *parser) errorExpected(pos scanner.Position, msg string) {
p.error(pos, msg)
}
-func (p *parser) expect(tok int) scanner.Position {
+func (p *parser) expect(tok rune) scanner.Position {
pos := p.pos
if p.tok != tok {
p.errorExpected(pos, scanner.TokenString(tok))
diff --git a/libgo/go/exp/gui/x11/conn.go b/libgo/go/exp/gui/x11/conn.go
index bf94bca..f4a453e 100644
--- a/libgo/go/exp/gui/x11/conn.go
+++ b/libgo/go/exp/gui/x11/conn.go
@@ -87,7 +87,7 @@ func (c *conn) writeSocket() {
setU32LE(c.flushBuf0[16:20], uint32(y<<16))
if _, err := c.w.Write(c.flushBuf0[:24]); err != nil {
if err != os.EOF {
- log.Println("x11:", err.String())
+ log.Println("x11:", err)
}
return
}
@@ -106,7 +106,7 @@ func (c *conn) writeSocket() {
x += nx
if _, err := c.w.Write(c.flushBuf1[:nx]); err != nil {
if err != os.EOF {
- log.Println("x11:", err.String())
+ log.Println("x11:", err)
}
return
}
@@ -114,7 +114,7 @@ func (c *conn) writeSocket() {
}
if err := c.w.Flush(); err != nil {
if err != os.EOF {
- log.Println("x11:", err.String())
+ log.Println("x11:", err)
}
return
}
diff --git a/libgo/go/exp/norm/composition.go b/libgo/go/exp/norm/composition.go
index 1d72223..7965ffc 100644
--- a/libgo/go/exp/norm/composition.go
+++ b/libgo/go/exp/norm/composition.go
@@ -126,26 +126,26 @@ func (rb *reorderBuffer) insert(src input, i int, info runeInfo) bool {
}
// appendRune inserts a rune at the end of the buffer. It is used for Hangul.
-func (rb *reorderBuffer) appendRune(rune uint32) {
+func (rb *reorderBuffer) appendRune(r uint32) {
bn := rb.nbyte
- sz := utf8.EncodeRune(rb.byte[bn:], int(rune))
+ sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.nbyte += utf8.UTFMax
rb.rune[rb.nrune] = runeInfo{bn, uint8(sz), 0, 0}
rb.nrune++
}
// assignRune sets a rune at position pos. It is used for Hangul and recomposition.
-func (rb *reorderBuffer) assignRune(pos int, rune uint32) {
+func (rb *reorderBuffer) assignRune(pos int, r uint32) {
bn := rb.rune[pos].pos
- sz := utf8.EncodeRune(rb.byte[bn:], int(rune))
+ sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.rune[pos] = runeInfo{bn, uint8(sz), 0, 0}
}
// runeAt returns the rune at position n. It is used for Hangul and recomposition.
func (rb *reorderBuffer) runeAt(n int) uint32 {
inf := rb.rune[n]
- rune, _ := utf8.DecodeRune(rb.byte[inf.pos : inf.pos+inf.size])
- return uint32(rune)
+ r, _ := utf8.DecodeRune(rb.byte[inf.pos : inf.pos+inf.size])
+ return uint32(r)
}
// bytesAt returns the UTF-8 encoding of the rune at position n.
@@ -237,17 +237,17 @@ func isHangulWithoutJamoT(b []byte) bool {
// decomposeHangul algorithmically decomposes a Hangul rune into
// its Jamo components.
// See http://unicode.org/reports/tr15/#Hangul for details on decomposing Hangul.
-func (rb *reorderBuffer) decomposeHangul(rune uint32) bool {
+func (rb *reorderBuffer) decomposeHangul(r uint32) bool {
b := rb.rune[:]
n := rb.nrune
if n+3 > len(b) {
return false
}
- rune -= hangulBase
- x := rune % jamoTCount
- rune /= jamoTCount
- rb.appendRune(jamoLBase + rune/jamoVCount)
- rb.appendRune(jamoVBase + rune%jamoVCount)
+ r -= hangulBase
+ x := r % jamoTCount
+ r /= jamoTCount
+ rb.appendRune(jamoLBase + r/jamoVCount)
+ rb.appendRune(jamoVBase + r%jamoVCount)
if x != 0 {
rb.appendRune(jamoTBase + x)
}
diff --git a/libgo/go/exp/norm/composition_test.go b/libgo/go/exp/norm/composition_test.go
index ce9caaf..e32380d 100644
--- a/libgo/go/exp/norm/composition_test.go
+++ b/libgo/go/exp/norm/composition_test.go
@@ -8,14 +8,14 @@ import "testing"
// TestCase is used for most tests.
type TestCase struct {
- in []int
- out []int
+ in []rune
+ out []rune
}
-type insertFunc func(rb *reorderBuffer, rune int) bool
+type insertFunc func(rb *reorderBuffer, r rune) bool
-func insert(rb *reorderBuffer, rune int) bool {
- src := inputString(string(rune))
+func insert(rb *reorderBuffer, r rune) bool {
+ src := inputString(string(r))
return rb.insert(src, 0, rb.f.info(src, 0))
}
@@ -39,7 +39,7 @@ func runTests(t *testing.T, name string, fm Form, f insertFunc, tests []TestCase
continue
}
for j, want := range test.out {
- found := int(rb.runeAt(j))
+ found := rune(rb.runeAt(j))
if found != want {
t.Errorf("%s:%d: runeAt(%d) = %U; want %U", name, i, j, found, want)
}
@@ -57,7 +57,7 @@ func TestFlush(t *testing.T) {
t.Errorf("wrote bytes on flush of empty buffer. (len(out) = %d)", len(out))
}
- for _, r := range []int("world!") {
+ for _, r := range []rune("world!") {
insert(&rb, r)
}
@@ -76,14 +76,14 @@ func TestFlush(t *testing.T) {
}
var insertTests = []TestCase{
- {[]int{'a'}, []int{'a'}},
- {[]int{0x300}, []int{0x300}},
- {[]int{0x300, 0x316}, []int{0x316, 0x300}}, // CCC(0x300)==230; CCC(0x316)==220
- {[]int{0x316, 0x300}, []int{0x316, 0x300}},
- {[]int{0x41, 0x316, 0x300}, []int{0x41, 0x316, 0x300}},
- {[]int{0x41, 0x300, 0x316}, []int{0x41, 0x316, 0x300}},
- {[]int{0x300, 0x316, 0x41}, []int{0x316, 0x300, 0x41}},
- {[]int{0x41, 0x300, 0x40, 0x316}, []int{0x41, 0x300, 0x40, 0x316}},
+ {[]rune{'a'}, []rune{'a'}},
+ {[]rune{0x300}, []rune{0x300}},
+ {[]rune{0x300, 0x316}, []rune{0x316, 0x300}}, // CCC(0x300)==230; CCC(0x316)==220
+ {[]rune{0x316, 0x300}, []rune{0x316, 0x300}},
+ {[]rune{0x41, 0x316, 0x300}, []rune{0x41, 0x316, 0x300}},
+ {[]rune{0x41, 0x300, 0x316}, []rune{0x41, 0x316, 0x300}},
+ {[]rune{0x300, 0x316, 0x41}, []rune{0x316, 0x300, 0x41}},
+ {[]rune{0x41, 0x300, 0x40, 0x316}, []rune{0x41, 0x300, 0x40, 0x316}},
}
func TestInsert(t *testing.T) {
@@ -91,18 +91,18 @@ func TestInsert(t *testing.T) {
}
var decompositionNFDTest = []TestCase{
- {[]int{0xC0}, []int{0x41, 0x300}},
- {[]int{0xAC00}, []int{0x1100, 0x1161}},
- {[]int{0x01C4}, []int{0x01C4}},
- {[]int{0x320E}, []int{0x320E}},
- {[]int("음ẻ과"), []int{0x110B, 0x1173, 0x11B7, 0x65, 0x309, 0x1100, 0x116A}},
+ {[]rune{0xC0}, []rune{0x41, 0x300}},
+ {[]rune{0xAC00}, []rune{0x1100, 0x1161}},
+ {[]rune{0x01C4}, []rune{0x01C4}},
+ {[]rune{0x320E}, []rune{0x320E}},
+ {[]rune("음ẻ과"), []rune{0x110B, 0x1173, 0x11B7, 0x65, 0x309, 0x1100, 0x116A}},
}
var decompositionNFKDTest = []TestCase{
- {[]int{0xC0}, []int{0x41, 0x300}},
- {[]int{0xAC00}, []int{0x1100, 0x1161}},
- {[]int{0x01C4}, []int{0x44, 0x5A, 0x030C}},
- {[]int{0x320E}, []int{0x28, 0x1100, 0x1161, 0x29}},
+ {[]rune{0xC0}, []rune{0x41, 0x300}},
+ {[]rune{0xAC00}, []rune{0x1100, 0x1161}},
+ {[]rune{0x01C4}, []rune{0x44, 0x5A, 0x030C}},
+ {[]rune{0x320E}, []rune{0x28, 0x1100, 0x1161, 0x29}},
}
func TestDecomposition(t *testing.T) {
@@ -111,15 +111,15 @@ func TestDecomposition(t *testing.T) {
}
var compositionTest = []TestCase{
- {[]int{0x41, 0x300}, []int{0xC0}},
- {[]int{0x41, 0x316}, []int{0x41, 0x316}},
- {[]int{0x41, 0x300, 0x35D}, []int{0xC0, 0x35D}},
- {[]int{0x41, 0x316, 0x300}, []int{0xC0, 0x316}},
+ {[]rune{0x41, 0x300}, []rune{0xC0}},
+ {[]rune{0x41, 0x316}, []rune{0x41, 0x316}},
+ {[]rune{0x41, 0x300, 0x35D}, []rune{0xC0, 0x35D}},
+ {[]rune{0x41, 0x316, 0x300}, []rune{0xC0, 0x316}},
// blocking starter
- {[]int{0x41, 0x316, 0x40, 0x300}, []int{0x41, 0x316, 0x40, 0x300}},
- {[]int{0x1100, 0x1161}, []int{0xAC00}},
+ {[]rune{0x41, 0x316, 0x40, 0x300}, []rune{0x41, 0x316, 0x40, 0x300}},
+ {[]rune{0x1100, 0x1161}, []rune{0xAC00}},
// parenthesized Hangul, alternate between ASCII and Hangul.
- {[]int{0x28, 0x1100, 0x1161, 0x29}, []int{0x28, 0xAC00, 0x29}},
+ {[]rune{0x28, 0x1100, 0x1161, 0x29}, []rune{0x28, 0xAC00, 0x29}},
}
func TestComposition(t *testing.T) {
diff --git a/libgo/go/exp/norm/maketables.go b/libgo/go/exp/norm/maketables.go
index 14718c5..93edf22 100644
--- a/libgo/go/exp/norm/maketables.go
+++ b/libgo/go/exp/norm/maketables.go
@@ -119,7 +119,7 @@ const (
// This contains only the properties we're interested in.
type Char struct {
name string
- codePoint int // if zero, this index is not a valid code point.
+ codePoint rune // if zero, this index is not a valid code point.
ccc uint8 // canonical combining class
excludeInComp bool // from CompositionExclusions.txt
compatDecomp bool // it has a compatibility expansion
@@ -160,7 +160,7 @@ const (
SMissing
)
-var lastChar int = 0
+var lastChar = rune('\u0000')
func (c Char) isValid() bool {
return c.codePoint != 0 && c.state != SMissing
@@ -193,7 +193,7 @@ func (f FormInfo) String() string {
return buf.String()
}
-type Decomposition []int
+type Decomposition []rune
func (d Decomposition) String() string {
return fmt.Sprintf("%.4X", d)
@@ -220,7 +220,7 @@ func openReader(file string) (input io.ReadCloser) {
return
}
-func parseDecomposition(s string, skipfirst bool) (a []int, e os.Error) {
+func parseDecomposition(s string, skipfirst bool) (a []rune, e os.Error) {
decomp := strings.Split(s, " ")
if len(decomp) > 0 && skipfirst {
decomp = decomp[1:]
@@ -230,7 +230,7 @@ func parseDecomposition(s string, skipfirst bool) (a []int, e os.Error) {
if err != nil {
return a, err
}
- a = append(a, int(point))
+ a = append(a, rune(point))
}
return a, nil
}
@@ -260,7 +260,7 @@ func parseCharacter(line string) {
state = SLast
}
firstChar := lastChar + 1
- lastChar = int(point)
+ lastChar = rune(point)
if state != SLast {
firstChar = lastChar
}
@@ -370,8 +370,8 @@ func loadCompositionExclusions() {
// hasCompatDecomp returns true if any of the recursive
// decompositions contains a compatibility expansion.
// In this case, the character may not occur in NFK*.
-func hasCompatDecomp(rune int) bool {
- c := &chars[rune]
+func hasCompatDecomp(r rune) bool {
+ c := &chars[r]
if c.compatDecomp {
return true
}
@@ -396,19 +396,19 @@ const (
JamoTEnd = 0x11C3
)
-func isHangul(rune int) bool {
- return HangulBase <= rune && rune < HangulEnd
+func isHangul(r rune) bool {
+ return HangulBase <= r && r < HangulEnd
}
-func ccc(rune int) uint8 {
- return chars[rune].ccc
+func ccc(r rune) uint8 {
+ return chars[r].ccc
}
// Insert a rune in a buffer, ordered by Canonical Combining Class.
-func insertOrdered(b Decomposition, rune int) Decomposition {
+func insertOrdered(b Decomposition, r rune) Decomposition {
n := len(b)
b = append(b, 0)
- cc := ccc(rune)
+ cc := ccc(r)
if cc > 0 {
// Use bubble sort.
for ; n > 0; n-- {
@@ -418,18 +418,18 @@ func insertOrdered(b Decomposition, rune int) Decomposition {
b[n] = b[n-1]
}
}
- b[n] = rune
+ b[n] = r
return b
}
// Recursively decompose.
-func decomposeRecursive(form int, rune int, d Decomposition) Decomposition {
- if isHangul(rune) {
+func decomposeRecursive(form int, r rune, d Decomposition) Decomposition {
+ if isHangul(r) {
return d
}
- dcomp := chars[rune].forms[form].decomp
+ dcomp := chars[r].forms[form].decomp
if len(dcomp) == 0 {
- return insertOrdered(d, rune)
+ return insertOrdered(d, r)
}
for _, c := range dcomp {
d = decomposeRecursive(form, c, d)
@@ -475,8 +475,8 @@ func completeCharFields(form int) {
f.isOneWay = f.isOneWay || hasCompatDecomp(c.codePoint)
}
- for _, rune := range f.decomp {
- chars[rune].forms[form].inDecomp = true
+ for _, r := range f.decomp {
+ chars[r].forms[form].inDecomp = true
}
}
@@ -505,7 +505,7 @@ func completeCharFields(form int) {
switch {
case len(f.decomp) > 0:
f.quickCheck[MDecomposed] = QCNo
- case isHangul(i):
+ case isHangul(rune(i)):
f.quickCheck[MDecomposed] = QCNo
default:
f.quickCheck[MDecomposed] = QCYes
@@ -588,7 +588,7 @@ func printCharInfoTables() int {
for i, char := range chars {
v := makeCharInfo(char)
if v != 0 {
- t.insert(i, v)
+ t.insert(rune(i), v)
}
}
return t.printTables("charInfo")
@@ -606,7 +606,7 @@ func printDecompositionTables() int {
for _, c := range chars {
for f := 0; f < 2; f++ {
d := c.forms[f].expandedDecomp
- s := string([]int(d))
+ s := string([]rune(d))
if _, ok := positionMap[s]; !ok {
p := decompositions.Len()
decompositions.WriteByte(uint8(len(s)))
@@ -624,7 +624,7 @@ func printDecompositionTables() int {
for i, c := range chars {
d := c.forms[FCanonical].expandedDecomp
if len(d) != 0 {
- nfcT.insert(i, positionMap[string([]int(d))])
+ nfcT.insert(rune(i), positionMap[string([]rune(d))])
if ccc(c.codePoint) != ccc(d[0]) {
// We assume the lead ccc of a decomposition is !=0 in this case.
if ccc(d[0]) == 0 {
@@ -634,7 +634,7 @@ func printDecompositionTables() int {
}
d = c.forms[FCompatibility].expandedDecomp
if len(d) != 0 {
- nfkcT.insert(i, positionMap[string([]int(d))])
+ nfkcT.insert(rune(i), positionMap[string([]rune(d))])
if ccc(c.codePoint) != ccc(d[0]) {
// We assume the lead ccc of a decomposition is !=0 in this case.
if ccc(d[0]) == 0 {
@@ -752,7 +752,7 @@ func verifyComputed() {
for i, c := range chars {
for _, f := range c.forms {
isNo := (f.quickCheck[MDecomposed] == QCNo)
- if (len(f.decomp) > 0) != isNo && !isHangul(i) {
+ if (len(f.decomp) > 0) != isNo && !isHangul(rune(i)) {
log.Fatalf("%U: NF*D must be no if rune decomposes", i)
}
@@ -764,7 +764,7 @@ func verifyComputed() {
}
}
-var qcRe = regexp.MustCompile(`^([0-9A-F\.]+) *; (NF.*_QC); ([YNM]) #.*$`)
+var qcRe = regexp.MustCompile(`([0-9A-F\.]+) *; (NF.*_QC); ([YNM]) #.*`)
// Use values in DerivedNormalizationProps.txt to compare against the
// values we computed.
diff --git a/libgo/go/exp/norm/maketesttables.go b/libgo/go/exp/norm/maketesttables.go
index fdcc114..20eb889 100644
--- a/libgo/go/exp/norm/maketesttables.go
+++ b/libgo/go/exp/norm/maketesttables.go
@@ -16,7 +16,7 @@ func main() {
// We take the smallest, largest and an arbitrary value for each
// of the UTF-8 sequence lengths.
-var testRunes = []int{
+var testRunes = []rune{
0x01, 0x0C, 0x7F, // 1-byte sequences
0x80, 0x100, 0x7FF, // 2-byte sequences
0x800, 0x999, 0xFFFF, // 3-byte sequences
diff --git a/libgo/go/exp/norm/normalize_test.go b/libgo/go/exp/norm/normalize_test.go
index e374edf..6bd5292 100644
--- a/libgo/go/exp/norm/normalize_test.go
+++ b/libgo/go/exp/norm/normalize_test.go
@@ -28,13 +28,13 @@ func runPosTests(t *testing.T, name string, f Form, fn positionFunc, tests []Pos
if pos != test.pos {
t.Errorf("%s:%d: position is %d; want %d", name, i, pos, test.pos)
}
- runes := []int(test.buffer)
+ runes := []rune(test.buffer)
if rb.nrune != len(runes) {
t.Errorf("%s:%d: reorder buffer lenght is %d; want %d", name, i, rb.nrune, len(runes))
continue
}
for j, want := range runes {
- found := int(rb.runeAt(j))
+ found := rune(rb.runeAt(j))
if found != want {
t.Errorf("%s:%d: rune at %d is %U; want %U", name, i, j, found, want)
}
@@ -385,8 +385,8 @@ func runAppendTests(t *testing.T, name string, f Form, fn appendFunc, tests []Ap
}
if outs != test.out {
// Find first rune that differs and show context.
- ir := []int(outs)
- ig := []int(test.out)
+ ir := []rune(outs)
+ ig := []rune(test.out)
for j := 0; j < len(ir) && j < len(ig); j++ {
if ir[j] == ig[j] {
continue
diff --git a/libgo/go/exp/norm/normregtest.go b/libgo/go/exp/norm/normregtest.go
index cbd73ff..e747dde 100644
--- a/libgo/go/exp/norm/normregtest.go
+++ b/libgo/go/exp/norm/normregtest.go
@@ -16,8 +16,8 @@ import (
"path"
"regexp"
"runtime"
- "strings"
"strconv"
+ "strings"
"time"
"utf8"
)
@@ -103,7 +103,7 @@ type Test struct {
name string
partnr int
number int
- rune int // used for character by character test
+ r rune // used for character by character test
cols [cMaxColumns]string // Each has 5 entries, see below.
}
@@ -174,12 +174,12 @@ func loadTestData() {
if err != nil {
logger.Fatal(err)
}
- if test.rune == 0 {
+ if test.r == 0 {
// save for CharacterByCharacterTests
- test.rune = int(r)
+ test.r = int(r)
}
var buf [utf8.UTFMax]byte
- sz := utf8.EncodeRune(buf[:], int(r))
+ sz := utf8.EncodeRune(buf[:], rune(r))
test.cols[j-1] += string(buf[:sz])
}
}
@@ -198,7 +198,7 @@ func cmpResult(t *Test, name string, f norm.Form, gold, test, result string) {
if errorCount > 20 {
return
}
- st, sr, sg := []int(test), []int(result), []int(gold)
+ st, sr, sg := []rune(test), []rune(result), []rune(gold)
logger.Printf("%s:%s: %s(%X)=%X; want:%X: %s",
t.Name(), name, fstr[f], st, sr, sg, t.name)
}
@@ -210,7 +210,7 @@ func cmpIsNormal(t *Test, name string, f norm.Form, test string, result, want bo
if errorCount > 20 {
return
}
- logger.Printf("%s:%s: %s(%X)=%v; want: %v", t.Name(), name, fstr[f], []int(test), result, want)
+ logger.Printf("%s:%s: %s(%X)=%v; want: %v", t.Name(), name, fstr[f], []rune(test), result, want)
}
}
@@ -243,13 +243,13 @@ func CharacterByCharacterTests() {
tests := part[1].tests
last := 0
for i := 0; i <= len(tests); i++ { // last one is special case
- var rune int
+ var r int
if i == len(tests) {
- rune = 0x2FA1E // Don't have to go to 0x10FFFF
+ r = 0x2FA1E // Don't have to go to 0x10FFFF
} else {
- rune = tests[i].rune
+ r = tests[i].r
}
- for last++; last < rune; last++ {
+ for last++; last < r; last++ {
// Check all characters that were not explicitly listed in the test.
t := &Test{partnr: 1, number: -1}
char := string(last)
diff --git a/libgo/go/exp/norm/trie_test.go b/libgo/go/exp/norm/trie_test.go
index 5649fb7..bbd5c03 100644
--- a/libgo/go/exp/norm/trie_test.go
+++ b/libgo/go/exp/norm/trie_test.go
@@ -73,15 +73,15 @@ var tests = []trietest{
{1, []byte{t6, tx, tx, tx, tx, tx}},
}
-func mkUtf8(rune int) ([]byte, int) {
+func mkUTF8(r rune) ([]byte, int) {
var b [utf8.UTFMax]byte
- sz := utf8.EncodeRune(b[:], rune)
+ sz := utf8.EncodeRune(b[:], r)
return b[:sz], sz
}
func TestLookup(t *testing.T) {
for i, tt := range testRunes {
- b, szg := mkUtf8(tt)
+ b, szg := mkUTF8(tt)
v, szt := testdata.lookup(b)
if int(v) != i {
t.Errorf("lookup(%U): found value %#x, expected %#x", tt, v, i)
@@ -103,7 +103,7 @@ func TestLookup(t *testing.T) {
func TestLookupUnsafe(t *testing.T) {
for i, tt := range testRunes {
- b, _ := mkUtf8(tt)
+ b, _ := mkUTF8(tt)
v := testdata.lookupUnsafe(b)
if int(v) != i {
t.Errorf("lookupUnsafe(%U): found value %#x, expected %#x", i, v, i)
@@ -113,7 +113,7 @@ func TestLookupUnsafe(t *testing.T) {
func TestLookupString(t *testing.T) {
for i, tt := range testRunes {
- b, szg := mkUtf8(tt)
+ b, szg := mkUTF8(tt)
v, szt := testdata.lookupString(string(b))
if int(v) != i {
t.Errorf("lookup(%U): found value %#x, expected %#x", i, v, i)
@@ -135,7 +135,7 @@ func TestLookupString(t *testing.T) {
func TestLookupStringUnsafe(t *testing.T) {
for i, tt := range testRunes {
- b, _ := mkUtf8(tt)
+ b, _ := mkUTF8(tt)
v := testdata.lookupStringUnsafe(string(b))
if int(v) != i {
t.Errorf("lookupUnsafe(%U): found value %#x, expected %#x", i, v, i)
diff --git a/libgo/go/exp/norm/triedata_test.go b/libgo/go/exp/norm/triedata_test.go
index e8898e5..7f62760 100644
--- a/libgo/go/exp/norm/triedata_test.go
+++ b/libgo/go/exp/norm/triedata_test.go
@@ -4,7 +4,7 @@
package norm
-var testRunes = []int{1, 12, 127, 128, 256, 2047, 2048, 2457, 65535, 65536, 65793, 1114111, 512, 513, 514, 528, 533}
+var testRunes = []rune{1, 12, 127, 128, 256, 2047, 2048, 2457, 65535, 65536, 65793, 1114111, 512, 513, 514, 528, 533}
// testdataValues: 192 entries, 384 bytes
// Block 2 is the null block.
diff --git a/libgo/go/exp/norm/triegen.go b/libgo/go/exp/norm/triegen.go
index 515e1c7..56cba32 100644
--- a/libgo/go/exp/norm/triegen.go
+++ b/libgo/go/exp/norm/triegen.go
@@ -94,9 +94,9 @@ func (n trieNode) countSparseEntries() int {
return count
}
-func (n *trieNode) insert(rune int, value uint16) {
+func (n *trieNode) insert(r rune, value uint16) {
var p [utf8.UTFMax]byte
- sz := utf8.EncodeRune(p[:], rune)
+ sz := utf8.EncodeRune(p[:], r)
for i := 0; i < sz; i++ {
if n.leaf {
diff --git a/libgo/go/exp/sql/convert_test.go b/libgo/go/exp/sql/convert_test.go
index 88ba8e7..8499918 100644
--- a/libgo/go/exp/sql/convert_test.go
+++ b/libgo/go/exp/sql/convert_test.go
@@ -52,7 +52,7 @@ var conversionTests = []conversionTest{
{s: "256", d: &scanuint8, wanterr: `string "256" overflows uint8`},
{s: "256", d: &scanuint16, wantuint: 256},
{s: "-1", d: &scanint, wantint: -1},
- {s: "foo", d: &scanint, wanterr: `converting string "foo" to a int: parsing "foo": Invalid argument`},
+ {s: "foo", d: &scanint, wanterr: `converting string "foo" to a int: parsing "foo": invalid syntax`},
}
func intValue(intptr interface{}) int64 {
diff --git a/libgo/go/exp/ssh/client.go b/libgo/go/exp/ssh/client.go
index 3311385..9eed315 100644
--- a/libgo/go/exp/ssh/client.go
+++ b/libgo/go/exp/ssh/client.go
@@ -258,51 +258,71 @@ func (c *ClientConn) openChan(typ string) (*clientChan, os.Error) {
// mainloop reads incoming messages and routes channel messages
// to their respective ClientChans.
func (c *ClientConn) mainLoop() {
+ // TODO(dfc) signal the underlying close to all channels
+ defer c.Close()
for {
packet, err := c.readPacket()
if err != nil {
- // TODO(dfc) signal the underlying close to all channels
- c.Close()
- return
+ break
}
// TODO(dfc) A note on blocking channel use.
// The msg, win, data and dataExt channels of a clientChan can
// cause this loop to block indefinately if the consumer does
// not service them.
- switch msg := decode(packet).(type) {
- case *channelOpenMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *channelOpenConfirmMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *channelOpenFailureMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *channelCloseMsg:
- ch := c.getChan(msg.PeersId)
- close(ch.win)
- close(ch.data)
- close(ch.dataExt)
- c.chanlist.remove(msg.PeersId)
- case *channelEOFMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *channelRequestSuccessMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *channelRequestFailureMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *channelRequestMsg:
- c.getChan(msg.PeersId).msg <- msg
- case *windowAdjustMsg:
- c.getChan(msg.PeersId).win <- int(msg.AdditionalBytes)
- case *channelData:
- c.getChan(msg.PeersId).data <- msg.Payload
- case *channelExtendedData:
- // RFC 4254 5.2 defines data_type_code 1 to be data destined
- // for stderr on interactive sessions. Other data types are
- // silently discarded.
- if msg.Datatype == 1 {
- c.getChan(msg.PeersId).dataExt <- msg.Payload
+ switch packet[0] {
+ case msgChannelData:
+ if len(packet) < 9 {
+ // malformed data packet
+ break
+ }
+ peersId := uint32(packet[1])<<24 | uint32(packet[2])<<16 | uint32(packet[3])<<8 | uint32(packet[4])
+ if length := int(packet[5])<<24 | int(packet[6])<<16 | int(packet[7])<<8 | int(packet[8]); length > 0 {
+ packet = packet[9:]
+ c.getChan(peersId).data <- packet[:length]
+ }
+ case msgChannelExtendedData:
+ if len(packet) < 13 {
+ // malformed data packet
+ break
+ }
+ peersId := uint32(packet[1])<<24 | uint32(packet[2])<<16 | uint32(packet[3])<<8 | uint32(packet[4])
+ datatype := uint32(packet[5])<<24 | uint32(packet[6])<<16 | uint32(packet[7])<<8 | uint32(packet[8])
+ if length := int(packet[9])<<24 | int(packet[10])<<16 | int(packet[11])<<8 | int(packet[12]); length > 0 {
+ packet = packet[13:]
+ // RFC 4254 5.2 defines data_type_code 1 to be data destined
+ // for stderr on interactive sessions. Other data types are
+ // silently discarded.
+ if datatype == 1 {
+ c.getChan(peersId).dataExt <- packet[:length]
+ }
}
default:
- fmt.Printf("mainLoop: unhandled %#v\n", msg)
+ switch msg := decode(packet).(type) {
+ case *channelOpenMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *channelOpenConfirmMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *channelOpenFailureMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *channelCloseMsg:
+ ch := c.getChan(msg.PeersId)
+ close(ch.win)
+ close(ch.data)
+ close(ch.dataExt)
+ c.chanlist.remove(msg.PeersId)
+ case *channelEOFMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *channelRequestSuccessMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *channelRequestFailureMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *channelRequestMsg:
+ c.getChan(msg.PeersId).msg <- msg
+ case *windowAdjustMsg:
+ c.getChan(msg.PeersId).win <- int(msg.AdditionalBytes)
+ default:
+ fmt.Printf("mainLoop: unhandled %#v\n", msg)
+ }
}
}
}
diff --git a/libgo/go/exp/ssh/messages.go b/libgo/go/exp/ssh/messages.go
index 7771f2b..5f2c447 100644
--- a/libgo/go/exp/ssh/messages.go
+++ b/libgo/go/exp/ssh/messages.go
@@ -144,19 +144,6 @@ type channelOpenFailureMsg struct {
Language string
}
-// See RFC 4254, section 5.2.
-type channelData struct {
- PeersId uint32
- Payload []byte `ssh:"rest"`
-}
-
-// See RFC 4254, section 5.2.
-type channelExtendedData struct {
- PeersId uint32
- Datatype uint32
- Payload []byte `ssh:"rest"`
-}
-
type channelRequestMsg struct {
PeersId uint32
Request string
@@ -612,10 +599,6 @@ func decode(packet []byte) interface{} {
msg = new(channelOpenFailureMsg)
case msgChannelWindowAdjust:
msg = new(windowAdjustMsg)
- case msgChannelData:
- msg = new(channelData)
- case msgChannelExtendedData:
- msg = new(channelExtendedData)
case msgChannelEOF:
msg = new(channelEOFMsg)
case msgChannelClose:
diff --git a/libgo/go/exp/ssh/server.go b/libgo/go/exp/ssh/server.go
index 3a640fc..0dd24ec 100644
--- a/libgo/go/exp/ssh/server.go
+++ b/libgo/go/exp/ssh/server.go
@@ -581,75 +581,89 @@ func (s *ServerConn) Accept() (Channel, os.Error) {
return nil, err
}
- switch msg := decode(packet).(type) {
- case *channelOpenMsg:
- c := new(channel)
- c.chanType = msg.ChanType
- c.theirId = msg.PeersId
- c.theirWindow = msg.PeersWindow
- c.maxPacketSize = msg.MaxPacketSize
- c.extraData = msg.TypeSpecificData
- c.myWindow = defaultWindowSize
- c.serverConn = s
- c.cond = sync.NewCond(&c.lock)
- c.pendingData = make([]byte, c.myWindow)
-
- s.lock.Lock()
- c.myId = s.nextChanId
- s.nextChanId++
- s.channels[c.myId] = c
- s.lock.Unlock()
- return c, nil
-
- case *channelRequestMsg:
- s.lock.Lock()
- c, ok := s.channels[msg.PeersId]
- if !ok {
- continue
+ switch packet[0] {
+ case msgChannelData:
+ if len(packet) < 9 {
+ // malformed data packet
+ return nil, ParseError{msgChannelData}
}
- c.handlePacket(msg)
- s.lock.Unlock()
-
- case *channelData:
+ peersId := uint32(packet[1])<<24 | uint32(packet[2])<<16 | uint32(packet[3])<<8 | uint32(packet[4])
s.lock.Lock()
- c, ok := s.channels[msg.PeersId]
+ c, ok := s.channels[peersId]
if !ok {
+ s.lock.Unlock()
continue
}
- c.handleData(msg.Payload)
- s.lock.Unlock()
-
- case *channelEOFMsg:
- s.lock.Lock()
- c, ok := s.channels[msg.PeersId]
- if !ok {
- continue
+ if length := int(packet[5])<<24 | int(packet[6])<<16 | int(packet[7])<<8 | int(packet[8]); length > 0 {
+ packet = packet[9:]
+ c.handleData(packet[:length])
}
- c.handlePacket(msg)
s.lock.Unlock()
+ default:
+ switch msg := decode(packet).(type) {
+ case *channelOpenMsg:
+ c := new(channel)
+ c.chanType = msg.ChanType
+ c.theirId = msg.PeersId
+ c.theirWindow = msg.PeersWindow
+ c.maxPacketSize = msg.MaxPacketSize
+ c.extraData = msg.TypeSpecificData
+ c.myWindow = defaultWindowSize
+ c.serverConn = s
+ c.cond = sync.NewCond(&c.lock)
+ c.pendingData = make([]byte, c.myWindow)
+
+ s.lock.Lock()
+ c.myId = s.nextChanId
+ s.nextChanId++
+ s.channels[c.myId] = c
+ s.lock.Unlock()
+ return c, nil
+
+ case *channelRequestMsg:
+ s.lock.Lock()
+ c, ok := s.channels[msg.PeersId]
+ if !ok {
+ s.lock.Unlock()
+ continue
+ }
+ c.handlePacket(msg)
+ s.lock.Unlock()
- case *channelCloseMsg:
- s.lock.Lock()
- c, ok := s.channels[msg.PeersId]
- if !ok {
- continue
- }
- c.handlePacket(msg)
- s.lock.Unlock()
+ case *channelEOFMsg:
+ s.lock.Lock()
+ c, ok := s.channels[msg.PeersId]
+ if !ok {
+ s.lock.Unlock()
+ continue
+ }
+ c.handlePacket(msg)
+ s.lock.Unlock()
- case *globalRequestMsg:
- if msg.WantReply {
- if err := s.writePacket([]byte{msgRequestFailure}); err != nil {
- return nil, err
+ case *channelCloseMsg:
+ s.lock.Lock()
+ c, ok := s.channels[msg.PeersId]
+ if !ok {
+ s.lock.Unlock()
+ continue
}
- }
+ c.handlePacket(msg)
+ s.lock.Unlock()
- case UnexpectedMessageError:
- return nil, msg
- case *disconnectMsg:
- return nil, os.EOF
- default:
- // Unknown message. Ignore.
+ case *globalRequestMsg:
+ if msg.WantReply {
+ if err := s.writePacket([]byte{msgRequestFailure}); err != nil {
+ return nil, err
+ }
+ }
+
+ case UnexpectedMessageError:
+ return nil, msg
+ case *disconnectMsg:
+ return nil, os.EOF
+ default:
+ // Unknown message. Ignore.
+ }
}
}
diff --git a/libgo/go/exp/template/html/css.go b/libgo/go/exp/template/html/css.go
index c22ec6d..c26ae78 100644
--- a/libgo/go/exp/template/html/css.go
+++ b/libgo/go/exp/template/html/css.go
@@ -35,19 +35,19 @@ func endsWithCSSKeyword(b []byte, kw string) bool {
}
// isCSSNmchar returns whether rune is allowed anywhere in a CSS identifier.
-func isCSSNmchar(rune int) bool {
+func isCSSNmchar(r rune) bool {
// Based on the CSS3 nmchar production but ignores multi-rune escape
// sequences.
// http://www.w3.org/TR/css3-syntax/#SUBTOK-nmchar
- return 'a' <= rune && rune <= 'z' ||
- 'A' <= rune && rune <= 'Z' ||
- '0' <= rune && rune <= '9' ||
- '-' == rune ||
- '_' == rune ||
+ return 'a' <= r && r <= 'z' ||
+ 'A' <= r && r <= 'Z' ||
+ '0' <= r && r <= '9' ||
+ r == '-' ||
+ r == '_' ||
// Non-ASCII cases below.
- 0x80 <= rune && rune <= 0xd7ff ||
- 0xe000 <= rune && rune <= 0xfffd ||
- 0x10000 <= rune && rune <= 0x10ffff
+ 0x80 <= r && r <= 0xd7ff ||
+ 0xe000 <= r && r <= 0xfffd ||
+ 0x10000 <= r && r <= 0x10ffff
}
// decodeCSS decodes CSS3 escapes given a sequence of stringchars.
@@ -81,11 +81,11 @@ func decodeCSS(s []byte) []byte {
for j < len(s) && j < 7 && isHex(s[j]) {
j++
}
- rune := hexDecode(s[1:j])
- if rune > unicode.MaxRune {
- rune, j = rune/16, j-1
+ r := hexDecode(s[1:j])
+ if r > unicode.MaxRune {
+ r, j = r/16, j-1
}
- n := utf8.EncodeRune(b[len(b):cap(b)], rune)
+ n := utf8.EncodeRune(b[len(b):cap(b)], r)
// The optional space at the end allows a hex
// sequence to be followed by a literal hex.
// string(decodeCSS([]byte(`\A B`))) == "\nB"
@@ -105,17 +105,17 @@ func isHex(c byte) bool {
}
// hexDecode decodes a short hex digit sequence: "10" -> 16.
-func hexDecode(s []byte) int {
- n := 0
+func hexDecode(s []byte) rune {
+ n := rune(0)
for _, c := range s {
n <<= 4
switch {
case '0' <= c && c <= '9':
- n |= int(c - '0')
+ n |= rune(c - '0')
case 'a' <= c && c <= 'f':
- n |= int(c-'a') + 10
+ n |= rune(c-'a') + 10
case 'A' <= c && c <= 'F':
- n |= int(c-'A') + 10
+ n |= rune(c-'A') + 10
default:
panic(fmt.Sprintf("Bad hex digit in %q", s))
}
@@ -251,11 +251,11 @@ func cssValueFilter(args ...interface{}) string {
case '-':
// Disallow <!-- or -->.
// -- should not appear in valid identifiers.
- if i != 0 && '-' == b[i-1] {
+ if i != 0 && b[i-1] == '-' {
return filterFailsafe
}
default:
- if c < 0x80 && isCSSNmchar(int(c)) {
+ if c < 0x80 && isCSSNmchar(rune(c)) {
id = append(id, c)
}
}
diff --git a/libgo/go/exp/template/html/css_test.go b/libgo/go/exp/template/html/css_test.go
index 5f633e8..b3b83e8 100644
--- a/libgo/go/exp/template/html/css_test.go
+++ b/libgo/go/exp/template/html/css_test.go
@@ -35,7 +35,7 @@ func TestEndsWithCSSKeyword(t *testing.T) {
func TestIsCSSNmchar(t *testing.T) {
tests := []struct {
- rune int
+ rune rune
want bool
}{
{0, false},
@@ -114,11 +114,11 @@ func TestDecodeCSS(t *testing.T) {
func TestHexDecode(t *testing.T) {
for i := 0; i < 0x200000; i += 101 /* coprime with 16 */ {
s := strconv.Itob(i, 16)
- if got := hexDecode([]byte(s)); got != i {
+ if got := int(hexDecode([]byte(s))); got != i {
t.Errorf("%s: want %d but got %d", s, i, got)
}
s = strings.ToUpper(s)
- if got := hexDecode([]byte(s)); got != i {
+ if got := int(hexDecode([]byte(s))); got != i {
t.Errorf("%s: want %d but got %d", s, i, got)
}
}
diff --git a/libgo/go/exp/template/html/escape_test.go b/libgo/go/exp/template/html/escape_test.go
index a4ea759..1b3b256 100644
--- a/libgo/go/exp/template/html/escape_test.go
+++ b/libgo/go/exp/template/html/escape_test.go
@@ -1549,8 +1549,8 @@ func TestEnsurePipelineContains(t *testing.T) {
}
}
-func expectExecuteFailure(t *testing.T, b *bytes.Buffer) {
- if x := recover(); x != nil {
+func expectExecuteFailure(t *testing.T, b *bytes.Buffer, err os.Error) {
+ if err != nil {
if b.Len() != 0 {
t.Errorf("output on buffer: %q", b.String())
}
@@ -1563,8 +1563,8 @@ func TestEscapeErrorsNotIgnorable(t *testing.T) {
var b bytes.Buffer
tmpl := template.Must(template.New("dangerous").Parse("<a"))
Escape(tmpl)
- defer expectExecuteFailure(t, &b)
- tmpl.Execute(&b, nil)
+ err := tmpl.Execute(&b, nil)
+ expectExecuteFailure(t, &b, err)
}
func TestEscapeSetErrorsNotIgnorable(t *testing.T) {
@@ -1574,8 +1574,8 @@ func TestEscapeSetErrorsNotIgnorable(t *testing.T) {
}
EscapeSet(s, "t")
var b bytes.Buffer
- defer expectExecuteFailure(t, &b)
- s.Execute(&b, "t", nil)
+ err = s.Execute(&b, "t", nil)
+ expectExecuteFailure(t, &b, err)
}
func TestRedundantFuncs(t *testing.T) {
diff --git a/libgo/go/exp/template/html/html.go b/libgo/go/exp/template/html/html.go
index 91bb1b1..92d8f41 100644
--- a/libgo/go/exp/template/html/html.go
+++ b/libgo/go/exp/template/html/html.go
@@ -139,7 +139,7 @@ var htmlNospaceNormReplacementTable = []string{
func htmlReplacer(s string, replacementTable []string, badRunes bool) string {
written, b := 0, new(bytes.Buffer)
for i, r := range s {
- if r < len(replacementTable) {
+ if int(r) < len(replacementTable) {
if repl := replacementTable[r]; len(repl) != 0 {
b.WriteString(s[written:i])
b.WriteString(repl)
diff --git a/libgo/go/exp/template/html/js.go b/libgo/go/exp/template/html/js.go
index 98c2ac5..5646f8a 100644
--- a/libgo/go/exp/template/html/js.go
+++ b/libgo/go/exp/template/html/js.go
@@ -85,7 +85,7 @@ func nextJSCtx(s []byte, preceding jsCtx) jsCtx {
// Look for an IdentifierName and see if it is a keyword that
// can precede a regular expression.
j := n
- for j > 0 && isJSIdentPart(int(s[j-1])) {
+ for j > 0 && isJSIdentPart(rune(s[j-1])) {
j--
}
if regexpPrecederKeywords[string(s[j:])] {
@@ -234,7 +234,7 @@ func replace(s string, replacementTable []string) string {
for i, r := range s {
var repl string
switch {
- case r < len(replacementTable) && replacementTable[r] != "":
+ case int(r) < len(replacementTable) && replacementTable[r] != "":
repl = replacementTable[r]
case r == '\u2028':
repl = `\u2028`
@@ -329,17 +329,17 @@ var jsRegexpReplacementTable = []string{
// It does not handle all the non-Latin letters, joiners, and combining marks,
// but it does handle every codepoint that can occur in a numeric literal or
// a keyword.
-func isJSIdentPart(rune int) bool {
+func isJSIdentPart(r rune) bool {
switch {
- case '$' == rune:
+ case r == '$':
return true
- case '0' <= rune && rune <= '9':
+ case '0' <= r && r <= '9':
return true
- case 'A' <= rune && rune <= 'Z':
+ case 'A' <= r && r <= 'Z':
return true
- case '_' == rune:
+ case r == '_':
return true
- case 'a' <= rune && rune <= 'z':
+ case 'a' <= r && r <= 'z':
return true
}
return false
diff --git a/libgo/go/exp/types/exportdata.go b/libgo/go/exp/types/exportdata.go
index 3835203..784ffff 100644
--- a/libgo/go/exp/types/exportdata.go
+++ b/libgo/go/exp/types/exportdata.go
@@ -17,7 +17,7 @@ import (
func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
// See $GOROOT/include/ar.h.
- hdr := make([]byte, 64+12+6+6+8+10+2)
+ hdr := make([]byte, 16+12+6+6+8+10+2)
_, err = io.ReadFull(buf, hdr)
if err != nil {
return
@@ -25,13 +25,13 @@ func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
if trace {
fmt.Printf("header: %s", hdr)
}
- s := strings.TrimSpace(string(hdr[64+12+6+6+8:][:10]))
+ s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10]))
size, err = strconv.Atoi(s)
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
err = os.NewError("invalid archive header")
return
}
- name = strings.TrimSpace(string(hdr[:64]))
+ name = strings.TrimSpace(string(hdr[:16]))
return
}
diff --git a/libgo/go/exp/types/gcimporter.go b/libgo/go/exp/types/gcimporter.go
index e744a63..4e5172a 100644
--- a/libgo/go/exp/types/gcimporter.go
+++ b/libgo/go/exp/types/gcimporter.go
@@ -71,7 +71,7 @@ func findPkg(path string) (filename, id string) {
// object/archive file and populates its scope with the results.
type gcParser struct {
scanner scanner.Scanner
- tok int // current token
+ tok rune // current token
lit string // literal string; only valid for Ident, Int, String tokens
id string // package id of imported package
imports map[string]*ast.Object // package id -> package object
@@ -195,7 +195,7 @@ func (p *gcParser) errorf(format string, args ...interface{}) {
p.error(fmt.Sprintf(format, args...))
}
-func (p *gcParser) expect(tok int) string {
+func (p *gcParser) expect(tok rune) string {
lit := p.lit
if p.tok != tok {
p.errorf("expected %q, got %q (%q)", scanner.TokenString(tok), scanner.TokenString(p.tok), lit)
@@ -205,9 +205,9 @@ func (p *gcParser) expect(tok int) string {
}
func (p *gcParser) expectSpecial(tok string) {
- sep := 'x' // not white space
+ sep := rune('x') // not white space
i := 0
- for i < len(tok) && p.tok == int(tok[i]) && sep > ' ' {
+ for i < len(tok) && p.tok == rune(tok[i]) && sep > ' ' {
sep = p.scanner.Peek() // if sep <= ' ', there is white space before the next token
p.next()
i++
@@ -260,7 +260,7 @@ func (p *gcParser) parsePkgId() *ast.Object {
func (p *gcParser) parseDotIdent() string {
ident := ""
if p.tok != scanner.Int {
- sep := 'x' // not white space
+ sep := rune('x') // not white space
for (p.tok == scanner.Ident || p.tok == scanner.Int || p.tok == '·') && sep > ' ' {
ident += p.lit
sep = p.scanner.Peek() // if sep <= ' ', there is white space before the next token
diff --git a/libgo/go/exp/types/testdata/test0.src b/libgo/go/exp/types/testdata/test0.src
new file mode 100644
index 0000000..84a1abe
--- /dev/null
+++ b/libgo/go/exp/types/testdata/test0.src
@@ -0,0 +1,154 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// type declarations
+
+package test0
+
+import "unsafe"
+
+const pi = 3.1415
+
+type (
+ N undeclared /* ERROR "undeclared" */
+ B bool
+ I int32
+ A [10]P
+ T struct {
+ x, y P
+ }
+ P *T
+ R (*R)
+ F func(A) I
+ Y interface {
+ f(A) I
+ }
+ S [](((P)))
+ M map[I]F
+ C chan<- I
+)
+
+
+type (
+ p1 pi /* ERROR "not a package" */ .foo
+ p2 unsafe.Pointer
+)
+
+
+type (
+ Pi pi /* ERROR "not a type" */
+
+ a /* DISABLED "illegal cycle" */ a
+ a /* ERROR "redeclared" */ int
+
+ // where the cycle error appears depends on the
+ // order in which declarations are processed
+ // (which depends on the order in which a map
+ // is iterated through)
+ b c
+ c /* DISABLED "illegal cycle" */ d
+ d e
+ e b
+
+ t *t
+
+ U V
+ V *W
+ W U
+
+ P1 *S2
+ P2 P1
+
+ S0 struct {
+ }
+ S1 struct {
+ a, b, c int
+ u, v, a /* ERROR "redeclared" */ float32
+ }
+ S2 struct {
+ U // anonymous field
+ // TODO(gri) recognize double-declaration below
+ // U /* ERROR "redeclared" */ int
+ }
+ S3 struct {
+ x S2
+ }
+ S4/* DISABLED "illegal cycle" */ struct {
+ S4
+ }
+ S5 struct {
+ S6
+ }
+ S6 /* DISABLED "illegal cycle" */ struct {
+ field S7
+ }
+ S7 struct {
+ S5
+ }
+
+ L1 []L1
+ L2 []int
+
+ A1 [10]int
+ A2 /* DISABLED "illegal cycle" */ [10]A2
+ A3 /* DISABLED "illegal cycle" */ [10]struct {
+ x A4
+ }
+ A4 [10]A3
+
+ F1 func()
+ F2 func(x, y, z float32)
+ F3 func(x, y, x /* ERROR "redeclared" */ float32)
+ F4 func() (x, y, x /* ERROR "redeclared" */ float32)
+ F5 func(x int) (x /* ERROR "redeclared" */ float32)
+ F6 func(x ...int)
+
+ I1 interface{}
+ I2 interface {
+ m1()
+ }
+ I3 interface {
+ m1()
+ m1 /* ERROR "redeclared" */ ()
+ }
+ I4 interface {
+ m1(x, y, x /* ERROR "redeclared" */ float32)
+ m2() (x, y, x /* ERROR "redeclared" */ float32)
+ m3(x int) (x /* ERROR "redeclared" */ float32)
+ }
+ I5 interface {
+ m1(I5)
+ }
+ I6 interface {
+ S0 /* ERROR "non-interface" */
+ }
+ I7 interface {
+ I1
+ I1
+ }
+ I8 /* DISABLED "illegal cycle" */ interface {
+ I8
+ }
+ I9 /* DISABLED "illegal cycle" */ interface {
+ I10
+ }
+ I10 interface {
+ I11
+ }
+ I11 interface {
+ I9
+ }
+
+ C1 chan int
+ C2 <-chan int
+ C3 chan<- C3
+ C4 chan C5
+ C5 chan C6
+ C6 chan C4
+
+ M1 map[Last]string
+ M2 map[string]M2
+
+ Last int
+)
diff --git a/libgo/go/exp/types/universe.go b/libgo/go/exp/types/universe.go
index 80db127..f043596 100644
--- a/libgo/go/exp/types/universe.go
+++ b/libgo/go/exp/types/universe.go
@@ -54,6 +54,7 @@ func init() {
Bool = defType("bool")
defType("byte") // TODO(gri) should be an alias for uint8
+ defType("rune") // TODO(gri) should be an alias for int
defType("complex64")
Complex128 = defType("complex128")
defType("float32")
diff --git a/libgo/go/exp/winfsnotify/winfsnotify_test.go b/libgo/go/exp/winfsnotify/winfsnotify_test.go
index 6e264d0..fb2b825 100644
--- a/libgo/go/exp/winfsnotify/winfsnotify_test.go
+++ b/libgo/go/exp/winfsnotify/winfsnotify_test.go
@@ -40,7 +40,7 @@ func TestNotifyEvents(t *testing.T) {
// Add a watch for testDir
os.RemoveAll(testDir)
if err = os.Mkdir(testDir, 0777); err != nil {
- t.Fatalf("Failed to create test directory", err)
+ t.Fatalf("Failed to create test directory: %s", err)
}
defer os.RemoveAll(testDir)
err = watcher.AddWatch(testDir, mask)