Commit 839a6846 authored by Russ Cox's avatar Russ Cox

delete export

TBR=r
OCL=23121
CL=23127
parent 0183baaf
......@@ -9,7 +9,7 @@ import (
"syscall";
)
export type FD struct {
type FD struct {
fildes int64; // file descriptor number
name string; // file name at Open time
}
......@@ -21,13 +21,13 @@ func newFD(fd int64, name string) *FD {
return &FD{fd, name}
}
export var (
var (
Stdin = newFD(0, "/dev/stdin");
Stdout = newFD(1, "/dev/stdout");
Stderr = newFD(2, "/dev/stderr");
)
export func Open(name string, mode int64, perm int64) (fd *FD, err *os.Error) {
func Open(name string, mode int64, perm int64) (fd *FD, err *os.Error) {
r, e := syscall.Open(name, mode, perm);
return newFD(r, name), os.ErrnoToError(e)
}
......
......@@ -4,13 +4,13 @@
package sort
export type SortInterface interface {
type SortInterface interface {
Len() int;
Less(i, j int) bool;
Swap(i, j int);
}
export func Sort(data SortInterface) {
func Sort(data SortInterface) {
for i := 1; i < data.Len(); i++ {
for j := i; j > 0 && data.Less(j, j-1); j-- {
data.Swap(j, j-1);
......@@ -18,7 +18,7 @@ export func Sort(data SortInterface) {
}
}
export func IsSorted(data SortInterface) bool {
func IsSorted(data SortInterface) bool {
n := data.Len();
for i := n - 1; i > 0; i-- {
if data.Less(i, i - 1) {
......@@ -30,21 +30,21 @@ export func IsSorted(data SortInterface) bool {
// Convenience types for common cases
export type IntArray []int
type IntArray []int
func (p IntArray) Len() int { return len(p); }
func (p IntArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p IntArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
export type FloatArray []float
type FloatArray []float
func (p FloatArray) Len() int { return len(p); }
func (p FloatArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p FloatArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
export type StringArray []string
type StringArray []string
func (p StringArray) Len() int { return len(p); }
func (p StringArray) Less(i, j int) bool { return p[i] < p[j]; }
......@@ -53,11 +53,11 @@ func (p StringArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
// Convenience wrappers for common cases
export func SortInts(a []int) { Sort(IntArray(a)); }
export func SortFloats(a []float) { Sort(FloatArray(a)); }
export func SortStrings(a []string) { Sort(StringArray(a)); }
func SortInts(a []int) { Sort(IntArray(a)); }
func SortFloats(a []float) { Sort(FloatArray(a)); }
func SortStrings(a []string) { Sort(StringArray(a)); }
export func IntsAreSorted(a []int) bool { return IsSorted(IntArray(a)); }
export func FloatsAreSorted(a []float) bool { return IsSorted(FloatArray(a)); }
export func StringsAreSorted(a []string) bool { return IsSorted(StringArray(a)); }
func IntsAreSorted(a []int) bool { return IsSorted(IntArray(a)); }
func FloatsAreSorted(a []float) bool { return IsSorted(FloatArray(a)); }
func StringsAreSorted(a []string) bool { return IsSorted(StringArray(a)); }
......@@ -69,35 +69,35 @@ func arrays2d(old *any, nel int) (ary []any);
// used by go programs
export func Breakpoint();
func Breakpoint();
export func Reflect(i interface { }) (uint64, string, bool);
export func Unreflect(uint64, string, bool) (ret interface { });
func Reflect(i interface { }) (uint64, string, bool);
func Unreflect(uint64, string, bool) (ret interface { });
export var Args []string;
export var Envs []string;
var Args []string;
var Envs []string;
export func Frexp(float64) (float64, int); // break fp into exp,fract
export func Ldexp(float64, int) float64; // make fp from exp,fract
export func Modf(float64) (float64, float64); // break fp into double.double
export func IsInf(float64, int) bool; // test for infinity
export func IsNaN(float64) bool; // test for not-a-number
export func Inf(int) float64; // return signed Inf
export func NaN() float64; // return a NaN
export func Float32bits(float32) uint32; // raw bits
export func Float64bits(float64) uint64; // raw bits
export func Float32frombits(uint32) float32; // raw bits
export func Float64frombits(uint64) float64; // raw bits
func Frexp(float64) (float64, int); // break fp into exp,fract
func Ldexp(float64, int) float64; // make fp from exp,fract
func Modf(float64) (float64, float64); // break fp into double.double
func IsInf(float64, int) bool; // test for infinity
func IsNaN(float64) bool; // test for not-a-number
func Inf(int) float64; // return signed Inf
func NaN() float64; // return a NaN
func Float32bits(float32) uint32; // raw bits
func Float64bits(float64) uint64; // raw bits
func Float32frombits(uint32) float32; // raw bits
func Float64frombits(uint64) float64; // raw bits
export func Gosched();
export func Goexit();
func Gosched();
func Goexit();
export func BytesToRune(*byte, int, int) (int, int); // convert bytes to runes
export func StringToRune(string, int) (int, int); // convert bytes to runes
func BytesToRune(*byte, int, int) (int, int); // convert bytes to runes
func StringToRune(string, int) (int, int); // convert bytes to runes
export func Exit(int);
func Exit(int);
export func Caller(n int) (pc uint64, file string, line int, ok bool);
func Caller(n int) (pc uint64, file string, line int, ok bool);
export func SemAcquire(sema *int32);
export func SemRelease(sema *int32);
func SemAcquire(sema *int32);
func SemRelease(sema *int32);
......@@ -52,7 +52,7 @@ import "fmt"
// results are packed again. For faster unpacking/packing, the base size
// in bits must be even.
export type (
type (
Digit uint64;
Digit2 uint32; // half-digits for division
)
......@@ -91,7 +91,7 @@ func isSmall(x Digit) bool {
}
export func Dump(x []Digit) {
func Dump(x []Digit) {
print("[", len(x), "]");
for i := len(x) - 1; i >= 0; i-- {
print(" ", x[i]);
......@@ -111,7 +111,7 @@ export func Dump(x []Digit) {
// n, m len(x), len(y)
export type Natural []Digit;
type Natural []Digit;
var (
natZero Natural = Natural{};
......@@ -123,7 +123,7 @@ var (
// Creation
export func Nat(x uint) Natural {
func Nat(x uint) Natural {
switch x {
case 0: return natZero;
case 1: return natOne;
......@@ -696,7 +696,7 @@ func muladd1(x Natural, d, c Digit) Natural {
// Determines base (octal, decimal, hexadecimal) if base == 0.
// Returns the number and base.
export func NatFromString(s string, base uint, slen *int) (Natural, uint) {
func NatFromString(s string, base uint, slen *int) (Natural, uint) {
// determine base if necessary
i, n := 0, len(s);
if base == 0 {
......@@ -766,7 +766,7 @@ func (xp Natural) Pow(n uint) Natural {
}
export func MulRange(a, b uint) Natural {
func MulRange(a, b uint) Natural {
switch {
case a > b: return Nat(1);
case a == b: return Nat(a);
......@@ -778,14 +778,14 @@ export func MulRange(a, b uint) Natural {
}
export func Fact(n uint) Natural {
func Fact(n uint) Natural {
// Using MulRange() instead of the basic for-loop
// lead to faster factorial computation.
return MulRange(2, n);
}
export func Binomial(n, k uint) Natural {
func Binomial(n, k uint) Natural {
return MulRange(n-k+1, n).Div(MulRange(1, k));
}
......@@ -806,7 +806,7 @@ func (xp Natural) Gcd(y Natural) Natural {
// Integers are normalized if the mantissa is normalized and the sign is
// false for mant == 0. Use MakeInt to create normalized Integers.
export type Integer struct {
type Integer struct {
sign bool;
mant Natural;
}
......@@ -814,7 +814,7 @@ export type Integer struct {
// Creation
export func MakeInt(sign bool, mant Natural) *Integer {
func MakeInt(sign bool, mant Natural) *Integer {
if mant.IsZero() {
sign = false; // normalize
}
......@@ -822,7 +822,7 @@ export func MakeInt(sign bool, mant Natural) *Integer {
}
export func Int(x int) *Integer {
func Int(x int) *Integer {
sign := false;
var ux uint;
if x < 0 {
......@@ -1103,7 +1103,7 @@ func (x *Integer) Format(h fmt.Formatter, c int) {
// Determines base (octal, decimal, hexadecimal) if base == 0.
// Returns the number and base.
export func IntFromString(s string, base uint, slen *int) (*Integer, uint) {
func IntFromString(s string, base uint, slen *int) (*Integer, uint) {
// get sign, if any
sign := false;
if len(s) > 0 && (s[0] == '-' || s[0] == '+') {
......@@ -1126,7 +1126,7 @@ export func IntFromString(s string, base uint, slen *int) (*Integer, uint) {
// ----------------------------------------------------------------------------
// Rational numbers
export type Rational struct {
type Rational struct {
a *Integer; // numerator
b Natural; // denominator
}
......@@ -1134,7 +1134,7 @@ export type Rational struct {
// Creation
export func MakeRat(a *Integer, b Natural) *Rational {
func MakeRat(a *Integer, b Natural) *Rational {
f := a.mant.Gcd(b); // f > 0
if f.Cmp(Nat(1)) != 0 {
a = MakeInt(a.sign, a.mant.Div(f));
......@@ -1144,7 +1144,7 @@ export func MakeRat(a *Integer, b Natural) *Rational {
}
export func Rat(a0 int, b0 int) *Rational {
func Rat(a0 int, b0 int) *Rational {
a, b := Int(a0), Int(b0);
if b.sign {
a = a.Neg();
......@@ -1233,7 +1233,7 @@ func (x *Rational) Format(h fmt.Formatter, c int) {
// Determines base (octal, decimal, hexadecimal) if base == 0.
// Returns the number and base of the nominator.
export func RatFromString(s string, base uint, slen *int) (*Rational, uint) {
func RatFromString(s string, base uint, slen *int) (*Rational, uint) {
// read nominator
var alen, blen int;
a, abase := IntFromString(s, base, &alen);
......
......@@ -90,7 +90,7 @@ func rat_eq(n uint, x, y *bignum.Rational) {
}
}
export func TestNatConv(t *testing.T) {
func TestNatConv(t *testing.T) {
tester = t;
test_msg = "NatConvA";
nat_eq(0, a, bignum.Nat(991));
......@@ -122,7 +122,7 @@ export func TestNatConv(t *testing.T) {
}
export func TestIntConv(t *testing.T) {
func TestIntConv(t *testing.T) {
tester = t;
test_msg = "IntConv";
var slen int;
......@@ -140,7 +140,7 @@ export func TestIntConv(t *testing.T) {
}
export func TestRatConv(t *testing.T) {
func TestRatConv(t *testing.T) {
tester = t;
test_msg = "RatConv";
var slen int;
......@@ -176,7 +176,7 @@ func sum(n uint, scale bignum.Natural) bignum.Natural {
}
export func TestNatAdd(t *testing.T) {
func TestNatAdd(t *testing.T) {
tester = t;
test_msg = "NatAddA";
nat_eq(0, add(nat_zero, nat_zero), nat_zero);
......@@ -206,7 +206,7 @@ func mul(x, y bignum.Natural) bignum.Natural {
}
export func TestNatSub(t *testing.T) {
func TestNatSub(t *testing.T) {
tester = t;
test_msg = "NatSubA";
nat_eq(0, nat_zero.Sub(nat_zero), nat_zero);
......@@ -223,7 +223,7 @@ export func TestNatSub(t *testing.T) {
}
export func TestNatMul(t *testing.T) {
func TestNatMul(t *testing.T) {
tester = t;
test_msg = "NatMulA";
nat_eq(0, mul(c, nat_zero), nat_zero);
......@@ -242,7 +242,7 @@ export func TestNatMul(t *testing.T) {
}
export func TestNatDiv(t *testing.T) {
func TestNatDiv(t *testing.T) {
tester = t;
test_msg = "NatDivA";
nat_eq(0, c.Div(nat_one), c);
......@@ -260,7 +260,7 @@ export func TestNatDiv(t *testing.T) {
}
export func TestIntQuoRem(t *testing.T) {
func TestIntQuoRem(t *testing.T) {
tester = t;
test_msg = "IntQuoRem";
type T struct { x, y, q, r int };
......@@ -287,7 +287,7 @@ export func TestIntQuoRem(t *testing.T) {
}
export func TestIntDivMod(t *testing.T) {
func TestIntDivMod(t *testing.T) {
tester = t;
test_msg = "IntDivMod";
type T struct { x, y, q, r int };
......@@ -314,7 +314,7 @@ export func TestIntDivMod(t *testing.T) {
}
export func TestNatMod(t *testing.T) {
func TestNatMod(t *testing.T) {
tester = t;
test_msg = "NatModA";
for i := uint(0); ; i++ {
......@@ -330,7 +330,7 @@ export func TestNatMod(t *testing.T) {
}
export func TestNatShift(t *testing.T) {
func TestNatShift(t *testing.T) {
tester = t;
test_msg = "NatShift1L";
test(0, b.Shl(0).Cmp(b) == 0);
......@@ -365,7 +365,7 @@ export func TestNatShift(t *testing.T) {
}
export func TestIntShift(t *testing.T) {
func TestIntShift(t *testing.T) {
tester = t;
test_msg = "IntShift1L";
test(0, ip.Shl(0).Cmp(ip) == 0);
......@@ -404,7 +404,7 @@ export func TestIntShift(t *testing.T) {
}
export func TestNatCmp(t *testing.T) {
func TestNatCmp(t *testing.T) {
tester = t;
test_msg = "NatCmp";
test(0, a.Cmp(a) == 0);
......@@ -417,14 +417,14 @@ export func TestNatCmp(t *testing.T) {
}
export func TestNatLog2(t *testing.T) {
func TestNatLog2(t *testing.T) {
tester = t;
test_msg = "NatLog2A";
test(0, nat_one.Log2() == 0);
test(1, nat_two.Log2() == 1);
test(2, bignum.Nat(3).Log2() == 1);
test(3, bignum.Nat(4).Log2() == 2);
test_msg = "NatLog2B";
for i := uint(0); i < 100; i++ {
test(i, nat_one.Shl(i).Log2() == i);
......@@ -432,7 +432,7 @@ export func TestNatLog2(t *testing.T) {
}
export func TestNatGcd(t *testing.T) {
func TestNatGcd(t *testing.T) {
tester = t;
test_msg = "NatGcdA";
f := bignum.Nat(99991);
......@@ -440,7 +440,7 @@ export func TestNatGcd(t *testing.T) {
}
export func TestNatPow(t *testing.T) {
func TestNatPow(t *testing.T) {
tester = t;
test_msg = "NatPowA";
nat_eq(0, nat_two.Pow(0), nat_one);
......@@ -452,7 +452,7 @@ export func TestNatPow(t *testing.T) {
}
export func TestNatPop(t *testing.T) {
func TestNatPop(t *testing.T) {
tester = t;
test_msg = "NatPopA";
test(0, nat_zero.Pop() == 0);
......
......@@ -21,7 +21,7 @@ const (
defaultBufSize = 4096
)
export var (
var (
EndOfFile = os.NewError("end of file");
PhaseError = os.NewError("phase error");
BufferFull = os.NewError("buffer full");
......@@ -39,14 +39,14 @@ func copySlice(dst []byte, src []byte) {
// Buffered input.
export type BufRead struct {
type BufRead struct {
buf []byte;
rd io.Read;
r, w int;
err *os.Error;
}
export func NewBufReadSize(rd io.Read, size int) (b *BufRead, err *os.Error) {
func NewBufReadSize(rd io.Read, size int) (b *BufRead, err *os.Error) {
if size <= 0 {
return nil, BadBufSize
}
......@@ -56,7 +56,7 @@ export func NewBufReadSize(rd io.Read, size int) (b *BufRead, err *os.Error) {
return b, nil
}
export func NewBufRead(rd io.Read) (b *BufRead, err *os.Error) {
func NewBufRead(rd io.Read) (b *BufRead, err *os.Error) {
return NewBufReadSize(rd, defaultBufSize);
}
......@@ -326,14 +326,14 @@ func (b *BufRead) ReadLineString(delim byte, savedelim bool) (line string, err *
// buffered output
export type BufWrite struct {
type BufWrite struct {
err *os.Error;
buf []byte;
n int;
wr io.Write;
}
export func NewBufWriteSize(wr io.Write, size int) (b *BufWrite, err *os.Error) {
func NewBufWriteSize(wr io.Write, size int) (b *BufWrite, err *os.Error) {
if size <= 0 {
return nil, BadBufSize
}
......@@ -343,7 +343,7 @@ export func NewBufWriteSize(wr io.Write, size int) (b *BufWrite, err *os.Error)
return b, nil
}
export func NewBufWrite(wr io.Write) (b *BufWrite, err *os.Error) {
func NewBufWrite(wr io.Write) (b *BufWrite, err *os.Error) {
return NewBufWriteSize(wr, defaultBufSize);
}
......
......@@ -173,7 +173,7 @@ var bufsizes = []int {
23, 32, 46, 64, 93, 128, 1024, 4096
}
export func TestBufReadSimple(t *testing.T) {
func TestBufReadSimple(t *testing.T) {
b, e := NewBufRead(newByteReader(io.StringBytes("hello world")));
if s := readBytes(b); s != "hello world" {
t.Errorf("simple hello world test failed: got %q", s);
......@@ -185,7 +185,7 @@ export func TestBufReadSimple(t *testing.T) {
}
}
export func TestBufRead(t *testing.T) {
func TestBufRead(t *testing.T) {
var texts [31]string;
str := "";
all := "";
......@@ -278,7 +278,7 @@ type writeMaker struct {
name string;
fn *()writeBuffer;
}
export func TestBufWrite(t *testing.T) {
func TestBufWrite(t *testing.T) {
var data [8192]byte;
var writers = []writeMaker {
......
......@@ -4,11 +4,11 @@
package array
export type Element interface {
type Element interface {
}
export type Array struct {
type Array struct {
// TODO do not export field
a []Element
}
......@@ -35,7 +35,7 @@ func (p *Array) Init(initial_len int) *Array {
}
export func New(len int) *Array {
func New(len int) *Array {
return new(Array).Init(len)
}
......@@ -112,7 +112,7 @@ func (p *Array) Pop() Element {
// Partial SortInterface support
export type LessInterface interface {
type LessInterface interface {
Less(y Element) bool
}
......
......@@ -9,7 +9,7 @@ import "testing"
import "sort"
export func TestInit(t *testing.T) {
func TestInit(t *testing.T) {
var a array.Array;
if a.Init(0).Len() != 0 { t.Error("A") }
if a.Init(1).Len() != 1 { t.Error("B") }
......@@ -17,19 +17,19 @@ export func TestInit(t *testing.T) {
}
export func TestNew(t *testing.T) {
func TestNew(t *testing.T) {
if array.New(0).Len() != 0 { t.Error("A") }
if array.New(1).Len() != 1 { t.Error("B") }
if array.New(10).Len() != 10 { t.Error("C") }
}
export func Val(i int) int {
func Val(i int) int {
return i*991 - 1234
}
export func TestAccess(t *testing.T) {
func TestAccess(t *testing.T) {
const n = 100;
var a array.Array;
a.Init(n);
......@@ -42,7 +42,7 @@ export func TestAccess(t *testing.T) {
}
export func TestInsertRemoveClear(t *testing.T) {
func TestInsertRemoveClear(t *testing.T) {
const n = 100;
a := array.New(0);
......@@ -81,7 +81,7 @@ export func TestInsertRemoveClear(t *testing.T) {
/* currently doesn't compile due to linker bug
export func TestSorting(t *testing.T) {
func TestSorting(t *testing.T) {
const n = 100;
a := array.NewIntArray(n);
for i := n-1; i >= 0; i-- {
......
......@@ -6,7 +6,7 @@ package array
import "array"
export type IntArray struct {
type IntArray struct {
// TODO do not export field
array.Array;
}
......@@ -18,7 +18,7 @@ func (p *IntArray) Init(len int) *IntArray {
}
export func NewIntArray(len int) *IntArray {
func NewIntArray(len int) *IntArray {
return new(IntArray).Init(len)
}
......
......@@ -218,7 +218,7 @@ type _Value interface {
}
// -- Flag structure (internal)
export type Flag struct {
type Flag struct {
name string;
usage string;
value _Value;
......@@ -232,13 +232,13 @@ type allFlags struct {
var flags *allFlags = &allFlags{make(map[string] *Flag), make(map[string] *Flag), 1}
export func PrintDefaults() {
func PrintDefaults() {
for k, f := range flags.formal {
print(" -", f.name, "=", f.value.str(), ": ", f.usage, "\n");
}
}
export func Usage() {
func Usage() {
if len(sys.Args) > 0 {
print("Usage of ", sys.Args[0], ": \n");
} else {
......@@ -248,11 +248,11 @@ export func Usage() {
sys.Exit(1);
}
export func NFlag() int {
func NFlag() int {
return len(flags.actual)
}
export func Arg(i int) string {
func Arg(i int) string {
i += flags.first_arg;
if i < 0 || i >= len(sys.Args) {
return "";
......@@ -260,7 +260,7 @@ export func Arg(i int) string {
return sys.Args[i]
}
export func NArg() int {
func NArg() int {
return len(sys.Args) - flags.first_arg
}
......@@ -277,63 +277,63 @@ func add(name string, value _Value, usage string) {
flags.formal[name] = f;
}
export func Bool(name string, value bool, usage string) *bool {
func Bool(name string, value bool, usage string) *bool {
p := new(bool);
add(name, newBoolValue(value, p), usage);
return p;
}
export func BoolVar(p *bool, name string, value bool, usage string) {
func BoolVar(p *bool, name string, value bool, usage string) {
add(name, newBoolValue(value, p), usage);
}
export func Int(name string, value int, usage string) *int {
func Int(name string, value int, usage string) *int {
p := new(int);
add(name, newIntValue(value, p), usage);
return p;
}
export func IntVar(p *int, name string, value int, usage string) {
func IntVar(p *int, name string, value int, usage string) {
add(name, newIntValue(value, p), usage);
}
export func Int64(name string, value int64, usage string) *int64 {
func Int64(name string, value int64, usage string) *int64 {
p := new(int64);
add(name, newInt64Value(value, p), usage);
return p;
}
export func Int64Var(p *int64, name string, value int64, usage string) {
func Int64Var(p *int64, name string, value int64, usage string) {
add(name, newInt64Value(value, p), usage);
}
export func Uint(name string, value uint, usage string) *uint {
func Uint(name string, value uint, usage string) *uint {
p := new(uint);
add(name, newUintValue(value, p), usage);
return p;
}
export func UintVar(p *uint, name string, value uint, usage string) {
func UintVar(p *uint, name string, value uint, usage string) {
add(name, newUintValue(value, p), usage);
}
export func Uint64(name string, value uint64, usage string) *uint64 {
func Uint64(name string, value uint64, usage string) *uint64 {
p := new(uint64);
add(name, newUint64Value(value, p), usage);
return p;
}
export func Uint64Var(p *uint64, name string, value uint64, usage string) {
func Uint64Var(p *uint64, name string, value uint64, usage string) {
add(name, newUint64Value(value, p), usage);
}
export func String(name, value string, usage string) *string {
func String(name, value string, usage string) *string {
p := new(string);
add(name, newStringValue(value, p), usage);
return p;
}
export func StringVar(p *string, name, value string, usage string) {
func StringVar(p *string, name, value string, usage string) {
add(name, newStringValue(value, p), usage);
}
......@@ -432,7 +432,7 @@ func (f *allFlags) ParseOne(index int) (ok bool, next int)
return true, index + 1
}
export func Parse() {
func Parse() {
for i := 1; i < len(sys.Args); {
ok, next := flags.ParseOne(i);
if next > 0 {
......
......@@ -11,7 +11,7 @@ import (
"testing";
)
export func TestFmtInterface(t *testing.T) {
func TestFmtInterface(t *testing.T) {
var i1 interface{};
i1 = "abc";
s := fmt.Sprintf("%s", i1);
......@@ -150,7 +150,7 @@ var fmttests = []fmtTest{
fmtTest{ "%20g", sys.NaN(), " NaN" },
}
export func TestSprintf(t *testing.T) {
func TestSprintf(t *testing.T) {
for i := 0; i < len(fmttests); i++ {
tt := fmttests[i];
s := fmt.Sprintf(tt.fmt, tt.val);
......@@ -204,7 +204,7 @@ var flagtests = []flagTest {
flagTest{ "%-1.2abc", "[%-1.2a]bc" },
}
export func TestFlagParser(t *testing.T) {
func TestFlagParser(t *testing.T) {
var flagprinter flagPrinter;
for i := 0; i < len(flagtests); i++ {
tt := flagtests[i];
......@@ -215,7 +215,7 @@ export func TestFlagParser(t *testing.T) {
}
}
export func TestStructPrinter(t *testing.T) {
func TestStructPrinter(t *testing.T) {
var s struct {
a string;
b string;
......@@ -241,7 +241,7 @@ export func TestStructPrinter(t *testing.T) {
}
}
export func TestArrayPrinter(t *testing.T) {
func TestArrayPrinter(t *testing.T) {
a := []int{1, 2, 3, 4, 5};
want := "[1 2 3 4 5]";
out := fmt.Sprintf("%v", a);
......
......@@ -33,7 +33,7 @@ func init() {
}
}
export type Fmt struct {
type Fmt struct {
buf string;
wid int;
wid_present bool;
......@@ -68,7 +68,7 @@ func (f *Fmt) init() {
f.clearflags();
}
export func New() *Fmt {
func New() *Fmt {
f := new(Fmt);
f.init();
return f;
......
......@@ -20,7 +20,7 @@ import (
// Representation of printer state passed to custom formatters.
// Provides access to the io.Write interface plus information about
// the active formatting verb.
export type Formatter interface {
type Formatter interface {
Write(b []byte) (ret int, err *os.Error);
Width() (wid int, ok bool);
Precision() (prec int, ok bool);
......@@ -29,11 +29,11 @@ export type Formatter interface {
Flag(int) bool;
}
export type Format interface {
type Format interface {
Format(f Formatter, c int);
}
export type String interface {
type String interface {
String() string
}
......@@ -129,7 +129,7 @@ func (p *pp) doprint(v reflect.StructValue, addspace, addnewline bool);
// These routines end in 'f' and take a format string.
export func Fprintf(w io.Write, format string, a ...) (n int, error *os.Error) {
func Fprintf(w io.Write, format string, a ...) (n int, error *os.Error) {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
p := newPrinter();
p.doprintf(format, v);
......@@ -137,12 +137,12 @@ export func Fprintf(w io.Write, format string, a ...) (n int, error *os.Error) {
return n, error;
}
export func Printf(format string, v ...) (n int, errno *os.Error) {
func Printf(format string, v ...) (n int, errno *os.Error) {
n, errno = Fprintf(os.Stdout, format, v);
return n, errno;
}
export func Sprintf(format string, a ...) string {
func Sprintf(format string, a ...) string {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
p := newPrinter();
p.doprintf(format, v);
......@@ -153,7 +153,7 @@ export func Sprintf(format string, a ...) string {
// These routines do not take a format string and add spaces only
// when the operand on neither side is a string.
export func Fprint(w io.Write, a ...) (n int, error *os.Error) {
func Fprint(w io.Write, a ...) (n int, error *os.Error) {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
p := newPrinter();
p.doprint(v, false, false);
......@@ -161,12 +161,12 @@ export func Fprint(w io.Write, a ...) (n int, error *os.Error) {
return n, error;
}
export func Print(v ...) (n int, errno *os.Error) {
func Print(v ...) (n int, errno *os.Error) {
n, errno = Fprint(os.Stdout, v);
return n, errno;
}
export func Sprint(a ...) string {
func Sprint(a ...) string {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
p := newPrinter();
p.doprint(v, false, false);
......@@ -178,7 +178,7 @@ export func Sprint(a ...) string {
// always add spaces between operands, and add a newline
// after the last operand.
export func Fprintln(w io.Write, a ...) (n int, error *os.Error) {
func Fprintln(w io.Write, a ...) (n int, error *os.Error) {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
p := newPrinter();
p.doprint(v, true, true);
......@@ -186,12 +186,12 @@ export func Fprintln(w io.Write, a ...) (n int, error *os.Error) {
return n, error;
}
export func Println(v ...) (n int, errno *os.Error) {
func Println(v ...) (n int, errno *os.Error) {
n, errno = Fprintln(os.Stdout, v);
return n, errno;
}
export func Sprintln(a ...) string {
func Sprintln(a ...) string {
v := reflect.NewValue(a).(reflect.PtrValue).Sub().(reflect.StructValue);
p := newPrinter();
p.doprint(v, true, true);
......
......@@ -14,7 +14,7 @@ package adler32
import "os"
export type Digest struct {
type Digest struct {
a, b uint32;
n int;
}
......@@ -24,7 +24,7 @@ const (
_MaxIter = 5552; // max mod-free iterations before would overflow uint32
)
export func NewDigest() *Digest {
func NewDigest() *Digest {
return &Digest{1, 0, 0};
}
......
......@@ -49,7 +49,7 @@ var golden = []_Adler32Test {
_Adler32Test{ 0x2e5d1316, "How can you write a big system without C++? -Paul Glick" },
}
export func TestGolden(t *testing.T) {
func TestGolden(t *testing.T) {
for i := 0; i < len(golden); i++ {
g := golden[i];
c := NewDigest();
......
......@@ -9,7 +9,7 @@ package crc32
import "os"
export const (
const (
// Far and away the most common CRC-32 polynomial.
// Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, mpeg-2, ...
IEEE = 0xedb88320;
......@@ -26,9 +26,9 @@ export const (
)
// TODO(rsc): Change to [256]uint32 once 6g can handle it.
export type Table []uint32
type Table []uint32
export func MakeTable(poly uint32) Table {
func MakeTable(poly uint32) Table {
t := make(Table, 256);
for i := 0; i < 256; i++ {
crc := uint32(i);
......@@ -44,18 +44,18 @@ export func MakeTable(poly uint32) Table {
return t;
}
export var IEEETable = MakeTable(IEEE);
var IEEETable = MakeTable(IEEE);
export type Digest struct {
type Digest struct {
crc uint32;
tab Table;
}
export func NewDigest(tab Table) *Digest {
func NewDigest(tab Table) *Digest {
return &Digest{0, tab};
}
export func NewIEEEDigest() *Digest {
func NewIEEEDigest() *Digest {
return NewDigest(IEEETable);
}
......
......@@ -49,7 +49,7 @@ var golden = []_Crc32Test {
_Crc32Test{ 0x8e0bb443, "How can you write a big system without C++? -Paul Glick" },
}
export func TestGolden(t *testing.T) {
func TestGolden(t *testing.T) {
for i := 0; i < len(golden); i++ {
g := golden[i];
c := NewIEEEDigest();
......
......@@ -17,14 +17,14 @@ const (
_Init3 = 0x10325476;
)
export type Digest struct {
type Digest struct {
s [4]uint32;
x [_Chunk]byte;
nx int;
len uint64;
}
export func NewDigest() *Digest {
func NewDigest() *Digest {
d := new(Digest);
d.s[0] = _Init0;
d.s[1] = _Init1;
......
......@@ -50,7 +50,7 @@ var golden = []md5Test {
md5Test{ "132f7619d33b523b1d9e5bd8e0928355", "How can you write a big system without C++? -Paul Glick" },
}
export func TestGolden(t *testing.T) {
func TestGolden(t *testing.T) {
for i := 0; i < len(golden); i++ {
g := golden[i];
c := NewDigest();
......
......@@ -18,14 +18,14 @@ const (
_Init4 = 0xC3D2E1F0;
)
export type Digest struct {
type Digest struct {
h [5]uint32;
x [_Chunk]byte;
nx int;
len uint64;
}
export func NewDigest() *Digest {
func NewDigest() *Digest {
d := new(Digest);
d.h[0] = _Init0;
d.h[1] = _Init1;
......
......@@ -52,7 +52,7 @@ var golden = []sha1Test {
sha1Test{ "6627d6904d71420b0bf3886ab629623538689f45", "How can you write a big system without C++? -Paul Glick" },
}
export func TestGolden(t *testing.T) {
func TestGolden(t *testing.T) {
for i := 0; i < len(golden); i++ {
g := golden[i];
c := NewDigest();
......
......@@ -12,7 +12,7 @@ import (
)
// Active HTTP connection (server side).
export type Conn struct {
type Conn struct {
rwc io.ReadWriteClose;
br *bufio.BufRead;
bw *bufio.BufWrite;
......@@ -21,7 +21,7 @@ export type Conn struct {
}
// Create new connection from rwc.
export func NewConn(rwc io.ReadWriteClose) (c *Conn, err *os.Error) {
func NewConn(rwc io.ReadWriteClose) (c *Conn, err *os.Error) {
c = new(Conn);
c.rwc = rwc;
if c.br, err = bufio.NewBufRead(rwc); err != nil {
......
......@@ -19,7 +19,7 @@ const (
_MaxHeaderLines = 1024;
)
export var (
var (
LineTooLong = os.NewError("http header line too long");
ValueTooLong = os.NewError("http header value too long");
HeaderTooLong = os.NewError("http header too long");
......@@ -29,7 +29,7 @@ export var (
)
// HTTP Request
export type Request struct {
type Request struct {
method string; // GET, PUT,etc.
rawurl string;
url *URL; // URI after GET, PUT etc.
......@@ -180,7 +180,7 @@ func parseHTTPVersion(vers string) (int, int, bool) {
}
// Read and parse a request from b.
export func ReadRequest(b *bufio.BufRead) (req *Request, err *os.Error) {
func ReadRequest(b *bufio.BufRead) (req *Request, err *os.Error) {
req = new(Request);
// First line: GET /index.html HTTP/1.0
......
......@@ -36,7 +36,7 @@ func serveConnection(fd net.Conn, raddr string, f *(*Conn, *Request)) {
}
// Web server: already listening on l, call f for each request.
export func Serve(l net.Listener, f *(*Conn, *Request)) *os.Error {
func Serve(l net.Listener, f *(*Conn, *Request)) *os.Error {
// TODO: Make this unnecessary
s, e := os.Getenv("GOMAXPROCS");
if n, ok := strconv.Atoi(s); n < 3 {
......@@ -54,7 +54,7 @@ export func Serve(l net.Listener, f *(*Conn, *Request)) *os.Error {
}
// Web server: listen on address, call f for each request.
export func ListenAndServe(addr string, f *(*Conn, *Request)) *os.Error {
func ListenAndServe(addr string, f *(*Conn, *Request)) *os.Error {
l, e := net.Listen("tcp", addr);
if e != nil {
return e
......
......@@ -12,7 +12,7 @@ import (
"strings"
)
export var (
var (
BadURL = os.NewError("bad url syntax")
)
......@@ -41,7 +41,7 @@ func unhex(c byte) byte {
}
// Unescape %xx into hex.
export func URLUnescape(s string) (string, *os.Error) {
func URLUnescape(s string) (string, *os.Error) {
// Count %, check that they're well-formed.
n := 0;
for i := 0; i < len(s); {
......@@ -76,7 +76,7 @@ export func URLUnescape(s string) (string, *os.Error) {
return string(t), nil;
}
export type URL struct {
type URL struct {
raw string;
scheme string;
rawpath string;
......@@ -127,7 +127,7 @@ func split(s string, c byte, cutc bool) (string, string) {
}
// Parse rawurl into a URL structure.
export func ParseURL(rawurl string) (url *URL, err *os.Error) {
func ParseURL(rawurl string) (url *URL, err *os.Error) {
if rawurl == "" {
return nil, BadURL
}
......@@ -172,7 +172,7 @@ export func ParseURL(rawurl string) (url *URL, err *os.Error) {
}
// A URL reference is a URL with #frag potentially added. Parse it.
export func ParseURLReference(rawurlref string) (url *URL, err *os.Error) {
func ParseURLReference(rawurlref string) (url *URL, err *os.Error) {
// Cut off #frag.
rawurl, frag := split(rawurlref, '#', true);
if url, err = ParseURL(rawurl); err != nil {
......
......@@ -24,7 +24,7 @@ func bytecopy(dst []byte, doff int, src []byte, soff int, count int) {
}
}
export type ByteBuffer struct {
type ByteBuffer struct {
buf []byte;
off int; // Read from here
len int; // Write to here
......@@ -87,8 +87,7 @@ func (b *ByteBuffer) AllData() []byte {
return b.buf[0:b.len]
}
export func NewByteBufferFromArray(buf []byte) *ByteBuffer {
func NewByteBufferFromArray(buf []byte) *ByteBuffer {
b := new(ByteBuffer);
b.buf = buf;
b.off = 0;
......
......@@ -9,28 +9,28 @@ import (
"syscall";
)
export var ErrEOF = os.NewError("EOF")
var ErrEOF = os.NewError("EOF")
export type Read interface {
type Read interface {
Read(p []byte) (n int, err *os.Error);
}
export type Write interface {
type Write interface {
Write(p []byte) (n int, err *os.Error);
}
export type ReadWrite interface {
type ReadWrite interface {
Read(p []byte) (n int, err *os.Error);
Write(p []byte) (n int, err *os.Error);
}
export type ReadWriteClose interface {
type ReadWriteClose interface {
Read(p []byte) (n int, err *os.Error);
Write(p []byte) (n int, err *os.Error);
Close() *os.Error;
}
export func WriteString(w Write, s string) (n int, err *os.Error) {
func WriteString(w Write, s string) (n int, err *os.Error) {
b := make([]byte, len(s)+1);
if !syscall.StringToBytes(b, s) {
return -1, os.EINVAL
......@@ -41,7 +41,7 @@ export func WriteString(w Write, s string) (n int, err *os.Error) {
}
// Read until buffer is full, EOF, or error
export func Readn(fd Read, buf []byte) (n int, err *os.Error) {
func Readn(fd Read, buf []byte) (n int, err *os.Error) {
n = 0;
for n < len(buf) {
nn, e := fd.Read(buf[n:len(buf)]);
......@@ -69,7 +69,7 @@ func (fd *_FullRead) Read(p []byte) (n int, err *os.Error) {
return n, err
}
export func Make_FullReader(fd Read) Read {
func Make_FullReader(fd Read) Read {
if fr, ok := fd.(*_FullRead); ok {
// already a _FullRead
return fd
......@@ -79,7 +79,7 @@ export func Make_FullReader(fd Read) Read {
// Copies n bytes (or until EOF is reached) from src to dst.
// Returns the number of bytes copied and the error, if any.
export func Copyn(src Read, dst Write, n int64) (written int64, err *os.Error) {
func Copyn(src Read, dst Write, n int64) (written int64, err *os.Error) {
buf := make([]byte, 32*1024);
for written < n {
l := len(buf);
......@@ -115,7 +115,7 @@ export func Copyn(src Read, dst Write, n int64) (written int64, err *os.Error) {
// Copies from src to dst until EOF is reached.
// Returns the number of bytes copied and the error, if any.
export func Copy(src Read, dst Write) (written int64, err *os.Error) {
func Copy(src Read, dst Write) (written int64, err *os.Error) {
buf := make([]byte, 32*1024);
for {
nr, er := src.Read(buf);
......@@ -147,7 +147,7 @@ export func Copy(src Read, dst Write) (written int64, err *os.Error) {
// Convert a string to an array of bytes for easy marshaling.
// Could fill with syscall.StringToBytes but it adds an unnecessary \000
// so the length would be wrong.
export func StringBytes(s string) []byte {
func StringBytes(s string) []byte {
b := make([]byte, len(s));
for i := 0; i < len(s); i++ {
b[i] = s[i];
......
......@@ -15,7 +15,7 @@ import (
"strings";
)
export const (
const (
StringKind = iota;
NumberKind;
MapKind; // JSON term is "Object", but in Go, it's a map
......@@ -24,7 +24,7 @@ export const (
NullKind;
)
export type Json interface {
type Json interface {
Kind() int;
String() string;
Number() float64;
......@@ -34,7 +34,7 @@ export type Json interface {
Len() int;
}
export func JsonToString(j Json) string {
func JsonToString(j Json) string {
if j == nil {
return "null"
}
......@@ -45,7 +45,7 @@ export func JsonToString(j Json) string {
}
type _Null struct { }
export var Null Json = &_Null{}
var Null Json = &_Null{}
func (*_Null) Kind() int { return NullKind }
func (*_Null) String() string { return "null" }
func (*_Null) Number() float64 { return 0 }
......@@ -128,7 +128,7 @@ func (j *_Map) String() string {
return s;
}
export func Walk(j Json, path string) Json {
func Walk(j Json, path string) Json {
for len(path) > 0 {
var elem string;
if i := strings.Index(path, "/"); i >= 0 {
......@@ -154,7 +154,7 @@ export func Walk(j Json, path string) Json {
return j
}
export func Equal(a, b Json) bool {
func Equal(a, b Json) bool {
switch {
case a == nil && b == nil:
return true;
......@@ -290,7 +290,7 @@ func (b *_JsonBuilder) Key(k string) Builder {
return bb
}
export func StringToJson(s string) (json Json, ok bool, errtok string) {
func StringToJson(s string) (json Json, ok bool, errtok string) {
var errindx int;
var j Json;
b := new(_JsonBuilder);
......
......@@ -24,7 +24,7 @@ var jsontests = []string {
`{"a":1}`,
}
export func TestJson(t *testing.T) {
func TestJson(t *testing.T) {
for i := 0; i < len(jsontests); i++ {
val, ok, errtok := StringToJson(jsontests[i]);
if !ok {
......@@ -39,7 +39,7 @@ export func TestJson(t *testing.T) {
}
}
export func TestJsonMap(t *testing.T) {
func TestJsonMap(t *testing.T) {
values := make(map[string]Json);
mapstr := "{";
for i := 0; i < len(jsontests); i++ {
......
......@@ -44,7 +44,7 @@ func _UnHex(p string, r, l int) (v int, ok bool) {
return v, true;
}
export func Unquote(s string) (t string, ok bool) {
func Unquote(s string) (t string, ok bool) {
if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' {
return
}
......@@ -117,7 +117,7 @@ export func Unquote(s string) (t string, ok bool) {
return string(b[0:w]), true
}
export func Quote(s string) string {
func Quote(s string) string {
chr := make([]byte, utf8.UTFMax);
chr0 := chr[0:1];
b := new(io.ByteBuffer);
......@@ -272,7 +272,7 @@ func (t *_Lexer) Next() {
type _Value interface {}
export type Builder interface {
type Builder interface {
// Set value
Int64(i int64);
Uint64(i uint64);
......@@ -386,7 +386,7 @@ Switch:
return ok;
}
export func Parse(s string, build Builder) (ok bool, errindx int, errtok string) {
func Parse(s string, build Builder) (ok bool, errindx int, errtok string) {
lex := new(_Lexer);
lex.s = s;
lex.Next();
......
......@@ -202,7 +202,7 @@ func (b *_StructBuilder) Key(k string) Builder {
return nobuilder
}
export func Unmarshal(s string, val interface{}) (ok bool, errtok string) {
func Unmarshal(s string, val interface{}) (ok bool, errtok string) {
var errindx int;
var val1 interface{};
b := &_StructBuilder{ reflect.NewValue(val) };
......
......@@ -46,7 +46,7 @@ func _Check(t *testing.T, ok bool, name string, v interface{}) {
}
}
export func TestUnmarshal(t *testing.T) {
func TestUnmarshal(t *testing.T) {
var m _MyStruct;
m.f = true;
ok, errtok := Unmarshal(_Encoded, &m);
......
......@@ -8,12 +8,12 @@
package malloc
export type Stats struct {
type Stats struct {
Alloc uint64;
Sys uint64;
};
export func Alloc(uint64) *byte;
export func Free(*byte);
export func GetStats() *Stats;
export func Lookup(*byte) (*byte, uintptr);
func Alloc(uint64) *byte;
func Free(*byte);
func GetStats() *Stats;
func Lookup(*byte) (*byte, uintptr);
......@@ -175,7 +175,7 @@ func veryclose(a,b float64) bool {
return tolerance(a, b, 4e-16);
}
export func TestAsin(t *testing.T) {
func TestAsin(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Asin(vf[i]/10); !veryclose(asin[i], f) {
t.Errorf("math.Asin(%g) = %g, want %g\n", vf[i]/10, f, asin[i]);
......@@ -183,7 +183,7 @@ export func TestAsin(t *testing.T) {
}
}
export func TestAtan(t *testing.T) {
func TestAtan(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Atan(vf[i]); !veryclose(atan[i], f) {
t.Errorf("math.Atan(%g) = %g, want %g\n", vf[i], f, atan[i]);
......@@ -191,7 +191,7 @@ export func TestAtan(t *testing.T) {
}
}
export func TestExp(t *testing.T) {
func TestExp(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Exp(vf[i]); !veryclose(exp[i], f) {
t.Errorf("math.Exp(%g) = %g, want %g\n", vf[i], f, exp[i]);
......@@ -199,7 +199,7 @@ export func TestExp(t *testing.T) {
}
}
export func TestFloor(t *testing.T) {
func TestFloor(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Floor(vf[i]); floor[i] != f {
t.Errorf("math.Floor(%g) = %g, want %g\n", vf[i], f, floor[i]);
......@@ -207,7 +207,7 @@ export func TestFloor(t *testing.T) {
}
}
export func TestLog(t *testing.T) {
func TestLog(t *testing.T) {
for i := 0; i < len(vf); i++ {
a := math.Fabs(vf[i]);
if f := math.Log(a); log[i] != f {
......@@ -219,7 +219,7 @@ export func TestLog(t *testing.T) {
}
}
export func TestPow(t *testing.T) {
func TestPow(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Pow(10, vf[i]); !close(pow[i], f) {
t.Errorf("math.Pow(10, %.17g) = %.17g, want %.17g\n", vf[i], f, pow[i]);
......@@ -227,7 +227,7 @@ export func TestPow(t *testing.T) {
}
}
export func TestSin(t *testing.T) {
func TestSin(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Sin(vf[i]); !close(sin[i], f) {
t.Errorf("math.Sin(%g) = %g, want %g\n", vf[i], f, sin[i]);
......@@ -235,7 +235,7 @@ export func TestSin(t *testing.T) {
}
}
export func TestSinh(t *testing.T) {
func TestSinh(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Sinh(vf[i]); !veryclose(sinh[i], f) {
t.Errorf("math.Sinh(%g) = %g, want %g\n", vf[i], f, sinh[i]);
......@@ -243,7 +243,7 @@ export func TestSinh(t *testing.T) {
}
}
export func TestSqrt(t *testing.T) {
func TestSqrt(t *testing.T) {
for i := 0; i < len(vf); i++ {
a := math.Fabs(vf[i]);
if f := math.Sqrt(a); !veryclose(sqrt[i], f) {
......@@ -252,7 +252,7 @@ export func TestSqrt(t *testing.T) {
}
}
export func TestTan(t *testing.T) {
func TestTan(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Tan(vf[i]); !close(tan[i], f) {
t.Errorf("math.Tan(%g) = %g, want %g\n", vf[i], f, tan[i]);
......@@ -260,7 +260,7 @@ export func TestTan(t *testing.T) {
}
}
export func TestTanh(t *testing.T) {
func TestTanh(t *testing.T) {
for i := 0; i < len(vf); i++ {
if f := math.Tanh(vf[i]); !veryclose(tanh[i], f) {
t.Errorf("math.Tanh(%g) = %g, want %g\n", vf[i], f, tanh[i]);
......@@ -268,7 +268,7 @@ export func TestTanh(t *testing.T) {
}
}
export func TestHypot(t *testing.T) {
func TestHypot(t *testing.T) {
for i := 0; i < len(vf); i++ {
a := math.Fabs(tanh[i]*math.Sqrt(2));
if f := math.Hypot(tanh[i], tanh[i]); !veryclose(a, f) {
......
......@@ -13,7 +13,7 @@ import "math"
* Arctan is called after appropriate range reduction.
*/
export func Asin(arg float64) float64 {
func Asin(arg float64) float64 {
var temp, x float64;
var sign bool;
......@@ -40,7 +40,7 @@ export func Asin(arg float64) float64 {
return temp;
}
export func Acos(arg float64) float64 {
func Acos(arg float64) float64 {
if arg > 1 || arg < -1 {
return sys.NaN();
}
......
......@@ -57,7 +57,7 @@ func satan(arg float64) float64 {
* atan makes its argument positive and
* calls the inner routine satan.
*/
export func Atan(arg float64) float64 {
func Atan(arg float64) float64 {
if arg > 0 {
return satan(arg);
}
......
......@@ -10,7 +10,7 @@ import "math"
* atan2 discovers what quadrant the angle
* is in and calls atan.
*/
export func Atan2(arg1, arg2 float64) float64 {
func Atan2(arg1, arg2 float64) float64 {
if arg1+arg2 == arg1 {
if arg1 >= 0 {
return Pi/2;
......
......@@ -4,7 +4,7 @@
package math
export const (
const (
// Mathematical constants.
// Reference: http://www.research.att.com/~njas/sequences/Axxxxxx
......
......@@ -82,7 +82,7 @@ import "math"
// compiler will convert from decimal to binary accurately enough
// to produce the hexadecimal values shown.
export func Exp(x float64) float64 {
func Exp(x float64) float64 {
const (
Ln2Hi = 6.93147180369123816490e-01;
Ln2Lo = 1.90821492927058770002e-10;
......
......@@ -4,7 +4,7 @@
package math
export func Fabs(arg float64) float64 {
func Fabs(arg float64) float64 {
if arg < 0 {
return -arg;
}
......
......@@ -9,7 +9,7 @@ package math
* (resp least >=)
*/
export func Floor(arg float64) float64 {
func Floor(arg float64) float64 {
if arg < 0 {
d, fract := sys.Modf(-arg);
if fract != 0.0 {
......@@ -21,6 +21,6 @@ export func Floor(arg float64) float64 {
return d;
}
export func Ceil(arg float64) float64 {
func Ceil(arg float64) float64 {
return -Floor(-arg);
}
......@@ -8,7 +8,7 @@ package math
* floating-point mod func without infinity or NaN checking
*/
export func Fmod(x, y float64) float64 {
func Fmod(x, y float64) float64 {
if y == 0 {
return x;
}
......
......@@ -12,7 +12,7 @@ package math
* Vol. 27, Number 6, pp. 577-581, Nov. 1983
*/
export func Hypot(p, q float64) float64 {
func Hypot(p, q float64) float64 {
if p < 0 {
p = -p;
}
......
......@@ -70,7 +70,7 @@ import "math"
// compiler will convert from decimal to binary accurately enough
// to produce the hexadecimal values shown.
export func Log(x float64) float64 {
func Log(x float64) float64 {
const (
Ln2Hi = 6.93147180369123816490e-01; /* 3fe62e42 fee00000 */
Ln2Lo = 1.90821492927058770002e-10; /* 3dea39ef 35793c76 */
......@@ -113,7 +113,7 @@ export func Log(x float64) float64 {
return k*Ln2Hi - ((hfsq-(s*(hfsq+R)+k*Ln2Lo)) - f);
}
export func Log10(arg float64) float64 {
func Log10(arg float64) float64 {
if arg <= 0 {
return sys.NaN();
}
......
......@@ -7,7 +7,7 @@ package math
import "math"
// x^y: exponentiation
export func Pow(x, y float64) float64 {
func Pow(x, y float64) float64 {
// TODO: x or y NaN, ±Inf, maybe ±0.
switch {
case y == 0:
......
......@@ -15,7 +15,7 @@ package math
var pow10tab [70]float64;
export func Pow10(e int) float64 {
func Pow10(e int) float64 {
if e < 0 {
return 1/Pow10(-e);
}
......
......@@ -52,13 +52,13 @@ func sinus(arg float64, quad int) float64 {
return temp1/temp2;
}
export func Cos(arg float64) float64 {
func Cos(arg float64) float64 {
if arg < 0 {
arg = -arg;
}
return sinus(arg, 1);
}
export func Sin(arg float64) float64 {
func Sin(arg float64) float64 {
return sinus(arg, 0);
}
......@@ -19,7 +19,7 @@ import "math"
* all arguments.
*/
export func Sinh(arg float64) float64 {
func Sinh(arg float64) float64 {
// The coefficients are #2029 from Hart & Cheney. (20.36D)
const
(
......@@ -58,7 +58,7 @@ export func Sinh(arg float64) float64 {
return temp;
}
export func Cosh(arg float64) float64 {
func Cosh(arg float64) float64 {
if arg < 0 {
arg = - arg;
}
......
......@@ -11,7 +11,7 @@ package math
* calls frexp
*/
export func Sqrt(arg float64) float64 {
func Sqrt(arg float64) float64 {
if sys.IsInf(arg, 1) {
return arg;
}
......
......@@ -10,7 +10,7 @@ import "math"
* floating point tangent
*/
export func Tan(arg float64) float64 {
func Tan(arg float64) float64 {
// Coefficients are #4285 from Hart & Cheney. (19.74D)
const
(
......
......@@ -14,7 +14,7 @@ import "math"
* would cause overflow improperly.
*/
export func Tanh(arg float64) float64 {
func Tanh(arg float64) float64 {
if arg < 0 {
arg = -arg;
if arg > 21 {
......
......@@ -64,7 +64,7 @@ var googleaddrs = []string {
"[2001:4860:0:2001::68]:80" // ipv6.google.com; removed if ipv6 flag not set
}
export func TestDialGoogle(t *testing.T) {
func TestDialGoogle(t *testing.T) {
// If no ipv6 tunnel, don't try the last address.
if !*ipv6 {
googleaddrs[len(googleaddrs)-1] = ""
......
......@@ -25,7 +25,7 @@ import (
"strings";
)
export var (
var (
DNS_InternalError = os.NewError("internal dns error");
DNS_MissingConfig = os.NewError("no dns configuration");
DNS_No_Answer = os.NewError("dns got no answer");
......@@ -171,7 +171,7 @@ func _LoadConfig() {
cfg = DNS_ReadConfig();
}
export func LookupHost(name string) (name1 string, addrs []string, err *os.Error) {
func LookupHost(name string) (name1 string, addrs []string, err *os.Error) {
// TODO(rsc): Pick out obvious non-DNS names to avoid
// sending stupid requests to the server?
......
......@@ -13,7 +13,7 @@ import (
"strconv";
)
export type DNS_Config struct {
type DNS_Config struct {
servers []string; // servers to use
search []string; // suffixes to append to local name
ndots int; // number of dots in name to trigger absolute lookup
......@@ -26,7 +26,7 @@ export type DNS_Config struct {
// TODO(rsc): Supposed to call uname() and chop the beginning
// of the host name to get the default search domain.
// We assume it's in resolv.conf anyway.
export func DNS_ReadConfig() *DNS_Config {
func DNS_ReadConfig() *DNS_Config {
file := _Open("/etc/resolv.conf");
if file == nil {
return nil
......
......@@ -32,7 +32,7 @@ import (
// _Packet formats
// Wire constants.
export const (
const (
// valid DNS_RR_Header.rrtype and DNS_Question.qtype
DNS_TypeA = 1;
DNS_TypeNS = 2;
......@@ -90,7 +90,7 @@ const (
)
// DNS queries.
export type DNS_Question struct {
type DNS_Question struct {
name string "domain-name"; // "domain-name" specifies encoding; see packers below
qtype uint16;
qclass uint16;
......@@ -99,7 +99,7 @@ export type DNS_Question struct {
// DNS responses (resource records).
// There are many types of messages,
// but they all share the same header.
export type DNS_RR_Header struct {
type DNS_RR_Header struct {
name string "domain-name";
rrtype uint16;
class uint16;
......@@ -111,62 +111,62 @@ func (h *DNS_RR_Header) Header() *DNS_RR_Header {
return h
}
export type DNS_RR interface {
type DNS_RR interface {
Header() *DNS_RR_Header
}
// Specific DNS RR formats for each query type.
export type DNS_RR_CNAME struct {
type DNS_RR_CNAME struct {
DNS_RR_Header;
cname string "domain-name";
}
export type DNS_RR_HINFO struct {
type DNS_RR_HINFO struct {
DNS_RR_Header;
cpu string;
os string;
}
export type DNS_RR_MB struct {
type DNS_RR_MB struct {
DNS_RR_Header;
mb string "domain-name";
}
export type DNS_RR_MG struct {
type DNS_RR_MG struct {
DNS_RR_Header;
mg string "domain-name";
}
export type DNS_RR_MINFO struct {
type DNS_RR_MINFO struct {
DNS_RR_Header;
rmail string "domain-name";
email string "domain-name";
}
export type DNS_RR_MR struct {
type DNS_RR_MR struct {
DNS_RR_Header;
mr string "domain-name";
}
export type DNS_RR_MX struct {
type DNS_RR_MX struct {
DNS_RR_Header;
pref uint16;
mx string "domain-name";
}
export type DNS_RR_NS struct {
type DNS_RR_NS struct {
DNS_RR_Header;
ns string "domain-name";
}
export type DNS_RR_PTR struct {
type DNS_RR_PTR struct {
DNS_RR_Header;
ptr string "domain-name";
}
export type DNS_RR_SOA struct {
type DNS_RR_SOA struct {
DNS_RR_Header;
ns string "domain-name";
mbox string "domain-name";
......@@ -177,12 +177,12 @@ export type DNS_RR_SOA struct {
minttl uint32;
}
export type DNS_RR_TXT struct {
type DNS_RR_TXT struct {
DNS_RR_Header;
txt string; // not domain name
}
export type DNS_RR_A struct {
type DNS_RR_A struct {
DNS_RR_Header;
a uint32 "ipv4";
}
......@@ -537,7 +537,7 @@ type _DNS_Msg_Top struct {
rcode int;
}
export type DNS_Msg struct {
type DNS_Msg struct {
_DNS_Msg_Top;
question []DNS_Question;
answer []DNS_RR;
......
......@@ -15,7 +15,7 @@ import (
// Network file descriptor. Only intended to be used internally,
// but have to export to make it available in other files implementing package net.
export type FD struct {
type FD struct {
// immutable until Close
fd int64;
osfd *os.FD;
......@@ -207,7 +207,7 @@ func _StartServer() {
pollserver = p
}
export func NewFD(fd int64) (f *FD, err *os.Error) {
func NewFD(fd int64) (f *FD, err *os.Error) {
if pollserver == nil {
once.Do(&_StartServer);
}
......
......@@ -12,13 +12,13 @@ import (
"syscall";
)
export type Pollster struct {
type Pollster struct {
kq int64;
eventbuf [10]syscall.Kevent_t;
events []syscall.Kevent_t;
}
export func NewPollster() (p *Pollster, err *os.Error) {
func NewPollster() (p *Pollster, err *os.Error) {
p = new(Pollster);
var e int64;
if p.kq, e = syscall.Kqueue(); e != 0 {
......
......@@ -17,14 +17,14 @@ const (
writeFlags = syscall.EPOLLOUT
)
export type Pollster struct {
type Pollster struct {
epfd int64;
// Events we're already waiting for
events map[int64] uint32;
}
export func NewPollster() (p *Pollster, err *os.Error) {
func NewPollster() (p *Pollster, err *os.Error) {
p = new(Pollster);
var e int64;
......
......@@ -16,7 +16,7 @@ import (
"net"
)
export const (
const (
IPv4len = 4;
IPv6len = 16
)
......@@ -37,7 +37,7 @@ func _MakeIPv4(a, b, c, d byte) []byte {
}
// Well-known IP addresses
export var IPv4bcast, IPv4allsys, IPv4allrouter, IPv4prefix, IPallbits, IPnoaddr []byte
var IPv4bcast, IPv4allsys, IPv4allrouter, IPv4prefix, IPallbits, IPnoaddr []byte
func init() {
IPv4bcast = _MakeIPv4(0xff, 0xff, 0xff, 0xff);
......@@ -63,7 +63,7 @@ func _IsZeros(p []byte) bool {
// Is p an IPv4 address (perhaps in IPv6 form)?
// If so, return the 4-byte V4 array.
export func ToIPv4(p []byte) []byte {
func ToIPv4(p []byte) []byte {
if len(p) == IPv4len {
return p
}
......@@ -77,7 +77,7 @@ export func ToIPv4(p []byte) []byte {
}
// Convert p to IPv6 form.
export func ToIPv6(p []byte) []byte {
func ToIPv6(p []byte) []byte {
if len(p) == IPv4len {
return _MakeIPv4(p[0], p[1], p[2], p[3])
}
......@@ -88,13 +88,13 @@ export func ToIPv6(p []byte) []byte {
}
// Default route masks for IPv4.
export var (
var (
ClassAMask = _MakeIPv4(0xff, 0, 0, 0);
ClassBMask = _MakeIPv4(0xff, 0xff, 0, 0);
ClassCMask = _MakeIPv4(0xff, 0xff, 0xff, 0);
)
export func DefaultMask(p []byte) []byte {
func DefaultMask(p []byte) []byte {
if p = ToIPv4(p); p == nil {
return nil
}
......@@ -110,7 +110,7 @@ export func DefaultMask(p []byte) []byte {
}
// Apply mask to ip, returning new address.
export func Mask(ip []byte, mask []byte) []byte {
func Mask(ip []byte, mask []byte) []byte {
n := len(ip);
if n != len(mask) {
return nil
......@@ -159,7 +159,7 @@ func itox(i uint) string {
}
// Convert IP address to string.
export func IPToString(p []byte) string {
func IPToString(p []byte) string {
// If IPv4, use dotted notation.
if p4 := ToIPv4(p); len(p4) == 4 {
return itod(uint(p4[0]))+"."
......@@ -228,7 +228,7 @@ func _SimpleMaskLength(mask []byte) int {
return n
}
export func MaskToString(mask []byte) string {
func MaskToString(mask []byte) string {
switch len(mask) {
case 4:
n := _SimpleMaskLength(mask);
......@@ -377,7 +377,7 @@ L: for j < IPv6len {
return p
}
export func ParseIP(s string) []byte {
func ParseIP(s string) []byte {
p := _ParseIPv4(s);
if p != nil {
return p
......
......@@ -43,7 +43,7 @@ var parseiptests = []parseIPTest {
parseIPTest{"::ffff:4a7d:1363", _IPv4(74, 125, 19, 99)},
}
export func TestParseIP(t *testing.T) {
func TestParseIP(t *testing.T) {
for i := 0; i < len(parseiptests); i++ {
tt := parseiptests[i];
if out := ParseIP(tt.in); !isEqual(out, tt.out) {
......
......@@ -11,7 +11,7 @@ import (
"syscall";
)
export var (
var (
BadAddress = os.NewError("malformed address");
MissingAddress = os.NewError("missing address");
UnknownNetwork = os.NewError("unknown network");
......@@ -21,7 +21,7 @@ export var (
Unknown_SocketFamily = os.NewError("unknown socket family");
)
export func LookupHost(name string) (name1 string, addrs []string, err *os.Error)
func LookupHost(name string) (name1 string, addrs []string, err *os.Error)
// Split "host:port" into "host" and "port".
// Host cannot contain colons unless it is bracketed.
......@@ -358,7 +358,7 @@ func _InternetSocket(net, laddr, raddr string, proto int64, mode string) (fd *FD
// TCP connections.
export type ConnTCP struct {
type ConnTCP struct {
_ConnBase
}
......@@ -377,7 +377,7 @@ func _NewConnTCP(fd *FD, raddr string) *ConnTCP {
return c
}
export func DialTCP(net, laddr, raddr string) (c *ConnTCP, err *os.Error) {
func DialTCP(net, laddr, raddr string) (c *ConnTCP, err *os.Error) {
if raddr == "" {
return nil, MissingAddress
}
......@@ -393,7 +393,7 @@ export func DialTCP(net, laddr, raddr string) (c *ConnTCP, err *os.Error) {
// TODO(rsc): UDP headers mode
export type ConnUDP struct {
type ConnUDP struct {
_ConnBase
}
......@@ -404,7 +404,7 @@ func _NewConnUDP(fd *FD, raddr string) *ConnUDP {
return c
}
export func DialUDP(net, laddr, raddr string) (c *ConnUDP, err *os.Error) {
func DialUDP(net, laddr, raddr string) (c *ConnUDP, err *os.Error) {
if raddr == "" {
return nil, MissingAddress
}
......@@ -422,7 +422,7 @@ export func DialUDP(net, laddr, raddr string) (c *ConnUDP, err *os.Error) {
// TODO: raw ethernet connections
export type Conn interface {
type Conn interface {
Read(b []byte) (n int, err *os.Error);
Write(b []byte) (n int, err *os.Error);
ReadFrom(b []byte) (n int, addr string, err *os.Error);
......@@ -450,7 +450,7 @@ export type Conn interface {
// Eventually, we plan to allow names in addition to IP addresses,
// but that requires writing a DNS library.
export func Dial(net, laddr, raddr string) (c Conn, err *os.Error) {
func Dial(net, laddr, raddr string) (c Conn, err *os.Error) {
switch net {
case "tcp", "tcp4", "tcp6":
c, err := DialTCP(net, laddr, raddr);
......@@ -477,17 +477,17 @@ export func Dial(net, laddr, raddr string) (c Conn, err *os.Error) {
}
export type Listener interface {
type Listener interface {
Accept() (c Conn, raddr string, err *os.Error);
Close() *os.Error;
}
export type ListenerTCP struct {
type ListenerTCP struct {
fd *FD;
laddr string
}
export func ListenTCP(net, laddr string) (l *ListenerTCP, err *os.Error) {
func ListenTCP(net, laddr string) (l *ListenerTCP, err *os.Error) {
fd, e := _InternetSocket(net, laddr, "", syscall.SOCK_STREAM, "listen");
if e != nil {
return nil, e
......@@ -534,7 +534,7 @@ func (l *ListenerTCP) Close() *os.Error {
return l.fd.Close()
}
export func Listen(net, laddr string) (l Listener, err *os.Error) {
func Listen(net, laddr string) (l Listener, err *os.Error) {
switch net {
case "tcp", "tcp4", "tcp6":
l, err := ListenTCP(net, laddr);
......
......@@ -11,7 +11,7 @@ import (
"unsafe";
)
export func IPv4ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
func IPv4ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
p = ToIPv4(p);
if p == nil || port < 0 || port > 0xFFFF {
return nil, os.EINVAL
......@@ -24,10 +24,10 @@ export func IPv4ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.E
for i := 0; i < IPv4len; i++ {
sa.Addr[i] = p[i]
}
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
return unsafe.Pointer(sa).(*syscall.Sockaddr), nil
}
export func IPv6ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
func IPv6ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
p = ToIPv6(p);
if p == nil || port < 0 || port > 0xFFFF {
return nil, os.EINVAL
......@@ -40,21 +40,21 @@ export func IPv6ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.E
for i := 0; i < IPv6len; i++ {
sa.Addr[i] = p[i]
}
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
return unsafe.Pointer(sa).(*syscall.Sockaddr), nil
}
export func SockaddrToIP(sa1 *syscall.Sockaddr) (p []byte, port int, err *os.Error) {
func SockaddrToIP(sa1 *syscall.Sockaddr) (p []byte, port int, err *os.Error) {
switch sa1.Family {
case syscall.AF_INET:
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet4);
sa := unsafe.Pointer(sa1).(*syscall.SockaddrInet4);
a := ToIPv6(sa.Addr);
if a == nil {
return nil, 0, os.EINVAL
}
return a, int(sa.Port[0])<<8 + int(sa.Port[1]), nil;
case syscall.AF_INET6:
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet6);
sa := unsafe.Pointer(sa1).(*syscall.SockaddrInet6);
a := ToIPv6(sa.Addr);
if a == nil {
return nil, 0, os.EINVAL
......@@ -66,7 +66,7 @@ export func SockaddrToIP(sa1 *syscall.Sockaddr) (p []byte, port int, err *os.Err
return nil, 0, nil // not reached
}
export func ListenBacklog() int64 {
func ListenBacklog() int64 {
return syscall.SOMAXCONN
}
......@@ -11,7 +11,7 @@ import (
"unsafe";
)
export func IPv4ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
func IPv4ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
p = ToIPv4(p);
if p == nil || port < 0 || port > 0xFFFF {
return nil, os.EINVAL
......@@ -23,12 +23,12 @@ export func IPv4ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.E
for i := 0; i < IPv4len; i++ {
sa.Addr[i] = p[i]
}
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
return unsafe.Pointer(sa).(*syscall.Sockaddr), nil
}
var _IPv6zero [16]byte;
export func IPv6ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
func IPv6ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.Error) {
p = ToIPv6(p);
if p == nil || port < 0 || port > 0xFFFF {
return nil, os.EINVAL
......@@ -48,20 +48,20 @@ export func IPv6ToSockaddr(p []byte, port int) (sa1 *syscall.Sockaddr, err *os.E
for i := 0; i < IPv6len; i++ {
sa.Addr[i] = p[i]
}
return unsafe.pointer(sa).(*syscall.Sockaddr), nil
return unsafe.Pointer(sa).(*syscall.Sockaddr), nil
}
export func SockaddrToIP(sa1 *syscall.Sockaddr) (p []byte, port int, err *os.Error) {
func SockaddrToIP(sa1 *syscall.Sockaddr) (p []byte, port int, err *os.Error) {
switch sa1.Family {
case syscall.AF_INET:
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet4);
sa := unsafe.Pointer(sa1).(*syscall.SockaddrInet4);
a := ToIPv6(sa.Addr);
if a == nil {
return nil, 0, os.EINVAL
}
return a, int(sa.Port[0])<<8 + int(sa.Port[1]), nil;
case syscall.AF_INET6:
sa := unsafe.pointer(sa1).(*syscall.SockaddrInet6);
sa := unsafe.Pointer(sa1).(*syscall.SockaddrInet6);
a := ToIPv6(sa.Addr);
if a == nil {
return nil, 0, os.EINVAL
......@@ -73,7 +73,7 @@ export func SockaddrToIP(sa1 *syscall.Sockaddr) (p []byte, port int, err *os.Err
return nil, 0, nil // not reached
}
export func ListenBacklog() int64 {
func ListenBacklog() int64 {
// TODO: Read the limit from /proc/sys/net/core/somaxconn,
// to take advantage of kernels that have raised the limit.
return syscall.SOMAXCONN
......
......@@ -11,7 +11,7 @@ import (
"testing";
)
export func TestReadLine(t *testing.T) {
func TestReadLine(t *testing.T) {
filename := "/etc/services"; // a nice big file
fd, err := os.Open(filename, os.O_RDONLY, 0);
......
......@@ -48,7 +48,7 @@ func _ReadServices() {
file.Close();
}
export func LookupPort(netw, name string) (port int, ok bool) {
func LookupPort(netw, name string) (port int, ok bool) {
once.Do(&_ReadServices);
switch netw {
......
......@@ -48,7 +48,7 @@ var porttests = []portTest {
portTest{ "tcp", "--badport--", 0, false },
}
export func TestLookupPort(t *testing.T) {
func TestLookupPort(t *testing.T) {
for i := 0; i < len(porttests); i++ {
tt := porttests[i];
if port, ok := LookupPort(tt.netw, tt.name); port != tt.port || ok != tt.ok {
......
......@@ -75,7 +75,7 @@ func doTest(t *testing.T, network, listenaddr, dialaddr string) {
<-done; // make sure server stopped
}
export func TestTcpServer(t *testing.T) {
func TestTcpServer(t *testing.T) {
doTest(t, "tcp", "0.0.0.0:9997", "127.0.0.1:9997");
doTest(t, "tcp", "[::]:9997", "[::ffff:127.0.0.1]:9997");
doTest(t, "tcp", "[::]:9997", "127.0.0.1:9997");
......
......@@ -42,7 +42,7 @@ func server() {
}
}
export func Do(f *()) {
func Do(f *()) {
// Look for job in map (avoids channel communication).
// If not there, ask map server to make one.
// TODO: Uncomment use of jobmap[f] once
......
......@@ -14,7 +14,7 @@ func call() {
ncall++
}
export func TestOnce(t *testing.T) {
func TestOnce(t *testing.T) {
ncall = 0;
once.Do(&call);
if ncall != 1 {
......
......@@ -9,11 +9,11 @@ package os
import os "os"
export var (
var (
ENOENV = NewError("no such environment variable");
)
export func Getenv(s string) (v string, err *Error) {
func Getenv(s string) (v string, err *Error) {
n := len(s);
if n == 0 {
return "", EINVAL
......
......@@ -8,7 +8,7 @@ import syscall "syscall"
// Errors are singleton structures. Use the String() method to get their contents --
// it handles the nil (no error) case.
export type Error struct {
type Error struct {
s string
}
......@@ -25,7 +25,7 @@ var errorStringTab = make(map[string] *Error);
// errors simultaneously but the consequences are unimportant.
// Allocate an Error object, but if it's been seen before, share that one.
export func NewError(s string) *Error {
func NewError(s string) *Error {
if s == "" {
return nil
}
......@@ -39,7 +39,7 @@ export func NewError(s string) *Error {
}
// Allocate an Error objecct, but if it's been seen before, share that one.
export func ErrnoToError(errno int64) *Error {
func ErrnoToError(errno int64) *Error {
if errno == 0 {
return nil
}
......@@ -53,7 +53,7 @@ export func ErrnoToError(errno int64) *Error {
return err;
}
export var (
var (
ENONE = ErrnoToError(syscall.ENONE);
EPERM = ErrnoToError(syscall.EPERM);
ENOENT = ErrnoToError(syscall.ENOENT);
......
......@@ -8,24 +8,24 @@ import syscall "syscall"
import os "os"
// FDs are wrappers for file descriptors
export type FD struct {
type FD struct {
fd int64
}
export func NewFD(fd int64) *FD {
func NewFD(fd int64) *FD {
if fd < 0 {
return nil
}
return &FD{fd}
}
export var (
var (
Stdin = NewFD(0);
Stdout = NewFD(1);
Stderr = NewFD(2);
)
export const (
const (
O_RDONLY = syscall.O_RDONLY;
O_WRONLY = syscall.O_WRONLY;
O_RDWR = syscall.O_RDWR;
......@@ -39,7 +39,7 @@ export const (
O_TRUNC = syscall.O_TRUNC;
)
export func Open(name string, mode int, flags int) (fd *FD, err *Error) {
func Open(name string, mode int, flags int) (fd *FD, err *Error) {
r, e := syscall.Open(name, int64(mode), int64(flags));
return NewFD(r), ErrnoToError(e)
}
......@@ -96,7 +96,7 @@ func (fd *FD) WriteString(s string) (ret int, err *Error) {
return int(r), ErrnoToError(e)
}
export func Pipe() (fd1 *FD, fd2 *FD, err *Error) {
func Pipe() (fd1 *FD, fd2 *FD, err *Error) {
var p [2]int64;
r, e := syscall.Pipe(&p);
if e != 0 {
......@@ -105,7 +105,7 @@ export func Pipe() (fd1 *FD, fd2 *FD, err *Error) {
return NewFD(p[0]), NewFD(p[1]), nil
}
export func Mkdir(name string, perm int) *Error {
func Mkdir(name string, perm int) *Error {
r, e := syscall.Mkdir(name, int64(perm));
return ErrnoToError(e)
}
......@@ -9,7 +9,7 @@ import (
"syscall"
)
export func Time() (sec int64, nsec int64, err *Error) {
func Time() (sec int64, nsec int64, err *Error) {
var errno int64;
sec, nsec, errno = syscall.Gettimeofday();
if errno != 0 {
......
......@@ -44,7 +44,7 @@ func seedrand(x int32) int32 {
return x;
}
export func Seed(seed int32) {
func Seed(seed int32) {
rng_tap = 0;
rng_feed = _LEN-_TAP;
......@@ -72,7 +72,7 @@ export func Seed(seed int32) {
}
}
export func Int63() int64 {
func Int63() int64 {
rng_tap--;
if rng_tap < 0 {
rng_tap += _LEN;
......@@ -88,20 +88,20 @@ export func Int63() int64 {
return x;
}
export func Uint32() uint32 {
func Uint32() uint32 {
return uint32(Int63() >> 31);
}
export func Int31() int32 {
func Int31() int32 {
return int32(Int63() >> 32);
}
export func Int() int {
func Int() int {
u := uint(Int63());
return int(u << 1 >> 1); // clear sign bit if int == int32
}
export func Int63n(n int64) int64 {
func Int63n(n int64) int64 {
if n <= 0 {
return 0
}
......@@ -113,15 +113,15 @@ export func Int63n(n int64) int64 {
return v % n
}
export func Int31n(n int32) int32 {
func Int31n(n int32) int32 {
return int32(Int63n(int64(n)))
}
export func Intn(n int) int {
func Intn(n int) int {
return int(Int63n(int64(n)))
}
export func Float64() float64 {
func Float64() float64 {
x := float64(Int63()) / float64(_MASK);
for x >= 1 {
x = float64(Int63()) / float64(_MASK);
......@@ -129,16 +129,16 @@ export func Float64() float64 {
return x;
}
export func Float32() float32 {
func Float32() float32 {
return float32(Float64())
}
export func Float() float
func Float() float
{
return float(Float64())
}
export func Perm(n int) []int {
func Perm(n int) []int {
m := make([]int, n);
for i:=0; i<n; i++ {
m[i] = i;
......
......@@ -87,9 +87,9 @@ func valuedump(s, t string) {
assert(reflect.ValueToString(v), t);
}
export type T struct { a int; b float64; c string; d *int }
type T struct { a int; b float64; c string; d *int }
export func TestAll(tt *testing.T) { // TODO(r): wrap up better
func TestAll(tt *testing.T) { // TODO(r): wrap up better
var s string;
var t reflect.Type;
......@@ -285,7 +285,7 @@ export func TestAll(tt *testing.T) { // TODO(r): wrap up better
}
}
export func TestInterfaceGet(t *testing.T) {
func TestInterfaceGet(t *testing.T) {
var inter struct { e interface{ } };
inter.e = 123.456;
v1 := reflect.NewValue(&inter);
......@@ -296,7 +296,7 @@ export func TestInterfaceGet(t *testing.T) {
assert(v3.Type().String(), "float");
}
export func TestCopyArray(t *testing.T) {
func TestCopyArray(t *testing.T) {
a := []int{ 1, 2, 3, 4, 10, 9, 8, 7 };
b := []int{ 11, 22, 33, 44, 1010, 99, 88, 77, 66, 55, 44 };
c := []int{ 11, 22, 33, 44, 1010, 99, 88, 77, 66, 55, 44 };
......@@ -331,7 +331,7 @@ export func TestCopyArray(t *testing.T) {
}
}
export func TestBigUnnamedStruct(t *testing.T) {
func TestBigUnnamedStruct(t *testing.T) {
b := struct{a,b,c,d int64}{1, 2, 3, 4};
v := NewValue(b);
b1 := v.Interface().(struct{a,b,c,d int64});
......@@ -343,7 +343,7 @@ export func TestBigUnnamedStruct(t *testing.T) {
type big struct {
a, b, c, d, e int64
}
export func TestBigStruct(t *testing.T) {
func TestBigStruct(t *testing.T) {
b := big{1, 2, 3, 4, 5};
v := NewValue(b);
b1 := v.Interface().(big);
......
......@@ -12,8 +12,8 @@ import (
"strconv";
)
export func TypeToString(typ Type, expand bool) string
export func ValueToString(val Value) string
func TypeToString(typ Type, expand bool) string
func ValueToString(val Value) string
func doubleQuote(s string) string {
out := "\"";
......@@ -62,7 +62,7 @@ func typeFieldsToString(t hasFields, sep string) string {
return str;
}
export func TypeToString(typ Type, expand bool) string {
func TypeToString(typ Type, expand bool) string {
var str string;
if name := typ.Name(); !expand && name != "" {
return name
......@@ -126,7 +126,7 @@ func integer(v int64) string {
return strconv.Itoa64(v);
}
export func ValueToString(val Value) string {
func ValueToString(val Value) string {
var str string;
typ := val.Type();
switch(val.Kind()) {
......
......@@ -12,13 +12,13 @@ import (
"sync";
)
export type Type interface
type Type interface
export func ExpandType(name string) Type
func ExpandType(name string) Type
func typestrings() string // implemented in C; declared here
export const (
const (
MissingKind = iota;
ArrayKind;
BoolKind;
......@@ -54,7 +54,7 @@ var interfacesize int
var missingString = "$missing$" // syntactic name for undefined type names
var dotDotDotString = "..."
export type Type interface {
type Type interface {
Kind() int;
Name() string;
String() string;
......@@ -102,7 +102,7 @@ func newBasicType(name string, kind int, size int) Type {
}
// Prebuilt basic types
export var (
var (
Missing = newBasicType(missingString, MissingKind, 1);
DotDotDot = newBasicType(dotDotDotString, DotDotDotKind, 16); // TODO(r): size of interface?
Bool = newBasicType("bool", BoolKind, 1); // TODO: need to know how big a bool is
......@@ -145,7 +145,7 @@ func (t *stubType) Get() Type {
// -- Pointer
export type PtrType interface {
type PtrType interface {
Sub() Type
}
......@@ -164,7 +164,7 @@ func (t *ptrTypeStruct) Sub() Type {
// -- Array
export type ArrayType interface {
type ArrayType interface {
Open() bool;
Len() int;
Elem() Type;
......@@ -203,7 +203,7 @@ func (t *arrayTypeStruct) Elem() Type {
// -- Map
export type MapType interface {
type MapType interface {
Key() Type;
Elem() Type;
}
......@@ -228,12 +228,12 @@ func (t *mapTypeStruct) Elem() Type {
// -- Chan
export type ChanType interface {
type ChanType interface {
Dir() int;
Elem() Type;
}
export const ( // channel direction
const ( // channel direction
SendDir = 1 << iota;
RecvDir;
BothDir = SendDir | RecvDir;
......@@ -259,7 +259,7 @@ func (t *chanTypeStruct) Elem() Type {
// -- Struct
export type StructType interface {
type StructType interface {
Field(int) (name string, typ Type, tag string, offset int);
Len() int;
}
......@@ -319,7 +319,7 @@ func (t *structTypeStruct) Len() int {
// -- Interface
export type InterfaceType interface {
type InterfaceType interface {
Field(int) (name string, typ Type, tag string, offset int);
Len() int;
}
......@@ -345,7 +345,7 @@ var nilInterface = newInterfaceTypeStruct("nil", "", make([]structField, 0));
// -- Func
export type FuncType interface {
type FuncType interface {
In() StructType;
Out() StructType;
}
......@@ -842,7 +842,7 @@ func (p *typeParser) Type(name string) *stubType {
return s;
}
export func ParseTypeString(name, typestring string) Type {
func ParseTypeString(name, typestring string) Type {
if typestring == "" {
// If the typestring is empty, it represents (the type of) a nil interface value
return nilInterface
......@@ -902,7 +902,7 @@ func typeNameToTypeString(name string) string {
}
// Type is known by name. Find (and create if necessary) its real type.
export func ExpandType(name string) Type {
func ExpandType(name string) Type {
lock();
t, ok := types[name];
if ok {
......
......@@ -12,13 +12,13 @@ import (
"unsafe";
)
export type Addr unsafe.pointer
type Addr unsafe.Pointer
func equalType(a, b Type) bool {
return a.String() == b.String()
}
export type Value interface {
type Value interface {
Kind() int;
Type() Type;
Addr() Addr;
......@@ -65,7 +65,7 @@ type creatorFn *(typ Type, addr Addr) Value
// -- Missing
export type MissingValue interface {
type MissingValue interface {
Kind() int;
Type() Type;
Addr() Addr;
......@@ -81,7 +81,7 @@ func missingCreator(typ Type, addr Addr) Value {
// -- Int
export type IntValue interface {
type IntValue interface {
Kind() int;
Get() int;
Set(int);
......@@ -106,7 +106,7 @@ func (v *intValueStruct) Set(i int) {
// -- Int8
export type Int8Value interface {
type Int8Value interface {
Kind() int;
Get() int8;
Set(int8);
......@@ -131,7 +131,7 @@ func (v *int8ValueStruct) Set(i int8) {
// -- Int16
export type Int16Value interface {
type Int16Value interface {
Kind() int;
Get() int16;
Set(int16);
......@@ -156,7 +156,7 @@ func (v *int16ValueStruct) Set(i int16) {
// -- Int32
export type Int32Value interface {
type Int32Value interface {
Kind() int;
Get() int32;
Set(int32);
......@@ -181,7 +181,7 @@ func (v *int32ValueStruct) Set(i int32) {
// -- Int64
export type Int64Value interface {
type Int64Value interface {
Kind() int;
Get() int64;
Set(int64);
......@@ -206,7 +206,7 @@ func (v *int64ValueStruct) Set(i int64) {
// -- Uint
export type UintValue interface {
type UintValue interface {
Kind() int;
Get() uint;
Set(uint);
......@@ -231,7 +231,7 @@ func (v *uintValueStruct) Set(i uint) {
// -- Uint8
export type Uint8Value interface {
type Uint8Value interface {
Kind() int;
Get() uint8;
Set(uint8);
......@@ -256,7 +256,7 @@ func (v *uint8ValueStruct) Set(i uint8) {
// -- Uint16
export type Uint16Value interface {
type Uint16Value interface {
Kind() int;
Get() uint16;
Set(uint16);
......@@ -281,7 +281,7 @@ func (v *uint16ValueStruct) Set(i uint16) {
// -- Uint32
export type Uint32Value interface {
type Uint32Value interface {
Kind() int;
Get() uint32;
Set(uint32);
......@@ -306,7 +306,7 @@ func (v *uint32ValueStruct) Set(i uint32) {
// -- Uint64
export type Uint64Value interface {
type Uint64Value interface {
Kind() int;
Get() uint64;
Set(uint64);
......@@ -331,7 +331,7 @@ func (v *uint64ValueStruct) Set(i uint64) {
// -- Uintptr
export type UintptrValue interface {
type UintptrValue interface {
Kind() int;
Get() uintptr;
Set(uintptr);
......@@ -356,7 +356,7 @@ func (v *uintptrValueStruct) Set(i uintptr) {
// -- Float
export type FloatValue interface {
type FloatValue interface {
Kind() int;
Get() float;
Set(float);
......@@ -381,7 +381,7 @@ func (v *floatValueStruct) Set(f float) {
// -- Float32
export type Float32Value interface {
type Float32Value interface {
Kind() int;
Get() float32;
Set(float32);
......@@ -406,7 +406,7 @@ func (v *float32ValueStruct) Set(f float32) {
// -- Float64
export type Float64Value interface {
type Float64Value interface {
Kind() int;
Get() float64;
Set(float64);
......@@ -431,7 +431,7 @@ func (v *float64ValueStruct) Set(f float64) {
// -- Float80
export type Float80Value interface {
type Float80Value interface {
Kind() int;
Get() float80;
Set(float80);
......@@ -459,7 +459,7 @@ func (v *Float80ValueStruct) Set(f float80) {
// -- String
export type StringValue interface {
type StringValue interface {
Kind() int;
Get() string;
Set(string);
......@@ -484,7 +484,7 @@ func (v *stringValueStruct) Set(s string) {
// -- Bool
export type BoolValue interface {
type BoolValue interface {
Kind() int;
Get() bool;
Set(bool);
......@@ -509,7 +509,7 @@ func (v *boolValueStruct) Set(b bool) {
// -- Pointer
export type PtrValue interface {
type PtrValue interface {
Kind() int;
Type() Type;
Sub() Value;
......@@ -545,7 +545,7 @@ func ptrCreator(typ Type, addr Addr) Value {
// -- Array
export type ArrayValue interface {
type ArrayValue interface {
Kind() int;
Type() Type;
Open() bool;
......@@ -652,7 +652,7 @@ func arrayCreator(typ Type, addr Addr) Value {
// -- Map TODO: finish and test
export type MapValue interface {
type MapValue interface {
Kind() int;
Type() Type;
Len() int;
......@@ -678,7 +678,7 @@ func (v *mapValueStruct) Elem(key Value) Value {
// -- Chan
export type ChanValue interface {
type ChanValue interface {
Kind() int;
Type() Type;
}
......@@ -693,7 +693,7 @@ func chanCreator(typ Type, addr Addr) Value {
// -- Struct
export type StructValue interface {
type StructValue interface {
Kind() int;
Type() Type;
Len() int;
......@@ -728,7 +728,7 @@ func structCreator(typ Type, addr Addr) Value {
// -- Interface
export type InterfaceValue interface {
type InterfaceValue interface {
Kind() int;
Type() Type;
Get() interface {};
......@@ -748,7 +748,7 @@ func interfaceCreator(typ Type, addr Addr) Value {
// -- Func
export type FuncValue interface {
type FuncValue interface {
Kind() int;
Type() Type;
}
......@@ -799,7 +799,7 @@ func newValueAddr(typ Type, addr Addr) Value {
return c(typ, addr);
}
export func NewInitValue(typ Type) Value {
func NewInitValue(typ Type) Value {
// Some values cannot be made this way.
switch typ.Kind() {
case FuncKind: // must be pointers, at least for now (TODO?)
......@@ -825,7 +825,7 @@ export func NewInitValue(typ Type) Value {
uint32 cap; // allocated number of elements
};
*/
export func NewOpenArrayValue(typ ArrayType, len, cap int) ArrayValue {
func NewOpenArrayValue(typ ArrayType, len, cap int) ArrayValue {
if !typ.Open() {
return nil
}
......@@ -843,7 +843,7 @@ export func NewOpenArrayValue(typ ArrayType, len, cap int) ArrayValue {
return newValueAddr(typ, Addr(array));
}
export func CopyArray(dst ArrayValue, src ArrayValue, n int) {
func CopyArray(dst ArrayValue, src ArrayValue, n int) {
if n == 0 {
return
}
......@@ -875,7 +875,7 @@ export func CopyArray(dst ArrayValue, src ArrayValue, n int) {
}
export func NewValue(e interface {}) Value {
func NewValue(e interface {}) Value {
value, typestring, indir := sys.Reflect(e);
typ, ok := typecache[typestring];
if !ok {
......
......@@ -36,16 +36,16 @@ type stringError struct {
}
var bad_re = []stringError{
stringError{ `*`, regexp.ErrBareClosure },
stringError{ `(abc`, regexp.ErrUnmatchedLpar },
stringError{ `abc)`, regexp.ErrUnmatchedRpar },
stringError{ `x[a-z`, regexp.ErrUnmatchedLbkt },
stringError{ `abc]`, regexp.ErrUnmatchedRbkt },
stringError{ `[z-a]`, regexp.ErrBadRange },
stringError{ `abc\`, regexp.ErrExtraneousBackslash },
stringError{ `a**`, regexp.ErrBadClosure },
stringError{ `a*+`, regexp.ErrBadClosure },
stringError{ `a??`, regexp.ErrBadClosure },
stringError{ `*`, regexp.ErrBareClosure },
stringError{ `(abc`, regexp.ErrUnmatchedLpar },
stringError{ `abc)`, regexp.ErrUnmatchedRpar },
stringError{ `x[a-z`, regexp.ErrUnmatchedLbkt },
stringError{ `abc]`, regexp.ErrUnmatchedRbkt },
stringError{ `[z-a]`, regexp.ErrBadRange },
stringError{ `abc\`, regexp.ErrExtraneousBackslash },
stringError{ `a**`, regexp.ErrBadClosure },
stringError{ `a*+`, regexp.ErrBadClosure },
stringError{ `a??`, regexp.ErrBadClosure },
stringError{ `*`, regexp.ErrBareClosure },
stringError{ `\x`, regexp.ErrBadBackslash },
}
......@@ -155,19 +155,19 @@ func executeTest(t *testing.T, expr string, str string, match []int) {
}
}
export func TestGoodCompile(t *testing.T) {
func TestGoodCompile(t *testing.T) {
for i := 0; i < len(good_re); i++ {
compileTest(t, good_re[i], nil);
}
}
export func TestBadCompile(t *testing.T) {
func TestBadCompile(t *testing.T) {
for i := 0; i < len(bad_re); i++ {
compileTest(t, bad_re[i].re, bad_re[i].err)
}
}
export func TestExecute(t *testing.T) {
func TestExecute(t *testing.T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
executeTest(t, test.re, test.text, test.match)
......@@ -185,7 +185,7 @@ func matchTest(t *testing.T, expr string, str string, match []int) {
}
}
export func TestMatch(t *testing.T) {
func TestMatch(t *testing.T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
matchTest(t, test.re, test.text, test.match)
......@@ -210,7 +210,7 @@ func matchStringsTest(t *testing.T, expr string, str string, match []int) {
}
}
export func TestMatchStrings(t *testing.T) {
func TestMatchStrings(t *testing.T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
matchTest(t, test.re, test.text, test.match)
......@@ -227,7 +227,7 @@ func matchFunctionTest(t *testing.T, expr string, str string, match []int) {
}
}
export func TestMatchFunction(t *testing.T) {
func TestMatchFunction(t *testing.T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
matchFunctionTest(t, test.re, test.text, test.match)
......
......@@ -15,16 +15,16 @@ import (
var debug = false;
export var ErrInternal = os.NewError("internal error");
export var ErrUnmatchedLpar = os.NewError("unmatched '('");
export var ErrUnmatchedRpar = os.NewError("unmatched ')'");
export var ErrUnmatchedLbkt = os.NewError("unmatched '['");
export var ErrUnmatchedRbkt = os.NewError("unmatched ']'");
export var ErrBadRange = os.NewError("bad range in character class");
export var ErrExtraneousBackslash = os.NewError("extraneous backslash");
export var ErrBadClosure = os.NewError("repeated closure (**, ++, etc.)");
export var ErrBareClosure = os.NewError("closure applies to nothing");
export var ErrBadBackslash = os.NewError("illegal backslash escape");
var ErrInternal = os.NewError("internal error");
var ErrUnmatchedLpar = os.NewError("unmatched '('");
var ErrUnmatchedRpar = os.NewError("unmatched ')'");
var ErrUnmatchedLbkt = os.NewError("unmatched '['");
var ErrUnmatchedRbkt = os.NewError("unmatched ']'");
var ErrBadRange = os.NewError("bad range in character class");
var ErrExtraneousBackslash = os.NewError("extraneous backslash");
var ErrBadClosure = os.NewError("repeated closure (**, ++, etc.)");
var ErrBareClosure = os.NewError("closure applies to nothing");
var ErrBadBackslash = os.NewError("illegal backslash escape");
// An instruction executed by the NFA
type instr interface {
......@@ -582,14 +582,14 @@ func compiler(str string, ch chan *_RE) {
}
// Public interface has only execute functionality
export type Regexp interface {
type Regexp interface {
Execute(s string) []int;
Match(s string) bool;
MatchStrings(s string) []string;
}
// Compile in separate goroutine; wait for result
export func Compile(str string) (regexp Regexp, error *os.Error) {
func Compile(str string) (regexp Regexp, error *os.Error) {
ch := make(chan *_RE);
go compiler(str, ch);
re := <-ch;
......@@ -739,7 +739,7 @@ func (re *_RE) MatchStrings(s string) []string {
// Exported function for simple boolean check. Anything more fancy
// needs a call to Compile.
export func Match(pattern string, s string) (matched bool, error *os.Error) {
func Match(pattern string, s string) (matched bool, error *os.Error) {
re, err := Compile(pattern);
if err != nil {
return false, err
......
......@@ -4,7 +4,7 @@
package sort
export type SortInterface interface {
type SortInterface interface {
Len() int;
Less(i, j int) bool;
Swap(i, j int);
......@@ -116,12 +116,12 @@ func quickSort(data SortInterface, a, b int) {
}
}
export func Sort(data SortInterface) {
func Sort(data SortInterface) {
quickSort(data, 0, data.Len());
}
export func IsSorted(data SortInterface) bool {
func IsSorted(data SortInterface) bool {
n := data.Len();
for i := n - 1; i > 0; i-- {
if data.Less(i, i - 1) {
......@@ -134,21 +134,21 @@ export func IsSorted(data SortInterface) bool {
// Convenience types for common cases
export type IntArray []int
type IntArray []int
func (p IntArray) Len() int { return len(p); }
func (p IntArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p IntArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
export type FloatArray []float
type FloatArray []float
func (p FloatArray) Len() int { return len(p); }
func (p FloatArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p FloatArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
export type StringArray []string
type StringArray []string
func (p StringArray) Len() int { return len(p); }
func (p StringArray) Less(i, j int) bool { return p[i] < p[j]; }
......@@ -157,11 +157,11 @@ func (p StringArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
// Convenience wrappers for common cases
export func SortInts(a []int) { Sort(IntArray(a)); }
export func SortFloats(a []float) { Sort(FloatArray(a)); }
export func SortStrings(a []string) { Sort(StringArray(a)); }
func SortInts(a []int) { Sort(IntArray(a)); }
func SortFloats(a []float) { Sort(FloatArray(a)); }
func SortStrings(a []string) { Sort(StringArray(a)); }
export func IntsAreSorted(a []int) bool { return IsSorted(IntArray(a)); }
export func FloatsAreSorted(a []float) bool { return IsSorted(FloatArray(a)); }
export func StringsAreSorted(a []string) bool { return IsSorted(StringArray(a)); }
func IntsAreSorted(a []int) bool { return IsSorted(IntArray(a)); }
func FloatsAreSorted(a []float) bool { return IsSorted(FloatArray(a)); }
func StringsAreSorted(a []string) bool { return IsSorted(StringArray(a)); }
......@@ -16,7 +16,7 @@ var ints = [...]int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984,
var floats = [...]float{74.3, 59.0, 238.2, -784.0, 2.3, 9845.768, -959.7485, 905, 7.8, 7.8}
var strings = [...]string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "***"}
export func TestSortIntArray(t *testing.T) {
func TestSortIntArray(t *testing.T) {
data := ints;
a := IntArray(data);
sort.Sort(a);
......@@ -26,7 +26,7 @@ export func TestSortIntArray(t *testing.T) {
}
}
export func TestSortFloatArray(t *testing.T) {
func TestSortFloatArray(t *testing.T) {
data := floats;
a := FloatArray(data);
sort.Sort(a);
......@@ -36,7 +36,7 @@ export func TestSortFloatArray(t *testing.T) {
}
}
export func TestSortStringArray(t *testing.T) {
func TestSortStringArray(t *testing.T) {
data := strings;
a := StringArray(data);
sort.Sort(a);
......@@ -46,7 +46,7 @@ export func TestSortStringArray(t *testing.T) {
}
}
export func TestSortInts(t *testing.T) {
func TestSortInts(t *testing.T) {
data := ints;
sort.SortInts(data);
if !sort.IntsAreSorted(data) {
......@@ -55,7 +55,7 @@ export func TestSortInts(t *testing.T) {
}
}
export func TestSortFloats(t *testing.T) {
func TestSortFloats(t *testing.T) {
data := floats;
sort.SortFloats(data);
if !sort.FloatsAreSorted(data) {
......@@ -64,7 +64,7 @@ export func TestSortFloats(t *testing.T) {
}
}
export func TestSortStrings(t *testing.T) {
func TestSortStrings(t *testing.T) {
data := strings;
sort.SortStrings(data);
if !sort.StringsAreSorted(data) {
......@@ -73,7 +73,7 @@ export func TestSortStrings(t *testing.T) {
}
}
export func TestSortLarge_Random(t *testing.T) {
func TestSortLarge_Random(t *testing.T) {
data := make([]int, 1000000);
for i := 0; i < len(data); i++ {
data[i] = rand.Intn(100);
......@@ -133,7 +133,7 @@ func lg(n int) int {
return i;
}
export func TestBentleyMcIlroy(t *testing.T) {
func TestBentleyMcIlroy(t *testing.T) {
sizes := []int{100, 1023, 1024, 1025};
dists := []string{"sawtooth", "rand", "stagger", "plateau", "shuffle"};
modes := []string{"copy", "reverse", "reverse1", "reverse2", "sort", "dither"};
......
......@@ -318,7 +318,7 @@ func decimalAtof32(neg bool, d *decimal, trunc bool) (f float32, ok bool) {
// If s is syntactically well-formed but is more than 1/2 ULP
// away from the largest floating point number of the given size,
// returns f = ±Inf, err = os.ERANGE.
export func Atof64(s string) (f float64, err *os.Error) {
func Atof64(s string) (f float64, err *os.Error) {
neg, d, trunc, ok := stringToDecimal(s);
if !ok {
return 0, os.EINVAL;
......@@ -336,7 +336,7 @@ export func Atof64(s string) (f float64, err *os.Error) {
return f, err
}
export func Atof32(s string) (f float32, err *os.Error) {
func Atof32(s string) (f float32, err *os.Error) {
neg, d, trunc, ok := stringToDecimal(s);
if !ok {
return 0, os.EINVAL;
......@@ -354,7 +354,7 @@ export func Atof32(s string) (f float32, err *os.Error) {
return f, err
}
export func Atof(s string) (f float, err *os.Error) {
func Atof(s string) (f float, err *os.Error) {
if FloatSize == 32 {
f1, err1 := Atof32(s);
return float(f1), err1;
......
......@@ -124,10 +124,10 @@ func testAtof(t *testing.T, opt bool) {
strconv.optimize = oldopt;
}
export func TestAtof(t *testing.T) {
func TestAtof(t *testing.T) {
testAtof(t, true);
}
export func TestAtofSlow(t *testing.T) {
func TestAtofSlow(t *testing.T) {
testAtof(t, false);
}
......@@ -15,7 +15,7 @@ func computeIntsize() uint {
var intsize = computeIntsize();
// Convert decimal string to unsigned integer.
export func Atoui64(s string) (i uint64, err *os.Error) {
func Atoui64(s string) (i uint64, err *os.Error) {
// empty string bad
if len(s) == 0 {
return 0, os.EINVAL
......@@ -52,7 +52,7 @@ export func Atoui64(s string) (i uint64, err *os.Error) {
}
// Convert decimal string to integer.
export func Atoi64(s string) (i int64, err *os.Error) {
func Atoi64(s string) (i int64, err *os.Error) {
// empty string bad
if len(s) == 0 {
return 0, os.EINVAL
......@@ -85,7 +85,7 @@ export func Atoi64(s string) (i int64, err *os.Error) {
return n, nil
}
export func Atoui(s string) (i uint, err *os.Error) {
func Atoui(s string) (i uint, err *os.Error) {
i1, e1 := Atoui64(s);
if e1 != nil && e1 != os.ERANGE {
return 0, e1
......@@ -99,7 +99,7 @@ export func Atoui(s string) (i uint, err *os.Error) {
return i, nil
}
export func Atoi(s string) (i int, err *os.Error) {
func Atoi(s string) (i int, err *os.Error) {
i1, e1 := Atoi64(s);
if e1 != nil && e1 != os.ERANGE {
return 0, e1
......
......@@ -103,7 +103,7 @@ var atoi32tests = []atoi32Test {
atoi32Test{ "-2147483649", -1<<31, os.ERANGE },
}
export func TestAtoui64(t *testing.T) {
func TestAtoui64(t *testing.T) {
for i := 0; i < len(atoui64tests); i++ {
test := &atoui64tests[i];
out, err := strconv.Atoui64(test.in);
......@@ -114,7 +114,7 @@ export func TestAtoui64(t *testing.T) {
}
}
export func TestAtoi64(t *testing.T) {
func TestAtoi64(t *testing.T) {
for i := 0; i < len(atoi64test); i++ {
test := &atoi64test[i];
out, err := strconv.Atoi64(test.in);
......@@ -125,7 +125,7 @@ export func TestAtoi64(t *testing.T) {
}
}
export func TestAtoui(t *testing.T) {
func TestAtoui(t *testing.T) {
switch intsize {
case 32:
for i := 0; i < len(atoui32tests); i++ {
......@@ -148,7 +148,7 @@ export func TestAtoui(t *testing.T) {
}
}
export func TestAtoi(t *testing.T) {
func TestAtoi(t *testing.T) {
switch intsize {
case 32:
for i := 0; i < len(atoi32tests); i++ {
......
......@@ -29,7 +29,7 @@ var shifttests = []shiftTest {
shiftTest{ 1953125, 9, "1000000000" },
}
export func TestDecimalShift(t *testing.T) {
func TestDecimalShift(t *testing.T) {
ok := true;
for i := 0; i < len(shifttests); i++ {
test := &shifttests[i];
......@@ -66,7 +66,7 @@ var roundtests = []roundTest {
roundTest{ 12999999, 4, "12990000", "13000000", "13000000", 13000000 },
}
export func TestDecimalRound(t *testing.T) {
func TestDecimalRound(t *testing.T) {
for i := 0; i < len(roundtests); i++ {
test := &roundtests[i];
s := strconv.newDecimal(test.i).RoundDown(test.nd).String();
......@@ -106,7 +106,7 @@ var roundinttests = []roundIntTest {
roundIntTest{ 1000, 0, 1000 },
}
export func TestDecimalRoundedInteger(t *testing.T) {
func TestDecimalRoundedInteger(t *testing.T) {
for i := 0; i < len(roundinttests); i++ {
test := roundinttests[i];
// TODO: should be able to use int := here.
......
......@@ -92,7 +92,7 @@ func myatof32(s string) (f float32, ok bool) {
return f1, true;
}
export func TestFp(t *testing.T) {
func TestFp(t *testing.T) {
fd, err := os.Open("testfp.txt", os.O_RDONLY, 0);
if err != nil {
panicln("testfp: open testfp.txt:", err.String());
......
......@@ -38,17 +38,17 @@ func floatsize() int {
}
return 64;
}
export var FloatSize = floatsize()
var FloatSize = floatsize()
export func Ftoa32(f float32, fmt byte, prec int) string {
func Ftoa32(f float32, fmt byte, prec int) string {
return genericFtoa(uint64(sys.Float32bits(f)), fmt, prec, &float32info);
}
export func Ftoa64(f float64, fmt byte, prec int) string {
func Ftoa64(f float64, fmt byte, prec int) string {
return genericFtoa(sys.Float64bits(f), fmt, prec, &float64info);
}
export func Ftoa(f float, fmt byte, prec int) string {
func Ftoa(f float, fmt byte, prec int) string {
if FloatSize == 32 {
return Ftoa32(float32(f), fmt, prec);
}
......
......@@ -98,7 +98,7 @@ var ftoatests = []ftoaTest {
ftoaTest{ -1, 'b', -1, "-4503599627370496p-52" },
}
export func TestFtoa(t *testing.T) {
func TestFtoa(t *testing.T) {
if strconv.FloatSize != 32 {
panic("floatsize: ", strconv.FloatSize);
}
......
......@@ -4,7 +4,7 @@
package strconv
export func Itoa64(i int64) string {
func Itoa64(i int64) string {
if i == 0 {
return "0"
}
......@@ -31,7 +31,7 @@ export func Itoa64(i int64) string {
return string(b[bp:len(b)])
}
export func Itoa(i int) string {
func Itoa(i int) string {
return Itoa64(int64(i));
}
......@@ -40,7 +40,7 @@ var itoa64tests = []itoa64Test {
itoa64Test{ -1<<63, "-9223372036854775808" },
}
export func TestItoa(t *testing.T) {
func TestItoa(t *testing.T) {
for i := 0; i < len(itoa64tests); i++ {
test := itoa64tests[i];
s := strconv.Itoa64(test.in);
......
......@@ -10,7 +10,7 @@ import (
const lowerhex = "0123456789abcdef"
export func Quote(s string) string {
func Quote(s string) string {
t := `"`;
for i := 0; i < len(s); i++ {
switch {
......@@ -67,7 +67,7 @@ export func Quote(s string) string {
return t;
}
export func CanBackquote(s string) bool {
func CanBackquote(s string) bool {
for i := 0; i < len(s); i++ {
if s[i] < ' ' || s[i] == '`' {
return false;
......
......@@ -23,7 +23,7 @@ var quotetests = []quoteTest {
quoteTest{ "\x04", `"\x04"` },
}
export func TestQuote(t *testing.T) {
func TestQuote(t *testing.T) {
for i := 0; i < len(quotetests); i++ {
tt := quotetests[i];
if out := Quote(tt.in); out != tt.out {
......@@ -78,7 +78,7 @@ var canbackquotetests = []canBackquoteTest {
canBackquoteTest{ `☺`, true },
}
export func TestCanBackquote(t *testing.T) {
func TestCanBackquote(t *testing.T) {
for i := 0; i < len(canbackquotetests); i++ {
tt := canbackquotetests[i];
if out := CanBackquote(tt.in); out != tt.out {
......
......@@ -7,7 +7,7 @@ package strings
import "utf8"
// Split string into array of UTF-8 sequences (still strings)
export func Explode(s string) []string {
func Explode(s string) []string {
a := make([]string, utf8.RuneCountInString(s, 0, len(s)));
j := 0;
var size, rune int;
......@@ -20,7 +20,7 @@ export func Explode(s string) []string {
}
// Count non-overlapping instances of sep in s.
export func Count(s, sep string) int {
func Count(s, sep string) int {
if sep == "" {
return utf8.RuneCountInString(s, 0, len(s))+1
}
......@@ -36,7 +36,7 @@ export func Count(s, sep string) int {
}
// Return index of first instance of sep in s.
export func Index(s, sep string) int {
func Index(s, sep string) int {
if sep == "" {
return 0
}
......@@ -50,7 +50,7 @@ export func Index(s, sep string) int {
}
// Split string into list of strings at separators
export func Split(s, sep string) []string {
func Split(s, sep string) []string {
if sep == "" {
return Explode(s)
}
......@@ -72,7 +72,7 @@ export func Split(s, sep string) []string {
}
// Join list of strings with separators between them.
export func Join(a []string, sep string) string {
func Join(a []string, sep string) string {
if len(a) == 0 {
return ""
}
......
......@@ -26,7 +26,7 @@ var faces = "☺☻☹";
var commas = "1,2,3,4";
var dots = "1....2....3....4";
export type ExplodeTest struct {
type ExplodeTest struct {
s string;
a []string;
}
......@@ -34,7 +34,7 @@ var explodetests = []ExplodeTest {
ExplodeTest{ abcd, []string{"a", "b", "c", "d"} },
ExplodeTest{ faces, []string{"☺", "☻", "☹" } },
}
export func TestExplode(t *testing.T) {
func TestExplode(t *testing.T) {
for i := 0; i < len(explodetests); i++ {
tt := explodetests[i];
a := Explode(tt.s);
......@@ -49,7 +49,7 @@ export func TestExplode(t *testing.T) {
}
}
export type SplitTest struct {
type SplitTest struct {
s string;
sep string;
a []string;
......@@ -64,7 +64,7 @@ var splittests = []SplitTest {
SplitTest{ faces, "~", []string{faces} },
SplitTest{ faces, "", []string{"☺", "☻", "☹"} },
}
export func TestSplit(t *testing.T) {
func TestSplit(t *testing.T) {
for i := 0; i < len(splittests); i++ {
tt := splittests[i];
a := Split(tt.s, tt.sep);
......
......@@ -8,7 +8,7 @@ func cas(val *int32, old, new int32) bool
func semacquire(*int32)
func semrelease(*int32)
export type Mutex struct {
type Mutex struct {
key int32;
sema int32;
}
......
......@@ -11,7 +11,7 @@ import (
"testing"
)
export func HammerSemaphore(s *int32, cdone chan bool) {
func HammerSemaphore(s *int32, cdone chan bool) {
for i := 0; i < 1000; i++ {
semacquire(s);
semrelease(s);
......@@ -19,7 +19,7 @@ export func HammerSemaphore(s *int32, cdone chan bool) {
cdone <- true;
}
export func TestSemaphore(t *testing.T) {
func TestSemaphore(t *testing.T) {
s := new(int32);
*s = 1;
c := make(chan bool);
......@@ -32,7 +32,7 @@ export func TestSemaphore(t *testing.T) {
}
export func HammerMutex(m *Mutex, cdone chan bool) {
func HammerMutex(m *Mutex, cdone chan bool) {
for i := 0; i < 1000; i++ {
m.Lock();
m.Unlock();
......@@ -40,7 +40,7 @@ export func HammerMutex(m *Mutex, cdone chan bool) {
cdone <- true;
}
export func TestMutex(t *testing.T) {
func TestMutex(t *testing.T) {
m := new(Mutex);
c := make(chan bool);
for i := 0; i < 10; i++ {
......
......@@ -4,7 +4,7 @@
package syscall
export const (
const (
ENONE=0;
EPERM=1;
ENOENT=2;
......@@ -234,7 +234,7 @@ func str(val int64) string { // do it here rather than with fmt to avoid depend
return string(buf)[i:len(buf)];
}
export func Errstr(errno int64) string {
func Errstr(errno int64) string {
if errno < 0 || errno >= len(error) {
return "Error " + str(errno)
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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