summaryrefslogtreecommitdiff
path: root/src/pkg/debug/dwarf/buf.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-12-15 15:27:16 -0800
committerRobert Griesemer <gri@golang.org>2009-12-15 15:27:16 -0800
commit881d6064d23d9da5c7ff368bc7d41d271290deff (patch)
tree44d5d948e3f27cc7eff15ec8cd7ee5165d9a7e90 /src/pkg/debug/dwarf/buf.go
parentd9dfea3ebd51cea89fef8afc6b2377c2958b24f1 (diff)
downloadgolang-881d6064d23d9da5c7ff368bc7d41d271290deff.tar.gz
1) Change default gofmt default settings for
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067
Diffstat (limited to 'src/pkg/debug/dwarf/buf.go')
-rw-r--r--src/pkg/debug/dwarf/buf.go108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/pkg/debug/dwarf/buf.go b/src/pkg/debug/dwarf/buf.go
index 2ece903a0..2d29cebdd 100644
--- a/src/pkg/debug/dwarf/buf.go
+++ b/src/pkg/debug/dwarf/buf.go
@@ -7,20 +7,20 @@
package dwarf
import (
- "encoding/binary";
- "os";
- "strconv";
+ "encoding/binary"
+ "os"
+ "strconv"
)
// Data buffer being decoded.
type buf struct {
- dwarf *Data;
- order binary.ByteOrder;
- name string;
- off Offset;
- data []byte;
- addrsize int;
- err os.Error;
+ dwarf *Data
+ order binary.ByteOrder
+ name string
+ off Offset
+ data []byte
+ addrsize int
+ err os.Error
}
func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf {
@@ -29,95 +29,95 @@ func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf {
func (b *buf) uint8() uint8 {
if len(b.data) < 1 {
- b.error("underflow");
- return 0;
+ b.error("underflow")
+ return 0
}
- val := b.data[0];
- b.data = b.data[1:];
- b.off++;
- return val;
+ val := b.data[0]
+ b.data = b.data[1:]
+ b.off++
+ return val
}
func (b *buf) bytes(n int) []byte {
if len(b.data) < n {
- b.error("underflow");
- return nil;
+ b.error("underflow")
+ return nil
}
- data := b.data[0:n];
- b.data = b.data[n:];
- b.off += Offset(n);
- return data;
+ data := b.data[0:n]
+ b.data = b.data[n:]
+ b.off += Offset(n)
+ return data
}
-func (b *buf) skip(n int) { b.bytes(n) }
+func (b *buf) skip(n int) { b.bytes(n) }
func (b *buf) string() string {
for i := 0; i < len(b.data); i++ {
if b.data[i] == 0 {
- s := string(b.data[0:i]);
- b.data = b.data[i+1:];
- b.off += Offset(i + 1);
- return s;
+ s := string(b.data[0:i])
+ b.data = b.data[i+1:]
+ b.off += Offset(i + 1)
+ return s
}
}
- b.error("underflow");
- return "";
+ b.error("underflow")
+ return ""
}
func (b *buf) uint16() uint16 {
- a := b.bytes(2);
+ a := b.bytes(2)
if a == nil {
return 0
}
- return b.order.Uint16(a);
+ return b.order.Uint16(a)
}
func (b *buf) uint32() uint32 {
- a := b.bytes(4);
+ a := b.bytes(4)
if a == nil {
return 0
}
- return b.order.Uint32(a);
+ return b.order.Uint32(a)
}
func (b *buf) uint64() uint64 {
- a := b.bytes(8);
+ a := b.bytes(8)
if a == nil {
return 0
}
- return b.order.Uint64(a);
+ return b.order.Uint64(a)
}
// Read a varint, which is 7 bits per byte, little endian.
// the 0x80 bit means read another byte.
func (b *buf) varint() (c uint64, bits uint) {
for i := 0; i < len(b.data); i++ {
- byte := b.data[i];
- c |= uint64(byte&0x7F) << bits;
- bits += 7;
+ byte := b.data[i]
+ c |= uint64(byte&0x7F) << bits
+ bits += 7
if byte&0x80 == 0 {
- b.off += Offset(i + 1);
- b.data = b.data[i+1:];
- return c, bits;
+ b.off += Offset(i + 1)
+ b.data = b.data[i+1:]
+ return c, bits
}
}
- return 0, 0;
+ return 0, 0
}
// Unsigned int is just a varint.
func (b *buf) uint() uint64 {
- x, _ := b.varint();
- return x;
+ x, _ := b.varint()
+ return x
}
// Signed int is a sign-extended varint.
func (b *buf) int() int64 {
- ux, bits := b.varint();
- x := int64(ux);
+ ux, bits := b.varint()
+ x := int64(ux)
if x&(1<<(bits-1)) != 0 {
x |= -1 << bits
}
- return x;
+ return x
}
// Address-sized uint.
@@ -132,21 +132,21 @@ func (b *buf) addr() uint64 {
case 8:
return uint64(b.uint64())
}
- b.error("unknown address size");
- return 0;
+ b.error("unknown address size")
+ return 0
}
func (b *buf) error(s string) {
if b.err == nil {
- b.data = nil;
- b.err = DecodeError{b.name, b.off, s};
+ b.data = nil
+ b.err = DecodeError{b.name, b.off, s}
}
}
type DecodeError struct {
- Name string;
- Offset Offset;
- Error string;
+ Name string
+ Offset Offset
+ Error string
}
func (e DecodeError) String() string {