Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
6aaef044
Commit
6aaef044
authored
Jun 08, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc cleanup: gofmt + &x -> x[0:] conversion
R=gri CC=golang-dev
https://golang.org/cl/1620042
parent
f29fb251
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
149 additions
and
141 deletions
+149
-141
src/pkg/debug/macho/file.go
src/pkg/debug/macho/file.go
+9
-9
src/pkg/debug/proc/regs_linux_386.go
src/pkg/debug/proc/regs_linux_386.go
+2
-2
src/pkg/http/triv.go
src/pkg/http/triv.go
+11
-4
src/pkg/json/stream_test.go
src/pkg/json/stream_test.go
+1
-1
src/pkg/net/iprawsock.go
src/pkg/net/iprawsock.go
+4
-4
src/pkg/net/tcpsock.go
src/pkg/net/tcpsock.go
+2
-2
src/pkg/net/udpsock.go
src/pkg/net/udpsock.go
+4
-4
test/copy.go
test/copy.go
+105
-105
test/fixedbugs/bug102.go
test/fixedbugs/bug102.go
+8
-7
test/ken/string.go
test/ken/string.go
+3
-3
No files found.
src/pkg/debug/macho/file.go
View file @
6aaef044
...
@@ -168,11 +168,11 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
...
@@ -168,11 +168,11 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
// Read and decode Mach magic to determine byte order, size.
// Read and decode Mach magic to determine byte order, size.
// Magic32 and Magic64 differ only in the bottom bit.
// Magic32 and Magic64 differ only in the bottom bit.
var
ident
[
4
]
byte
var
ident
[
4
]
byte
if
_
,
err
:=
r
.
ReadAt
(
&
ident
,
0
);
err
!=
nil
{
if
_
,
err
:=
r
.
ReadAt
(
ident
[
0
:
]
,
0
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
be
:=
binary
.
BigEndian
.
Uint32
(
&
ident
)
be
:=
binary
.
BigEndian
.
Uint32
(
ident
[
0
:
]
)
le
:=
binary
.
LittleEndian
.
Uint32
(
&
ident
)
le
:=
binary
.
LittleEndian
.
Uint32
(
ident
[
0
:
]
)
switch
Magic32
&^
1
{
switch
Magic32
&^
1
{
case
be
&^
1
:
case
be
&^
1
:
f
.
ByteOrder
=
binary
.
BigEndian
f
.
ByteOrder
=
binary
.
BigEndian
...
@@ -227,7 +227,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
...
@@ -227,7 +227,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
s
.
LoadBytes
=
cmddat
s
.
LoadBytes
=
cmddat
s
.
Cmd
=
cmd
s
.
Cmd
=
cmd
s
.
Len
=
siz
s
.
Len
=
siz
s
.
Name
=
cstring
(
&
seg32
.
Name
)
s
.
Name
=
cstring
(
seg32
.
Name
[
0
:
]
)
s
.
Addr
=
uint64
(
seg32
.
Addr
)
s
.
Addr
=
uint64
(
seg32
.
Addr
)
s
.
Memsz
=
uint64
(
seg32
.
Memsz
)
s
.
Memsz
=
uint64
(
seg32
.
Memsz
)
s
.
Offset
=
uint64
(
seg32
.
Offset
)
s
.
Offset
=
uint64
(
seg32
.
Offset
)
...
@@ -243,8 +243,8 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
...
@@ -243,8 +243,8 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
return
nil
,
err
return
nil
,
err
}
}
sh
:=
new
(
Section
)
sh
:=
new
(
Section
)
sh
.
Name
=
cstring
(
&
sh32
.
Name
)
sh
.
Name
=
cstring
(
sh32
.
Name
[
0
:
]
)
sh
.
Seg
=
cstring
(
&
sh32
.
Seg
)
sh
.
Seg
=
cstring
(
sh32
.
Seg
[
0
:
]
)
sh
.
Addr
=
uint64
(
sh32
.
Addr
)
sh
.
Addr
=
uint64
(
sh32
.
Addr
)
sh
.
Size
=
uint64
(
sh32
.
Size
)
sh
.
Size
=
uint64
(
sh32
.
Size
)
sh
.
Offset
=
sh32
.
Offset
sh
.
Offset
=
sh32
.
Offset
...
@@ -265,7 +265,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
...
@@ -265,7 +265,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
s
.
LoadBytes
=
cmddat
s
.
LoadBytes
=
cmddat
s
.
Cmd
=
cmd
s
.
Cmd
=
cmd
s
.
Len
=
siz
s
.
Len
=
siz
s
.
Name
=
cstring
(
&
seg64
.
Name
)
s
.
Name
=
cstring
(
seg64
.
Name
[
0
:
]
)
s
.
Addr
=
seg64
.
Addr
s
.
Addr
=
seg64
.
Addr
s
.
Memsz
=
seg64
.
Memsz
s
.
Memsz
=
seg64
.
Memsz
s
.
Offset
=
seg64
.
Offset
s
.
Offset
=
seg64
.
Offset
...
@@ -281,8 +281,8 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
...
@@ -281,8 +281,8 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
return
nil
,
err
return
nil
,
err
}
}
sh
:=
new
(
Section
)
sh
:=
new
(
Section
)
sh
.
Name
=
cstring
(
&
sh64
.
Name
)
sh
.
Name
=
cstring
(
sh64
.
Name
[
0
:
]
)
sh
.
Seg
=
cstring
(
&
sh64
.
Seg
)
sh
.
Seg
=
cstring
(
sh64
.
Seg
[
0
:
]
)
sh
.
Addr
=
sh64
.
Addr
sh
.
Addr
=
sh64
.
Addr
sh
.
Size
=
sh64
.
Size
sh
.
Size
=
sh64
.
Size
sh
.
Offset
=
sh64
.
Offset
sh
.
Offset
=
sh64
.
Offset
...
...
src/pkg/debug/proc/regs_linux_386.go
View file @
6aaef044
...
@@ -15,7 +15,7 @@ type _386Regs struct {
...
@@ -15,7 +15,7 @@ type _386Regs struct {
setter
func
(
*
syscall
.
PtraceRegs
)
os
.
Error
setter
func
(
*
syscall
.
PtraceRegs
)
os
.
Error
}
}
var
names
=
[
...
]
string
{
var
names
=
[]
string
{
"eax"
,
"eax"
,
"ebx"
,
"ebx"
,
"ecx"
,
"ecx"
,
...
@@ -55,7 +55,7 @@ func (r *_386Regs) SetSP(val Word) os.Error {
...
@@ -55,7 +55,7 @@ func (r *_386Regs) SetSP(val Word) os.Error {
return
r
.
setter
(
&
r
.
PtraceRegs
)
return
r
.
setter
(
&
r
.
PtraceRegs
)
}
}
func
(
r
*
_386Regs
)
Names
()
[]
string
{
return
&
names
}
func
(
r
*
_386Regs
)
Names
()
[]
string
{
return
names
}
func
(
r
*
_386Regs
)
Get
(
i
int
)
Word
{
func
(
r
*
_386Regs
)
Get
(
i
int
)
Word
{
switch
i
{
switch
i
{
...
...
src/pkg/http/triv.go
View file @
6aaef044
...
@@ -6,13 +6,12 @@ package main
...
@@ -6,13 +6,12 @@ package main
import
(
import
(
"bytes"
"bytes"
"bufio"
"expvar"
"expvar"
"flag"
"flag"
"fmt"
"fmt"
"http"
"io"
"io"
"log"
"log"
"net"
"os"
"os"
"strconv"
"strconv"
)
)
...
@@ -67,7 +66,7 @@ func FileServer(c *http.Conn, req *http.Request) {
...
@@ -67,7 +66,7 @@ func FileServer(c *http.Conn, req *http.Request) {
fmt
.
Fprintf
(
c
,
"open %s: %v
\n
"
,
path
,
err
)
fmt
.
Fprintf
(
c
,
"open %s: %v
\n
"
,
path
,
err
)
return
return
}
}
n
,
err1
:=
io
.
Copy
(
c
,
f
)
n
,
_
:=
io
.
Copy
(
c
,
f
)
fmt
.
Fprintf
(
c
,
"[%d bytes]
\n
"
,
n
)
fmt
.
Fprintf
(
c
,
"[%d bytes]
\n
"
,
n
)
f
.
Close
()
f
.
Close
()
}
}
...
@@ -89,7 +88,7 @@ func FlagServer(c *http.Conn, req *http.Request) {
...
@@ -89,7 +88,7 @@ func FlagServer(c *http.Conn, req *http.Request) {
// simple argument server
// simple argument server
func
ArgServer
(
c
*
http
.
Conn
,
req
*
http
.
Request
)
{
func
ArgServer
(
c
*
http
.
Conn
,
req
*
http
.
Request
)
{
for
i
,
s
:=
range
os
.
Args
{
for
_
,
s
:=
range
os
.
Args
{
fmt
.
Fprint
(
c
,
s
,
" "
)
fmt
.
Fprint
(
c
,
s
,
" "
)
}
}
}
}
...
@@ -138,6 +137,13 @@ func DateServer(c *http.Conn, req *http.Request) {
...
@@ -138,6 +137,13 @@ func DateServer(c *http.Conn, req *http.Request) {
}
}
}
}
func
Logger
(
c
*
http
.
Conn
,
req
*
http
.
Request
)
{
log
.
Stdout
(
req
.
URL
.
Raw
)
c
.
WriteHeader
(
404
)
c
.
Write
([]
byte
(
"oops"
))
}
func
main
()
{
func
main
()
{
flag
.
Parse
()
flag
.
Parse
()
...
@@ -146,6 +152,7 @@ func main() {
...
@@ -146,6 +152,7 @@ func main() {
http
.
Handle
(
"/counter"
,
ctr
)
http
.
Handle
(
"/counter"
,
ctr
)
expvar
.
Publish
(
"counter"
,
ctr
)
expvar
.
Publish
(
"counter"
,
ctr
)
http
.
Handle
(
"/"
,
http
.
HandlerFunc
(
Logger
))
http
.
Handle
(
"/go/"
,
http
.
HandlerFunc
(
FileServer
))
http
.
Handle
(
"/go/"
,
http
.
HandlerFunc
(
FileServer
))
http
.
Handle
(
"/flags"
,
http
.
HandlerFunc
(
FlagServer
))
http
.
Handle
(
"/flags"
,
http
.
HandlerFunc
(
FlagServer
))
http
.
Handle
(
"/args"
,
http
.
HandlerFunc
(
ArgServer
))
http
.
Handle
(
"/args"
,
http
.
HandlerFunc
(
ArgServer
))
...
...
src/pkg/json/stream_test.go
View file @
6aaef044
...
@@ -109,7 +109,7 @@ func TestRawMessage(t *testing.T) {
...
@@ -109,7 +109,7 @@ func TestRawMessage(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unmarshal: %v"
,
err
)
t
.
Fatalf
(
"Unmarshal: %v"
,
err
)
}
}
if
string
(
*
data
.
Id
)
!=
raw
{
if
string
(
[]
byte
(
*
data
.
Id
)
)
!=
raw
{
t
.
Fatalf
(
"Raw mismatch: have %#q want %#q"
,
[]
byte
(
*
data
.
Id
),
raw
)
t
.
Fatalf
(
"Raw mismatch: have %#q want %#q"
,
[]
byte
(
*
data
.
Id
),
raw
)
}
}
b
,
err
:=
Marshal
(
&
data
)
b
,
err
:=
Marshal
(
&
data
)
...
...
src/pkg/net/iprawsock.go
View file @
6aaef044
...
@@ -15,9 +15,9 @@ import (
...
@@ -15,9 +15,9 @@ import (
func
sockaddrToIP
(
sa
syscall
.
Sockaddr
)
Addr
{
func
sockaddrToIP
(
sa
syscall
.
Sockaddr
)
Addr
{
switch
sa
:=
sa
.
(
type
)
{
switch
sa
:=
sa
.
(
type
)
{
case
*
syscall
.
SockaddrInet4
:
case
*
syscall
.
SockaddrInet4
:
return
&
IPAddr
{
&
sa
.
Addr
}
return
&
IPAddr
{
sa
.
Addr
[
0
:
]
}
case
*
syscall
.
SockaddrInet6
:
case
*
syscall
.
SockaddrInet6
:
return
&
IPAddr
{
&
sa
.
Addr
}
return
&
IPAddr
{
sa
.
Addr
[
0
:
]
}
}
}
return
nil
return
nil
}
}
...
@@ -176,14 +176,14 @@ func (c *IPConn) ReadFromIP(b []byte) (n int, addr *IPAddr, err os.Error) {
...
@@ -176,14 +176,14 @@ func (c *IPConn) ReadFromIP(b []byte) (n int, addr *IPAddr, err os.Error) {
n
,
sa
,
err
:=
c
.
fd
.
ReadFrom
(
b
)
n
,
sa
,
err
:=
c
.
fd
.
ReadFrom
(
b
)
switch
sa
:=
sa
.
(
type
)
{
switch
sa
:=
sa
.
(
type
)
{
case
*
syscall
.
SockaddrInet4
:
case
*
syscall
.
SockaddrInet4
:
addr
=
&
IPAddr
{
&
sa
.
Addr
}
addr
=
&
IPAddr
{
sa
.
Addr
[
0
:
]
}
if
len
(
b
)
>=
4
{
// discard ipv4 header
if
len
(
b
)
>=
4
{
// discard ipv4 header
hsize
:=
(
int
(
b
[
0
])
&
0xf
)
*
4
hsize
:=
(
int
(
b
[
0
])
&
0xf
)
*
4
copy
(
b
,
b
[
hsize
:
])
copy
(
b
,
b
[
hsize
:
])
n
-=
hsize
n
-=
hsize
}
}
case
*
syscall
.
SockaddrInet6
:
case
*
syscall
.
SockaddrInet6
:
addr
=
&
IPAddr
{
&
sa
.
Addr
}
addr
=
&
IPAddr
{
sa
.
Addr
[
0
:
]
}
}
}
return
return
}
}
...
...
src/pkg/net/tcpsock.go
View file @
6aaef044
...
@@ -14,9 +14,9 @@ import (
...
@@ -14,9 +14,9 @@ import (
func
sockaddrToTCP
(
sa
syscall
.
Sockaddr
)
Addr
{
func
sockaddrToTCP
(
sa
syscall
.
Sockaddr
)
Addr
{
switch
sa
:=
sa
.
(
type
)
{
switch
sa
:=
sa
.
(
type
)
{
case
*
syscall
.
SockaddrInet4
:
case
*
syscall
.
SockaddrInet4
:
return
&
TCPAddr
{
&
sa
.
Addr
,
sa
.
Port
}
return
&
TCPAddr
{
sa
.
Addr
[
0
:
]
,
sa
.
Port
}
case
*
syscall
.
SockaddrInet6
:
case
*
syscall
.
SockaddrInet6
:
return
&
TCPAddr
{
&
sa
.
Addr
,
sa
.
Port
}
return
&
TCPAddr
{
sa
.
Addr
[
0
:
]
,
sa
.
Port
}
}
}
return
nil
return
nil
}
}
...
...
src/pkg/net/udpsock.go
View file @
6aaef044
...
@@ -14,9 +14,9 @@ import (
...
@@ -14,9 +14,9 @@ import (
func
sockaddrToUDP
(
sa
syscall
.
Sockaddr
)
Addr
{
func
sockaddrToUDP
(
sa
syscall
.
Sockaddr
)
Addr
{
switch
sa
:=
sa
.
(
type
)
{
switch
sa
:=
sa
.
(
type
)
{
case
*
syscall
.
SockaddrInet4
:
case
*
syscall
.
SockaddrInet4
:
return
&
UDPAddr
{
&
sa
.
Addr
,
sa
.
Port
}
return
&
UDPAddr
{
sa
.
Addr
[
0
:
]
,
sa
.
Port
}
case
*
syscall
.
SockaddrInet6
:
case
*
syscall
.
SockaddrInet6
:
return
&
UDPAddr
{
&
sa
.
Addr
,
sa
.
Port
}
return
&
UDPAddr
{
sa
.
Addr
[
0
:
]
,
sa
.
Port
}
}
}
return
nil
return
nil
}
}
...
@@ -176,9 +176,9 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) {
...
@@ -176,9 +176,9 @@ func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err os.Error) {
n
,
sa
,
err
:=
c
.
fd
.
ReadFrom
(
b
)
n
,
sa
,
err
:=
c
.
fd
.
ReadFrom
(
b
)
switch
sa
:=
sa
.
(
type
)
{
switch
sa
:=
sa
.
(
type
)
{
case
*
syscall
.
SockaddrInet4
:
case
*
syscall
.
SockaddrInet4
:
addr
=
&
UDPAddr
{
&
sa
.
Addr
,
sa
.
Port
}
addr
=
&
UDPAddr
{
sa
.
Addr
[
0
:
]
,
sa
.
Port
}
case
*
syscall
.
SockaddrInet6
:
case
*
syscall
.
SockaddrInet6
:
addr
=
&
UDPAddr
{
&
sa
.
Addr
,
sa
.
Port
}
addr
=
&
UDPAddr
{
sa
.
Addr
[
0
:
]
,
sa
.
Port
}
}
}
return
return
}
}
...
...
test/copy.go
View file @
6aaef044
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
package
main
package
main
import
(
import
(
"fmt"
;
"fmt"
"os"
;
"os"
)
)
const
N
=
40
const
N
=
40
...
@@ -25,53 +25,53 @@ var input64 = make([]uint64, N)
...
@@ -25,53 +25,53 @@ var input64 = make([]uint64, N)
var
output64
=
make
([]
uint64
,
N
)
var
output64
=
make
([]
uint64
,
N
)
func
u8
(
i
int
)
uint8
{
func
u8
(
i
int
)
uint8
{
i
=
'a'
+
i
%
26
;
i
=
'a'
+
i
%
26
return
uint8
(
i
)
;
return
uint8
(
i
)
}
}
func
u16
(
ii
int
)
uint16
{
func
u16
(
ii
int
)
uint16
{
var
i
=
uint16
(
ii
)
;
var
i
=
uint16
(
ii
)
i
=
'a'
+
i
%
26
;
i
=
'a'
+
i
%
26
i
|=
i
<<
8
;
i
|=
i
<<
8
return
i
;
return
i
}
}
func
u32
(
ii
int
)
uint32
{
func
u32
(
ii
int
)
uint32
{
var
i
=
uint32
(
ii
)
;
var
i
=
uint32
(
ii
)
i
=
'a'
+
i
%
26
;
i
=
'a'
+
i
%
26
i
|=
i
<<
8
;
i
|=
i
<<
8
i
|=
i
<<
16
;
i
|=
i
<<
16
return
i
;
return
i
}
}
func
u64
(
ii
int
)
uint64
{
func
u64
(
ii
int
)
uint64
{
var
i
=
uint64
(
ii
)
;
var
i
=
uint64
(
ii
)
i
=
'a'
+
i
%
26
;
i
=
'a'
+
i
%
26
i
|=
i
<<
8
;
i
|=
i
<<
8
i
|=
i
<<
16
;
i
|=
i
<<
16
i
|=
i
<<
32
;
i
|=
i
<<
32
return
i
;
return
i
}
}
func
reset
()
{
func
reset
()
{
// swap in and out to exercise copy-up and copy-down
// swap in and out to exercise copy-up and copy-down
input8
,
output8
=
output8
,
input8
;
input8
,
output8
=
output8
,
input8
input16
,
output16
=
output16
,
input16
;
input16
,
output16
=
output16
,
input16
input32
,
output32
=
output32
,
input32
;
input32
,
output32
=
output32
,
input32
input64
,
output64
=
output64
,
input64
;
input64
,
output64
=
output64
,
input64
in
:=
0
;
in
:=
0
out
:=
13
;
out
:=
13
for
i
:=
range
input8
{
for
i
:=
range
input8
{
input8
[
i
]
=
u8
(
in
)
;
input8
[
i
]
=
u8
(
in
)
output8
[
i
]
=
u8
(
out
)
;
output8
[
i
]
=
u8
(
out
)
input16
[
i
]
=
u16
(
in
)
;
input16
[
i
]
=
u16
(
in
)
output16
[
i
]
=
u16
(
out
)
;
output16
[
i
]
=
u16
(
out
)
input32
[
i
]
=
u32
(
in
)
;
input32
[
i
]
=
u32
(
in
)
output32
[
i
]
=
u32
(
out
)
;
output32
[
i
]
=
u32
(
out
)
input64
[
i
]
=
u64
(
in
)
;
input64
[
i
]
=
u64
(
in
)
output64
[
i
]
=
u64
(
out
)
;
output64
[
i
]
=
u64
(
out
)
in
++
;
in
++
out
++
;
out
++
}
}
}
}
...
@@ -79,30 +79,30 @@ func clamp(n int) int {
...
@@ -79,30 +79,30 @@ func clamp(n int) int {
if
n
>
N
{
if
n
>
N
{
return
N
return
N
}
}
return
n
;
return
n
}
}
func
ncopied
(
length
,
in
,
out
int
)
int
{
func
ncopied
(
length
,
in
,
out
int
)
int
{
n
:=
length
;
n
:=
length
if
in
+
n
>
N
{
if
in
+
n
>
N
{
n
=
N
-
in
n
=
N
-
in
}
}
if
out
+
n
>
N
{
if
out
+
n
>
N
{
n
=
N
-
out
n
=
N
-
out
}
}
return
n
;
return
n
}
}
func
doAllSlices
(
length
,
in
,
out
int
)
{
func
doAllSlices
(
length
,
in
,
out
int
)
{
reset
()
;
reset
()
n
:=
copy
(
output8
[
out
:
clamp
(
out
+
length
)],
input8
[
in
:
clamp
(
in
+
length
)])
;
n
:=
copy
(
output8
[
out
:
clamp
(
out
+
length
)],
input8
[
in
:
clamp
(
in
+
length
)])
verify8
(
length
,
in
,
out
,
n
)
;
verify8
(
length
,
in
,
out
,
n
)
n
=
copy
(
output16
[
out
:
clamp
(
out
+
length
)],
input16
[
in
:
clamp
(
in
+
length
)])
;
n
=
copy
(
output16
[
out
:
clamp
(
out
+
length
)],
input16
[
in
:
clamp
(
in
+
length
)])
verify16
(
length
,
in
,
out
,
n
)
;
verify16
(
length
,
in
,
out
,
n
)
n
=
copy
(
output32
[
out
:
clamp
(
out
+
length
)],
input32
[
in
:
clamp
(
in
+
length
)])
;
n
=
copy
(
output32
[
out
:
clamp
(
out
+
length
)],
input32
[
in
:
clamp
(
in
+
length
)])
verify32
(
length
,
in
,
out
,
n
)
;
verify32
(
length
,
in
,
out
,
n
)
n
=
copy
(
output64
[
out
:
clamp
(
out
+
length
)],
input64
[
in
:
clamp
(
in
+
length
)])
;
n
=
copy
(
output64
[
out
:
clamp
(
out
+
length
)],
input64
[
in
:
clamp
(
in
+
length
)])
verify64
(
length
,
in
,
out
,
n
)
;
verify64
(
length
,
in
,
out
,
n
)
}
}
func
bad8
(
state
string
,
i
,
length
,
in
,
out
int
)
{
func
bad8
(
state
string
,
i
,
length
,
in
,
out
int
)
{
...
@@ -111,36 +111,36 @@ func bad8(state string, i, length, in, out int) {
...
@@ -111,36 +111,36 @@ func bad8(state string, i, length, in, out int) {
length
,
in
,
out
,
length
,
in
,
out
,
output8
[
i
],
output8
[
i
],
uint8
(
i
+
13
),
uint8
(
i
+
13
),
input8
,
output8
)
;
input8
,
output8
)
os
.
Exit
(
1
)
;
os
.
Exit
(
1
)
}
}
func
verify8
(
length
,
in
,
out
,
m
int
)
{
func
verify8
(
length
,
in
,
out
,
m
int
)
{
n
:=
ncopied
(
length
,
in
,
out
)
;
n
:=
ncopied
(
length
,
in
,
out
)
if
m
!=
n
{
if
m
!=
n
{
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
;
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
return
;
return
}
}
// before
// before
var
i
int
;
var
i
int
for
i
=
0
;
i
<
out
;
i
++
{
for
i
=
0
;
i
<
out
;
i
++
{
if
output8
[
i
]
!=
u8
(
i
+
13
)
{
if
output8
[
i
]
!=
u8
(
i
+
13
)
{
bad8
(
"before8"
,
i
,
length
,
in
,
out
)
;
bad8
(
"before8"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// copied part
// copied part
for
;
i
<
out
+
n
;
i
++
{
for
;
i
<
out
+
n
;
i
++
{
if
output8
[
i
]
!=
u8
(
i
+
in
-
out
)
{
if
output8
[
i
]
!=
u8
(
i
+
in
-
out
)
{
bad8
(
"copied8"
,
i
,
length
,
in
,
out
)
;
bad8
(
"copied8"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// after
// after
for
;
i
<
len
(
output8
);
i
++
{
for
;
i
<
len
(
output8
);
i
++
{
if
output8
[
i
]
!=
u8
(
i
+
13
)
{
if
output8
[
i
]
!=
u8
(
i
+
13
)
{
bad8
(
"after8"
,
i
,
length
,
in
,
out
)
;
bad8
(
"after8"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
}
}
...
@@ -151,36 +151,36 @@ func bad16(state string, i, length, in, out int) {
...
@@ -151,36 +151,36 @@ func bad16(state string, i, length, in, out int) {
length
,
in
,
out
,
length
,
in
,
out
,
output16
[
i
],
output16
[
i
],
uint16
(
i
+
13
),
uint16
(
i
+
13
),
input16
,
output16
)
;
input16
,
output16
)
os
.
Exit
(
1
)
;
os
.
Exit
(
1
)
}
}
func
verify16
(
length
,
in
,
out
,
m
int
)
{
func
verify16
(
length
,
in
,
out
,
m
int
)
{
n
:=
ncopied
(
length
,
in
,
out
)
;
n
:=
ncopied
(
length
,
in
,
out
)
if
m
!=
n
{
if
m
!=
n
{
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
;
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
return
;
return
}
}
// before
// before
var
i
int
;
var
i
int
for
i
=
0
;
i
<
out
;
i
++
{
for
i
=
0
;
i
<
out
;
i
++
{
if
output16
[
i
]
!=
u16
(
i
+
13
)
{
if
output16
[
i
]
!=
u16
(
i
+
13
)
{
bad16
(
"before16"
,
i
,
length
,
in
,
out
)
;
bad16
(
"before16"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// copied part
// copied part
for
;
i
<
out
+
n
;
i
++
{
for
;
i
<
out
+
n
;
i
++
{
if
output16
[
i
]
!=
u16
(
i
+
in
-
out
)
{
if
output16
[
i
]
!=
u16
(
i
+
in
-
out
)
{
bad16
(
"copied16"
,
i
,
length
,
in
,
out
)
;
bad16
(
"copied16"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// after
// after
for
;
i
<
len
(
output16
);
i
++
{
for
;
i
<
len
(
output16
);
i
++
{
if
output16
[
i
]
!=
u16
(
i
+
13
)
{
if
output16
[
i
]
!=
u16
(
i
+
13
)
{
bad16
(
"after16"
,
i
,
length
,
in
,
out
)
;
bad16
(
"after16"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
}
}
...
@@ -191,36 +191,36 @@ func bad32(state string, i, length, in, out int) {
...
@@ -191,36 +191,36 @@ func bad32(state string, i, length, in, out int) {
length
,
in
,
out
,
length
,
in
,
out
,
output32
[
i
],
output32
[
i
],
uint32
(
i
+
13
),
uint32
(
i
+
13
),
input32
,
output32
)
;
input32
,
output32
)
os
.
Exit
(
1
)
;
os
.
Exit
(
1
)
}
}
func
verify32
(
length
,
in
,
out
,
m
int
)
{
func
verify32
(
length
,
in
,
out
,
m
int
)
{
n
:=
ncopied
(
length
,
in
,
out
)
;
n
:=
ncopied
(
length
,
in
,
out
)
if
m
!=
n
{
if
m
!=
n
{
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
;
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
return
;
return
}
}
// before
// before
var
i
int
;
var
i
int
for
i
=
0
;
i
<
out
;
i
++
{
for
i
=
0
;
i
<
out
;
i
++
{
if
output32
[
i
]
!=
u32
(
i
+
13
)
{
if
output32
[
i
]
!=
u32
(
i
+
13
)
{
bad32
(
"before32"
,
i
,
length
,
in
,
out
)
;
bad32
(
"before32"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// copied part
// copied part
for
;
i
<
out
+
n
;
i
++
{
for
;
i
<
out
+
n
;
i
++
{
if
output32
[
i
]
!=
u32
(
i
+
in
-
out
)
{
if
output32
[
i
]
!=
u32
(
i
+
in
-
out
)
{
bad32
(
"copied32"
,
i
,
length
,
in
,
out
)
;
bad32
(
"copied32"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// after
// after
for
;
i
<
len
(
output32
);
i
++
{
for
;
i
<
len
(
output32
);
i
++
{
if
output32
[
i
]
!=
u32
(
i
+
13
)
{
if
output32
[
i
]
!=
u32
(
i
+
13
)
{
bad32
(
"after32"
,
i
,
length
,
in
,
out
)
;
bad32
(
"after32"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
}
}
...
@@ -231,36 +231,36 @@ func bad64(state string, i, length, in, out int) {
...
@@ -231,36 +231,36 @@ func bad64(state string, i, length, in, out int) {
length
,
in
,
out
,
length
,
in
,
out
,
output64
[
i
],
output64
[
i
],
uint64
(
i
+
13
),
uint64
(
i
+
13
),
input64
,
output64
)
;
input64
,
output64
)
os
.
Exit
(
1
)
;
os
.
Exit
(
1
)
}
}
func
verify64
(
length
,
in
,
out
,
m
int
)
{
func
verify64
(
length
,
in
,
out
,
m
int
)
{
n
:=
ncopied
(
length
,
in
,
out
)
;
n
:=
ncopied
(
length
,
in
,
out
)
if
m
!=
n
{
if
m
!=
n
{
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
;
fmt
.
Printf
(
"count bad(%d %d %d): %d not %d
\n
"
,
length
,
in
,
out
,
m
,
n
)
return
;
return
}
}
// before
// before
var
i
int
;
var
i
int
for
i
=
0
;
i
<
out
;
i
++
{
for
i
=
0
;
i
<
out
;
i
++
{
if
output64
[
i
]
!=
u64
(
i
+
13
)
{
if
output64
[
i
]
!=
u64
(
i
+
13
)
{
bad64
(
"before64"
,
i
,
length
,
in
,
out
)
;
bad64
(
"before64"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// copied part
// copied part
for
;
i
<
out
+
n
;
i
++
{
for
;
i
<
out
+
n
;
i
++
{
if
output64
[
i
]
!=
u64
(
i
+
in
-
out
)
{
if
output64
[
i
]
!=
u64
(
i
+
in
-
out
)
{
bad64
(
"copied64"
,
i
,
length
,
in
,
out
)
;
bad64
(
"copied64"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
// after
// after
for
;
i
<
len
(
output64
);
i
++
{
for
;
i
<
len
(
output64
);
i
++
{
if
output64
[
i
]
!=
u64
(
i
+
13
)
{
if
output64
[
i
]
!=
u64
(
i
+
13
)
{
bad64
(
"after64"
,
i
,
length
,
in
,
out
)
;
bad64
(
"after64"
,
i
,
length
,
in
,
out
)
return
;
return
}
}
}
}
}
}
...
@@ -275,19 +275,19 @@ func slice() {
...
@@ -275,19 +275,19 @@ func slice() {
}
}
}
}
// Array test. Can be much simpler. It's
mostly checking for promotion of *[N] to []
// Array test. Can be much simpler. It's
only checking for correct handling of [0:].
func
array
()
{
func
array
()
{
var
array
[
N
]
uint8
;
var
array
[
N
]
uint8
reset
()
;
reset
()
copy
(
&
array
,
input8
);
copy
(
array
[
0
:
],
input8
)
for
i
:=
0
;
i
<
N
;
i
++
{
for
i
:=
0
;
i
<
N
;
i
++
{
output8
[
i
]
=
0
output8
[
i
]
=
0
}
}
copy
(
output8
,
&
array
);
copy
(
output8
,
array
[
0
:
])
verify8
(
N
,
0
,
0
,
N
)
;
verify8
(
N
,
0
,
0
,
N
)
}
}
func
main
()
{
func
main
()
{
slice
()
;
slice
()
array
()
;
array
()
}
}
test/fixedbugs/bug102.go
View file @
6aaef044
...
@@ -7,19 +7,20 @@
...
@@ -7,19 +7,20 @@
package
main
package
main
func
main
()
{
func
main
()
{
var
b
[
0
]
byte
;
var
b
[
0
]
byte
s
:=
string
(
&
b
);
// out of bounds trap
s
:=
string
(
b
[
0
:
])
// out of bounds trap
if
s
!=
""
{
if
s
!=
""
{
panic
(
"bad convert"
)
panic
(
"bad convert"
)
}
}
var
b1
=
[
5
]
byte
{
'h'
,
'e'
,
'l'
,
'l'
,
'o'
}
;
var
b1
=
[
5
]
byte
{
'h'
,
'e'
,
'l'
,
'l'
,
'o'
}
if
string
(
&
b1
)
!=
"hello"
{
if
string
(
b1
[
0
:
]
)
!=
"hello"
{
panic
(
"bad convert 1"
)
panic
(
"bad convert 1"
)
}
}
var
b2
=
make
([]
byte
,
5
);
var
b2
=
make
([]
byte
,
5
)
for
i
:=
0
;
i
<
5
;
i
++
{
b2
[
i
]
=
b1
[
i
]
}
for
i
:=
0
;
i
<
5
;
i
++
{
b2
[
i
]
=
b1
[
i
]
}
if
string
(
b2
)
!=
"hello"
{
if
string
(
b2
)
!=
"hello"
{
panic
(
"bad convert 2"
)
panic
(
"bad convert 2"
)
}
}
}
}
test/ken/string.go
View file @
6aaef044
...
@@ -88,7 +88,7 @@ func main() {
...
@@ -88,7 +88,7 @@ func main() {
z1
[
0
]
=
'a'
z1
[
0
]
=
'a'
z1
[
1
]
=
'b'
z1
[
1
]
=
'b'
z1
[
2
]
=
'c'
z1
[
2
]
=
'c'
c
=
string
(
&
z1
)
c
=
string
(
z1
[
0
:
]
)
if
c
!=
"abc"
{
if
c
!=
"abc"
{
print
(
"create byte array "
,
c
)
print
(
"create byte array "
,
c
)
panic
(
"fail"
)
panic
(
"fail"
)
...
@@ -99,7 +99,7 @@ func main() {
...
@@ -99,7 +99,7 @@ func main() {
z2
[
0
]
=
'a'
z2
[
0
]
=
'a'
z2
[
1
]
=
'\u1234'
z2
[
1
]
=
'\u1234'
z2
[
2
]
=
'c'
z2
[
2
]
=
'c'
c
=
string
(
&
z2
)
c
=
string
(
z2
[
0
:
]
)
if
c
!=
"a
\u1234
c"
{
if
c
!=
"a
\u1234
c"
{
print
(
"create int array "
,
c
)
print
(
"create int array "
,
c
)
panic
(
"fail"
)
panic
(
"fail"
)
...
@@ -110,7 +110,7 @@ func main() {
...
@@ -110,7 +110,7 @@ func main() {
z3
[
0
]
=
'a'
z3
[
0
]
=
'a'
z3
[
1
]
=
'b'
z3
[
1
]
=
'b'
z3
[
2
]
=
'c'
z3
[
2
]
=
'c'
c
=
string
(
z3
)
c
=
string
(
z3
[
0
:
]
)
if
c
!=
"abc"
{
if
c
!=
"abc"
{
print
(
"create array pointer "
,
c
)
print
(
"create array pointer "
,
c
)
panic
(
"fail"
)
panic
(
"fail"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment