Remove the types float and complex.

Update to current version of Go library.

Update testsuite for removed types.

	* go-lang.c (go_langhook_init): Omit float_type_size when calling
	go_create_gogo.
	* go-c.h: Update declaration of go_create_gogo.

From-SVN: r169098
This commit is contained in:
Ian Lance Taylor 2011-01-21 18:19:03 +00:00 committed by Ian Lance Taylor
parent d6ed1c8903
commit ff5f50c52c
388 changed files with 21980 additions and 18002 deletions

View File

@ -1,3 +1,9 @@
2011-01-21 Ian Lance Taylor <iant@google.com>
* go-lang.c (go_langhook_init): Omit float_type_size when calling
go_create_gogo.
* go-c.h: Update declaration of go_create_gogo.
2011-01-13 Ian Lance Taylor <iant@google.com> 2011-01-13 Ian Lance Taylor <iant@google.com>
* go-backend.c: Include "rtl.h" and "target.h". * go-backend.c: Include "rtl.h" and "target.h".

View File

@ -41,8 +41,7 @@ extern void go_set_prefix (const char*);
extern void go_add_search_path (const char*); extern void go_add_search_path (const char*);
extern void go_create_gogo (int int_type_size, int float_type_size, extern void go_create_gogo (int int_type_size, int pointer_size);
int pointer_size);
extern void go_parse_input_files (const char**, unsigned int, extern void go_parse_input_files (const char**, unsigned int,
bool only_check_syntax, bool only_check_syntax,

View File

@ -1,5 +1,5 @@
/* go-lang.c -- Go frontend gcc interface. /* go-lang.c -- Go frontend gcc interface.
Copyright (C) 2009, 2010 Free Software Foundation, Inc. Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
@ -103,7 +103,7 @@ go_langhook_init (void)
to, e.g., unsigned_char_type_node) but before calling to, e.g., unsigned_char_type_node) but before calling
build_common_builtin_nodes (because it calls, indirectly, build_common_builtin_nodes (because it calls, indirectly,
go_type_for_size). */ go_type_for_size). */
go_create_gogo (INT_TYPE_SIZE, FLOAT_TYPE_SIZE, POINTER_SIZE); go_create_gogo (INT_TYPE_SIZE, POINTER_SIZE);
build_common_builtin_nodes (); build_common_builtin_nodes ();

View File

@ -345,8 +345,6 @@ Export::register_builtin_types(Gogo* gogo)
this->register_builtin_type(gogo, "int", BUILTIN_INT); this->register_builtin_type(gogo, "int", BUILTIN_INT);
this->register_builtin_type(gogo, "uint", BUILTIN_UINT); this->register_builtin_type(gogo, "uint", BUILTIN_UINT);
this->register_builtin_type(gogo, "uintptr", BUILTIN_UINTPTR); this->register_builtin_type(gogo, "uintptr", BUILTIN_UINTPTR);
this->register_builtin_type(gogo, "float", BUILTIN_FLOAT);
this->register_builtin_type(gogo, "complex", BUILTIN_COMPLEX);
this->register_builtin_type(gogo, "bool", BUILTIN_BOOL); this->register_builtin_type(gogo, "bool", BUILTIN_BOOL);
this->register_builtin_type(gogo, "string", BUILTIN_STRING); this->register_builtin_type(gogo, "string", BUILTIN_STRING);
} }

View File

@ -33,14 +33,12 @@ enum Builtin_code
BUILTIN_INT = -11, BUILTIN_INT = -11,
BUILTIN_UINT = -12, BUILTIN_UINT = -12,
BUILTIN_UINTPTR = -13, BUILTIN_UINTPTR = -13,
BUILTIN_FLOAT = -14,
BUILTIN_BOOL = -15, BUILTIN_BOOL = -15,
BUILTIN_STRING = -16, BUILTIN_STRING = -16,
BUILTIN_COMPLEX64 = -17, BUILTIN_COMPLEX64 = -17,
BUILTIN_COMPLEX128 = -18, BUILTIN_COMPLEX128 = -18,
BUILTIN_COMPLEX = -19,
SMALLEST_BUILTIN_CODE = -19 SMALLEST_BUILTIN_CODE = -18
}; };
// This class manages exporting Go declarations. It handles the main // This class manages exporting Go declarations. It handles the main

View File

@ -1932,7 +1932,7 @@ Float_expression::do_determine_type(const Type_context* context)
|| context->type->complex_type() != NULL)) || context->type->complex_type() != NULL))
this->type_ = context->type; this->type_ = context->type;
else if (!context->may_be_abstract) else if (!context->may_be_abstract)
this->type_ = Type::lookup_float_type("float"); this->type_ = Type::lookup_float_type("float64");
} }
// Return true if the floating point value VAL fits in the range of // Return true if the floating point value VAL fits in the range of
@ -2185,7 +2185,7 @@ Complex_expression::do_determine_type(const Type_context* context)
&& context->type->complex_type() != NULL) && context->type->complex_type() != NULL)
this->type_ = context->type; this->type_ = context->type;
else if (!context->may_be_abstract) else if (!context->may_be_abstract)
this->type_ = Type::lookup_complex_type("complex"); this->type_ = Type::lookup_complex_type("complex128");
} }
// Return true if the complex value REAL/IMAG fits in the range of the // Return true if the complex value REAL/IMAG fits in the range of the
@ -6473,7 +6473,7 @@ class Builtin_call_expression : public Call_expression
BUILTIN_CAP, BUILTIN_CAP,
BUILTIN_CLOSE, BUILTIN_CLOSE,
BUILTIN_CLOSED, BUILTIN_CLOSED,
BUILTIN_CMPLX, BUILTIN_COMPLEX,
BUILTIN_COPY, BUILTIN_COPY,
BUILTIN_IMAG, BUILTIN_IMAG,
BUILTIN_LEN, BUILTIN_LEN,
@ -6501,7 +6501,7 @@ class Builtin_call_expression : public Call_expression
real_imag_type(Type*); real_imag_type(Type*);
static Type* static Type*
cmplx_type(Type*); complex_type(Type*);
// A pointer back to the general IR structure. This avoids a global // A pointer back to the general IR structure. This avoids a global
// variable, or passing it around everywhere. // variable, or passing it around everywhere.
@ -6532,8 +6532,8 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
this->code_ = BUILTIN_CLOSE; this->code_ = BUILTIN_CLOSE;
else if (name == "closed") else if (name == "closed")
this->code_ = BUILTIN_CLOSED; this->code_ = BUILTIN_CLOSED;
else if (name == "cmplx") else if (name == "complex")
this->code_ = BUILTIN_CMPLX; this->code_ = BUILTIN_COMPLEX;
else if (name == "copy") else if (name == "copy")
this->code_ = BUILTIN_COPY; this->code_ = BUILTIN_COPY;
else if (name == "imag") else if (name == "imag")
@ -6774,9 +6774,7 @@ Builtin_call_expression::real_imag_type(Type* arg_type)
return NULL; return NULL;
while (nt->real_type()->named_type() != NULL) while (nt->real_type()->named_type() != NULL)
nt = nt->real_type()->named_type(); nt = nt->real_type()->named_type();
if (nt->name() == "complex") if (nt->name() == "complex64")
return Type::lookup_float_type("float");
else if (nt->name() == "complex64")
return Type::lookup_float_type("float32"); return Type::lookup_float_type("float32");
else if (nt->name() == "complex128") else if (nt->name() == "complex128")
return Type::lookup_float_type("float64"); return Type::lookup_float_type("float64");
@ -6784,11 +6782,11 @@ Builtin_call_expression::real_imag_type(Type* arg_type)
return NULL; return NULL;
} }
// Return the type of the cmplx function, given the type of one of the // Return the type of the complex function, given the type of one of the
// argments. Like real_imag_type, we have to map by name. // argments. Like real_imag_type, we have to map by name.
Type* Type*
Builtin_call_expression::cmplx_type(Type* arg_type) Builtin_call_expression::complex_type(Type* arg_type)
{ {
if (arg_type == NULL || arg_type->is_abstract()) if (arg_type == NULL || arg_type->is_abstract())
return NULL; return NULL;
@ -6797,9 +6795,7 @@ Builtin_call_expression::cmplx_type(Type* arg_type)
return NULL; return NULL;
while (nt->real_type()->named_type() != NULL) while (nt->real_type()->named_type() != NULL)
nt = nt->real_type()->named_type(); nt = nt->real_type()->named_type();
if (nt->name() == "float") if (nt->name() == "float32")
return Type::lookup_complex_type("complex");
else if (nt->name() == "float32")
return Type::lookup_complex_type("complex64"); return Type::lookup_complex_type("complex64");
else if (nt->name() == "float64") else if (nt->name() == "float64")
return Type::lookup_complex_type("complex128"); return Type::lookup_complex_type("complex128");
@ -6868,7 +6864,7 @@ Builtin_call_expression::do_is_constant() const
return arg->field_reference_expression() != NULL; return arg->field_reference_expression() != NULL;
} }
case BUILTIN_CMPLX: case BUILTIN_COMPLEX:
{ {
const Expression_list* args = this->args(); const Expression_list* args = this->args();
if (args != NULL && args->size() == 2) if (args != NULL && args->size() == 2)
@ -7053,7 +7049,7 @@ bool
Builtin_call_expression::do_complex_constant_value(mpfr_t real, mpfr_t imag, Builtin_call_expression::do_complex_constant_value(mpfr_t real, mpfr_t imag,
Type** ptype) const Type** ptype) const
{ {
if (this->code_ == BUILTIN_CMPLX) if (this->code_ == BUILTIN_COMPLEX)
{ {
const Expression_list* args = this->args(); const Expression_list* args = this->args();
if (args == NULL || args->size() != 2) if (args == NULL || args->size() != 2)
@ -7078,7 +7074,7 @@ Builtin_call_expression::do_complex_constant_value(mpfr_t real, mpfr_t imag,
{ {
mpfr_set(real, r, GMP_RNDN); mpfr_set(real, r, GMP_RNDN);
mpfr_set(imag, i, GMP_RNDN); mpfr_set(imag, i, GMP_RNDN);
*ptype = Builtin_call_expression::cmplx_type(rtype); *ptype = Builtin_call_expression::complex_type(rtype);
ret = true; ret = true;
} }
@ -7154,7 +7150,7 @@ Builtin_call_expression::do_type()
return t; return t;
} }
case BUILTIN_CMPLX: case BUILTIN_COMPLEX:
{ {
const Expression_list* args = this->args(); const Expression_list* args = this->args();
if (args == NULL || args->size() != 2) if (args == NULL || args->size() != 2)
@ -7166,7 +7162,7 @@ Builtin_call_expression::do_type()
if (t->is_abstract()) if (t->is_abstract())
t = t->make_non_abstract_type(); t = t->make_non_abstract_type();
} }
t = Builtin_call_expression::cmplx_type(t); t = Builtin_call_expression::complex_type(t);
if (t == NULL) if (t == NULL)
t = Type::make_error_type(); t = Type::make_error_type();
return t; return t;
@ -7195,13 +7191,13 @@ Builtin_call_expression::do_determine_type(const Type_context* context)
case BUILTIN_REAL: case BUILTIN_REAL:
case BUILTIN_IMAG: case BUILTIN_IMAG:
arg_type = Builtin_call_expression::cmplx_type(context->type); arg_type = Builtin_call_expression::complex_type(context->type);
is_print = false; is_print = false;
break; break;
case BUILTIN_CMPLX: case BUILTIN_COMPLEX:
{ {
// For the cmplx function the type of one operand can // For the complex function the type of one operand can
// determine the type of the other, as in a binary expression. // determine the type of the other, as in a binary expression.
arg_type = Builtin_call_expression::real_imag_type(context->type); arg_type = Builtin_call_expression::real_imag_type(context->type);
if (args != NULL && args->size() == 2) if (args != NULL && args->size() == 2)
@ -7498,7 +7494,7 @@ Builtin_call_expression::do_check_types(Gogo*)
} }
break; break;
case BUILTIN_CMPLX: case BUILTIN_COMPLEX:
{ {
const Expression_list* args = this->args(); const Expression_list* args = this->args();
if (args == NULL || args->size() < 2) if (args == NULL || args->size() < 2)
@ -7512,9 +7508,9 @@ Builtin_call_expression::do_check_types(Gogo*)
this->set_is_error(); this->set_is_error();
else if (!Type::are_identical(args->front()->type(), else if (!Type::are_identical(args->front()->type(),
args->back()->type(), true, NULL)) args->back()->type(), true, NULL))
this->report_error(_("cmplx arguments must have identical types")); this->report_error(_("complex arguments must have identical types"));
else if (args->front()->type()->float_type() == NULL) else if (args->front()->type()->float_type() == NULL)
this->report_error(_("cmplx arguments must have " this->report_error(_("complex arguments must have "
"floating-point type")); "floating-point type"));
} }
break; break;
@ -8077,7 +8073,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
arg_tree); arg_tree);
} }
case BUILTIN_CMPLX: case BUILTIN_COMPLEX:
{ {
const Expression_list* args = this->args(); const Expression_list* args = this->args();
gcc_assert(args != NULL && args->size() == 2); gcc_assert(args != NULL && args->size() == 2);

View File

@ -24,10 +24,10 @@ static Gogo* gogo;
GO_EXTERN_C GO_EXTERN_C
void void
go_create_gogo(int int_type_size, int float_type_size, int pointer_size) go_create_gogo(int int_type_size, int pointer_size)
{ {
gcc_assert(::gogo == NULL); gcc_assert(::gogo == NULL);
::gogo = new Gogo(int_type_size, float_type_size, pointer_size); ::gogo = new Gogo(int_type_size, pointer_size);
if (!unique_prefix.empty()) if (!unique_prefix.empty())
::gogo->set_unique_prefix(unique_prefix); ::gogo->set_unique_prefix(unique_prefix);
} }

View File

@ -19,7 +19,7 @@
// Class Gogo. // Class Gogo.
Gogo::Gogo(int int_type_size, int float_type_size, int pointer_size) Gogo::Gogo(int int_type_size, int pointer_size)
: package_(NULL), : package_(NULL),
functions_(), functions_(),
globals_(new Bindings(NULL)), globals_(new Bindings(NULL)),
@ -86,12 +86,6 @@ Gogo::Gogo(int int_type_size, int float_type_size, int pointer_size)
pointer_size, pointer_size,
RUNTIME_TYPE_KIND_UINTPTR)); RUNTIME_TYPE_KIND_UINTPTR));
this->add_named_type(Type::make_float_type("float", float_type_size,
RUNTIME_TYPE_KIND_FLOAT));
this->add_named_type(Type::make_complex_type("complex", float_type_size * 2,
RUNTIME_TYPE_KIND_COMPLEX));
this->add_named_type(Type::make_named_bool_type()); this->add_named_type(Type::make_named_bool_type());
this->add_named_type(Type::make_named_string_type()); this->add_named_type(Type::make_named_string_type());
@ -199,10 +193,10 @@ Gogo::Gogo(int int_type_size, int float_type_size, int pointer_size)
append_type->set_is_builtin(); append_type->set_is_builtin();
this->globals_->add_function_declaration("append", NULL, append_type, loc); this->globals_->add_function_declaration("append", NULL, append_type, loc);
Function_type* cmplx_type = Type::make_function_type(NULL, NULL, NULL, loc); Function_type* complex_type = Type::make_function_type(NULL, NULL, NULL, loc);
cmplx_type->set_is_varargs(); complex_type->set_is_varargs();
cmplx_type->set_is_builtin(); complex_type->set_is_builtin();
this->globals_->add_function_declaration("cmplx", NULL, cmplx_type, loc); this->globals_->add_function_declaration("complex", NULL, complex_type, loc);
Function_type* real_type = Type::make_function_type(NULL, NULL, NULL, loc); Function_type* real_type = Type::make_function_type(NULL, NULL, NULL, loc);
real_type->set_is_varargs(); real_type->set_is_varargs();
@ -212,7 +206,7 @@ Gogo::Gogo(int int_type_size, int float_type_size, int pointer_size)
Function_type* imag_type = Type::make_function_type(NULL, NULL, NULL, loc); Function_type* imag_type = Type::make_function_type(NULL, NULL, NULL, loc);
imag_type->set_is_varargs(); imag_type->set_is_varargs();
imag_type->set_is_builtin(); imag_type->set_is_builtin();
this->globals_->add_function_declaration("imag", NULL, cmplx_type, loc); this->globals_->add_function_declaration("imag", NULL, imag_type, loc);
this->define_builtin_function_trees(); this->define_builtin_function_trees();

View File

@ -100,9 +100,9 @@ operator<(const Import_init& i1, const Import_init& i2)
class Gogo class Gogo
{ {
public: public:
// Create the IR, passing in the sizes of the types "int", "float", // Create the IR, passing in the sizes of the types "int" and
// and "uintptr" in bits. // "uintptr" in bits.
Gogo(int int_type_size, int float_type_size, int pointer_size); Gogo(int int_type_size, int pointer_size);
// Get the package name. // Get the package name.
const std::string& const std::string&

View File

@ -704,8 +704,6 @@ Import::register_builtin_types(Gogo* gogo)
this->register_builtin_type(gogo, "int", BUILTIN_INT); this->register_builtin_type(gogo, "int", BUILTIN_INT);
this->register_builtin_type(gogo, "uint", BUILTIN_UINT); this->register_builtin_type(gogo, "uint", BUILTIN_UINT);
this->register_builtin_type(gogo, "uintptr", BUILTIN_UINTPTR); this->register_builtin_type(gogo, "uintptr", BUILTIN_UINTPTR);
this->register_builtin_type(gogo, "float", BUILTIN_FLOAT);
this->register_builtin_type(gogo, "complex", BUILTIN_COMPLEX);
this->register_builtin_type(gogo, "bool", BUILTIN_BOOL); this->register_builtin_type(gogo, "bool", BUILTIN_BOOL);
this->register_builtin_type(gogo, "string", BUILTIN_STRING); this->register_builtin_type(gogo, "string", BUILTIN_STRING);
} }

View File

@ -194,9 +194,9 @@ Type::make_non_abstract_type()
case TYPE_INTEGER: case TYPE_INTEGER:
return Type::lookup_integer_type("int"); return Type::lookup_integer_type("int");
case TYPE_FLOAT: case TYPE_FLOAT:
return Type::lookup_float_type("float"); return Type::lookup_float_type("float64");
case TYPE_COMPLEX: case TYPE_COMPLEX:
return Type::lookup_complex_type("complex"); return Type::lookup_complex_type("complex128");
case TYPE_STRING: case TYPE_STRING:
return Type::lookup_string_type(); return Type::lookup_string_type();
case TYPE_BOOLEAN: case TYPE_BOOLEAN:
@ -1872,8 +1872,7 @@ Float_type::create_abstract_float_type()
{ {
static Float_type* abstract_type; static Float_type* abstract_type;
if (abstract_type == NULL) if (abstract_type == NULL)
abstract_type = new Float_type(true, FLOAT_TYPE_SIZE, abstract_type = new Float_type(true, 64, RUNTIME_TYPE_KIND_FLOAT64);
RUNTIME_TYPE_KIND_FLOAT);
return abstract_type; return abstract_type;
} }
@ -2029,8 +2028,7 @@ Complex_type::create_abstract_complex_type()
{ {
static Complex_type* abstract_type; static Complex_type* abstract_type;
if (abstract_type == NULL) if (abstract_type == NULL)
abstract_type = new Complex_type(true, FLOAT_TYPE_SIZE * 2, abstract_type = new Complex_type(true, 128, RUNTIME_TYPE_KIND_COMPLEX128);
RUNTIME_TYPE_KIND_FLOAT);
return abstract_type; return abstract_type;
} }

View File

@ -60,22 +60,20 @@ static const int RUNTIME_TYPE_KIND_UINT16 = 9;
static const int RUNTIME_TYPE_KIND_UINT32 = 10; static const int RUNTIME_TYPE_KIND_UINT32 = 10;
static const int RUNTIME_TYPE_KIND_UINT64 = 11; static const int RUNTIME_TYPE_KIND_UINT64 = 11;
static const int RUNTIME_TYPE_KIND_UINTPTR = 12; static const int RUNTIME_TYPE_KIND_UINTPTR = 12;
static const int RUNTIME_TYPE_KIND_FLOAT = 13; static const int RUNTIME_TYPE_KIND_FLOAT32 = 13;
static const int RUNTIME_TYPE_KIND_FLOAT32 = 14; static const int RUNTIME_TYPE_KIND_FLOAT64 = 14;
static const int RUNTIME_TYPE_KIND_FLOAT64 = 15; static const int RUNTIME_TYPE_KIND_COMPLEX64 = 15;
static const int RUNTIME_TYPE_KIND_COMPLEX = 16; static const int RUNTIME_TYPE_KIND_COMPLEX128 = 16;
static const int RUNTIME_TYPE_KIND_COMPLEX64 = 17; static const int RUNTIME_TYPE_KIND_ARRAY = 17;
static const int RUNTIME_TYPE_KIND_COMPLEX128 = 18; static const int RUNTIME_TYPE_KIND_CHAN = 18;
static const int RUNTIME_TYPE_KIND_ARRAY = 19; static const int RUNTIME_TYPE_KIND_FUNC = 19;
static const int RUNTIME_TYPE_KIND_CHAN = 20; static const int RUNTIME_TYPE_KIND_INTERFACE = 20;
static const int RUNTIME_TYPE_KIND_FUNC = 21; static const int RUNTIME_TYPE_KIND_MAP = 21;
static const int RUNTIME_TYPE_KIND_INTERFACE = 22; static const int RUNTIME_TYPE_KIND_PTR = 22;
static const int RUNTIME_TYPE_KIND_MAP = 23; static const int RUNTIME_TYPE_KIND_SLICE = 23;
static const int RUNTIME_TYPE_KIND_PTR = 24; static const int RUNTIME_TYPE_KIND_STRING = 24;
static const int RUNTIME_TYPE_KIND_SLICE = 25; static const int RUNTIME_TYPE_KIND_STRUCT = 25;
static const int RUNTIME_TYPE_KIND_STRING = 26; static const int RUNTIME_TYPE_KIND_UNSAFE_POINTER = 26;
static const int RUNTIME_TYPE_KIND_STRUCT = 27;
static const int RUNTIME_TYPE_KIND_UNSAFE_POINTER = 28;
// To build the complete list of methods for a named type we need to // To build the complete list of methods for a named type we need to
// gather all methods from anonymous fields. Those methods may // gather all methods from anonymous fields. Those methods may

View File

@ -28,7 +28,7 @@ const (
c4 c4
) )
var ints = []string { var ints = []string{
"1", "1",
"2", "2",
"3", "3",
@ -36,15 +36,15 @@ var ints = []string {
func f() (int, int) { func f() (int, int) {
call += "f" call += "f"
return 1,2 return 1, 2
} }
func g() (float, float) { func g() (float64, float64) {
call += "g" call += "g"
return 3,4 return 3, 4
} }
func h(_ int, _ float) { func h(_ int, _ float64) {
} }
func i() int { func i() int {
@ -55,43 +55,64 @@ func i() int {
var _ = i() var _ = i()
func main() { func main() {
if call != "i" {panic("init did not run")} if call != "i" {
panic("init did not run")
}
call = "" call = ""
_, _ = f() _, _ = f()
a, _ := f() a, _ := f()
if a != 1 {panic(a)} if a != 1 {
panic(a)
}
b, _ := g() b, _ := g()
if b != 3 {panic(b)} if b != 3 {
panic(b)
}
_, a = f() _, a = f()
if a != 2 {panic(a)} if a != 2 {
panic(a)
}
_, b = g() _, b = g()
if b != 4 {panic(b)} if b != 4 {
panic(b)
}
_ = i() _ = i()
if call != "ffgfgi" {panic(call)} if call != "ffgfgi" {
if c4 != 4 {panic(c4)} panic(call)
}
if c4 != 4 {
panic(c4)
}
out := "" out := ""
for _, s := range ints { for _, s := range ints {
out += s out += s
} }
if out != "123" {panic(out)} if out != "123" {
panic(out)
}
sum := 0 sum := 0
for s, _ := range ints { for s := range ints {
sum += s sum += s
} }
if sum != 3 {panic(sum)} if sum != 3 {
panic(sum)
}
h(a,b) h(a, b)
} }
// useless but legal // useless but legal
var _ int = 1 var _ int = 1
var _ = 2 var _ = 2
var _, _ = 3, 4 var _, _ = 3, 4
const _ = 3 const _ = 3
const _, _ = 4, 5 const _, _ = 4, 5
type _ int type _ int
func _() { func _() {
panic("oops") panic("oops")
} }

View File

@ -7,25 +7,19 @@
package main package main
var ( var (
f float
f32 float32 f32 float32
f64 float64 f64 float64
c complex c64 complex64
c64 complex64
c128 complex128 c128 complex128
) )
func main() { func main() {
// ok // ok
c = cmplx(f, f) c64 = complex(f32, f32)
c64 = cmplx(f32, f32) c128 = complex(f64, f64)
c128 = cmplx(f64, f64)
_ = cmplx(f, f32) // ERROR "cmplx" _ = complex128(0) // ok
_ = cmplx(f, f64) // ERROR "cmplx" _ = complex(f32, f64) // ERROR "complex"
_ = cmplx(f32, f) // ERROR "cmplx" _ = complex(f64, f32) // ERROR "complex"
_ = cmplx(f32, f64) // ERROR "cmplx"
_ = cmplx(f64, f) // ERROR "cmplx"
_ = cmplx(f64, f32) // ERROR "cmplx"
} }

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,16 @@
package main package main
type T struct { i int; f float; s string; next *T } type T struct {
i int
f float64
s string
next *T
}
type R struct { num int } type R struct {
num int
}
func itor(a int) *R { func itor(a int) *R {
r := new(R) r := new(R)
@ -18,11 +25,16 @@ func itor(a int) *R {
func eq(a []*R) { func eq(a []*R) {
for i := 0; i < len(a); i++ { for i := 0; i < len(a); i++ {
if a[i].num != i { panic("bad") } if a[i].num != i {
panic("bad")
}
} }
} }
type P struct { a, b int } type P struct {
a, b int
}
func NewP(a, b int) *P { func NewP(a, b int) *P {
return &P{a, b} return &P{a, b}
} }
@ -34,37 +46,57 @@ func main() {
var tp *T var tp *T
tp = &T{0, 7.2, "hi", &t} tp = &T{0, 7.2, "hi", &t}
a1 := []int{1,2,3} a1 := []int{1, 2, 3}
if len(a1) != 3 { panic("a1") } if len(a1) != 3 {
a2 := [10]int{1,2,3} panic("a1")
if len(a2) != 10 || cap(a2) != 10 { panic("a2") } }
a2 := [10]int{1, 2, 3}
if len(a2) != 10 || cap(a2) != 10 {
panic("a2")
}
a3 := [10]int{1,2,3,} a3 := [10]int{1, 2, 3}
if len(a3) != 10 || a2[3] != 0 { panic("a3") } if len(a3) != 10 || a2[3] != 0 {
panic("a3")
}
var oai []int var oai []int
oai = []int{1,2,3} oai = []int{1, 2, 3}
if len(oai) != 3 { panic("oai") } if len(oai) != 3 {
panic("oai")
}
at := [...]*T{&t, tp, &t} at := [...]*T{&t, tp, &t}
if len(at) != 3 { panic("at") } if len(at) != 3 {
panic("at")
}
c := make(chan int) c := make(chan int)
ac := []chan int{c, c, c} ac := []chan int{c, c, c}
if len(ac) != 3 { panic("ac") } if len(ac) != 3 {
panic("ac")
}
aat := [][len(at)]*T{at, at} aat := [][len(at)]*T{at, at}
if len(aat) != 2 || len(aat[1]) != 3 { panic("aat") } if len(aat) != 2 || len(aat[1]) != 3 {
panic("aat")
}
s := string([]byte{'h', 'e', 'l', 'l', 'o'}) s := string([]byte{'h', 'e', 'l', 'l', 'o'})
if s != "hello" { panic("s") } if s != "hello" {
panic("s")
}
m := map[string]float{"one":1.0, "two":2.0, "pi":22./7.} m := map[string]float64{"one": 1.0, "two": 2.0, "pi": 22. / 7.}
if len(m) != 3 { panic("m") } if len(m) != 3 {
panic("m")
}
eq([]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)}) eq([]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)})
p1 := NewP(1, 2) p1 := NewP(1, 2)
p2 := NewP(1, 2) p2 := NewP(1, 2)
if p1 == p2 { panic("NewP") } if p1 == p2 {
panic("NewP")
}
} }

View File

@ -6,74 +6,75 @@
package main package main
type I interface {} type I interface{}
const ( const (
// assume all types behave similarly to int8/uint8 // assume all types behave similarly to int8/uint8
Int8 int8 = 101 Int8 int8 = 101
Minus1 int8 = -1 Minus1 int8 = -1
Uint8 uint8 = 102 Uint8 uint8 = 102
Const = 103 Const = 103
Float32 float32 = 104.5 Float32 float32 = 104.5
Float float = 105.5 Float64 float64 = 105.5
ConstFloat = 106.5 ConstFloat = 106.5
Big float64 = 1e300 Big float64 = 1e300
String = "abc" String = "abc"
Bool = true Bool = true
) )
var ( var (
a1 = Int8 * 100 // ERROR "overflow" a1 = Int8 * 100 // ERROR "overflow"
a2 = Int8 * -1 // OK a2 = Int8 * -1 // OK
a3 = Int8 * 1000 // ERROR "overflow" a3 = Int8 * 1000 // ERROR "overflow"
a4 = Int8 * int8(1000) // ERROR "overflow" a4 = Int8 * int8(1000) // ERROR "overflow"
a5 = int8(Int8 * 1000) // ERROR "overflow" a5 = int8(Int8 * 1000) // ERROR "overflow"
a6 = int8(Int8 * int8(1000)) // ERROR "overflow" a6 = int8(Int8 * int8(1000)) // ERROR "overflow"
a7 = Int8 - 2*Int8 - 2*Int8 // ERROR "overflow" a7 = Int8 - 2*Int8 - 2*Int8 // ERROR "overflow"
a8 = Int8 * Const / 100 // ERROR "overflow" a8 = Int8 * Const / 100 // ERROR "overflow"
a9 = Int8 * (Const / 100) // OK a9 = Int8 * (Const / 100) // OK
b1 = Uint8 * Uint8 // ERROR "overflow" b1 = Uint8 * Uint8 // ERROR "overflow"
b2 = Uint8 * -1 // ERROR "overflow" b2 = Uint8 * -1 // ERROR "overflow"
b3 = Uint8 - Uint8 // OK b3 = Uint8 - Uint8 // OK
b4 = Uint8 - Uint8 - Uint8 // ERROR "overflow" b4 = Uint8 - Uint8 - Uint8 // ERROR "overflow"
b5 = uint8(^0) // ERROR "overflow" b5 = uint8(^0) // ERROR "overflow"
b6 = ^uint8(0) // OK b6 = ^uint8(0) // OK
b7 = uint8(Minus1) // ERROR "overflow" b7 = uint8(Minus1) // ERROR "overflow"
b8 = uint8(int8(-1)) // ERROR "overflow" b8 = uint8(int8(-1)) // ERROR "overflow"
b8a = uint8(-1) // ERROR "overflow" b8a = uint8(-1) // ERROR "overflow"
b9 byte = (1<<10) >> 8 // OK b9 byte = (1 << 10) >> 8 // OK
b10 byte = (1<<10) // ERROR "overflow" b10 byte = (1 << 10) // ERROR "overflow"
b11 byte = (byte(1)<<10) >> 8 // ERROR "overflow" b11 byte = (byte(1) << 10) >> 8 // ERROR "overflow"
b12 byte = 1000 // ERROR "overflow" b12 byte = 1000 // ERROR "overflow"
b13 byte = byte(1000) // ERROR "overflow" b13 byte = byte(1000) // ERROR "overflow"
b14 byte = byte(100) * byte(100) // ERROR "overflow" b14 byte = byte(100) * byte(100) // ERROR "overflow"
b15 byte = byte(100) * 100 // ERROR "overflow" b15 byte = byte(100) * 100 // ERROR "overflow"
b16 byte = byte(0) * 1000 // ERROR "overflow" b16 byte = byte(0) * 1000 // ERROR "overflow"
b16a byte = 0 * 1000 // OK b16a byte = 0 * 1000 // OK
b17 byte = byte(0) * byte(1000) // ERROR "overflow" b17 byte = byte(0) * byte(1000) // ERROR "overflow"
b18 byte = Uint8/0 // ERROR "division by zero" b18 byte = Uint8 / 0 // ERROR "division by zero"
c1 float64 = Big c1 float64 = Big
c2 float64 = Big*Big // ERROR "overflow" c2 float64 = Big * Big // ERROR "overflow"
c3 float64 = float64(Big)*Big // ERROR "overflow" c3 float64 = float64(Big) * Big // ERROR "overflow"
c4 = Big*Big // ERROR "overflow" c4 = Big * Big // ERROR "overflow"
c5 = Big/0 // ERROR "division by zero" c5 = Big / 0 // ERROR "division by zero"
) )
func f(int) func f(int)
func main() { func main() {
f(Int8) // ERROR "convert|wrong type|cannot" f(Int8) // ERROR "convert|wrong type|cannot"
f(Minus1) // ERROR "convert|wrong type|cannot" f(Minus1) // ERROR "convert|wrong type|cannot"
f(Uint8) // ERROR "convert|wrong type|cannot" f(Uint8) // ERROR "convert|wrong type|cannot"
f(Const) // OK f(Const) // OK
f(Float32) // ERROR "convert|wrong type|cannot" f(Float32) // ERROR "convert|wrong type|cannot"
f(Float) // ERROR "convert|wrong type|cannot" f(Float64) // ERROR "convert|wrong type|cannot"
f(ConstFloat) // ERROR "truncate" f(ConstFloat) // ERROR "truncate"
f(ConstFloat - 0.5) // OK f(ConstFloat - 0.5) // OK
f(Big) // ERROR "convert|wrong type|cannot" f(Big) // ERROR "convert|wrong type|cannot"
f(String) // ERROR "convert|wrong type|cannot|incompatible" f(String) // ERROR "convert|wrong type|cannot|incompatible"
f(Bool) // ERROR "convert|wrong type|cannot|incompatible" f(Bool) // ERROR "convert|wrong type|cannot|incompatible"
} }

View File

@ -11,54 +11,56 @@ package main
// the language spec says for now. // the language spec says for now.
var x1 = string(1) var x1 = string(1)
var x2 string = string(1) var x2 string = string(1)
var x3 = int(1.5) // ERROR "convert|truncate" var x3 = int(1.5) // ERROR "convert|truncate"
var x4 int = int(1.5) // ERROR "convert|truncate" var x4 int = int(1.5) // ERROR "convert|truncate"
var x5 = "a" + string(1) var x5 = "a" + string(1)
var x6 = int(1e100) // ERROR "overflow" var x6 = int(1e100) // ERROR "overflow"
var x7 = float(1e1000) // ERROR "overflow" var x7 = float32(1e1000) // ERROR "overflow"
// implicit conversions merit scrutiny // implicit conversions merit scrutiny
var s string var s string
var bad1 string = 1 // ERROR "conver|incompatible|invalid|cannot" var bad1 string = 1 // ERROR "conver|incompatible|invalid|cannot"
var bad2 = s + 1 // ERROR "conver|incompatible|invalid" var bad2 = s + 1 // ERROR "conver|incompatible|invalid"
var bad3 = s + 'a' // ERROR "conver|incompatible|invalid" var bad3 = s + 'a' // ERROR "conver|incompatible|invalid"
var bad4 = "a" + 1 // ERROR "literals|incompatible|convert|invalid" var bad4 = "a" + 1 // ERROR "literals|incompatible|convert|invalid"
var bad5 = "a" + 'a' // ERROR "literals|incompatible|convert|invalid" var bad5 = "a" + 'a' // ERROR "literals|incompatible|convert|invalid"
var bad6 int = 1.5 // ERROR "convert|truncate" var bad6 int = 1.5 // ERROR "convert|truncate"
var bad7 int = 1e100 // ERROR "overflow" var bad7 int = 1e100 // ERROR "overflow"
var bad8 float32 = 1e200 // ERROR "overflow" var bad8 float32 = 1e200 // ERROR "overflow"
// but these implicit conversions are okay // but these implicit conversions are okay
var good1 string = "a" var good1 string = "a"
var good2 int = 1.0 var good2 int = 1.0
var good3 int = 1e9 var good3 int = 1e9
var good4 float = 1e20 var good4 float64 = 1e20
// explicit conversion of string is okay // explicit conversion of string is okay
var _ = []int("abc") var _ = []int("abc")
var _ = []byte("abc") var _ = []byte("abc")
// implicit is not // implicit is not
var _ []int = "abc" // ERROR "cannot use|incompatible|invalid" var _ []int = "abc" // ERROR "cannot use|incompatible|invalid"
var _ []byte = "abc" // ERROR "cannot use|incompatible|invalid" var _ []byte = "abc" // ERROR "cannot use|incompatible|invalid"
// named string is okay // named string is okay
type Tstring string type Tstring string
var ss Tstring = "abc" var ss Tstring = "abc"
var _ = []int(ss) var _ = []int(ss)
var _ = []byte(ss) var _ = []byte(ss)
// implicit is still not // implicit is still not
var _ []int = ss // ERROR "cannot use|incompatible|invalid" var _ []int = ss // ERROR "cannot use|incompatible|invalid"
var _ []byte = ss // ERROR "cannot use|incompatible|invalid" var _ []byte = ss // ERROR "cannot use|incompatible|invalid"
// named slice is not // named slice is not
type Tint []int type Tint []int
type Tbyte []byte type Tbyte []byte
var _ = Tint("abc") // ERROR "convert|incompatible|invalid"
var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid" var _ = Tint("abc") // ERROR "convert|incompatible|invalid"
var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid"
// implicit is still not // implicit is still not
var _ Tint = "abc" // ERROR "cannot use|incompatible|invalid" var _ Tint = "abc" // ERROR "cannot use|incompatible|invalid"
var _ Tbyte = "abc" // ERROR "cannot use|incompatible|invalid" var _ Tbyte = "abc" // ERROR "cannot use|incompatible|invalid"

View File

@ -8,26 +8,26 @@
package main package main
func f1() int { return 1 } func f1() int { return 1 }
func f2() (float, int) { return 1, 2 } func f2() (float32, int) { return 1, 2 }
func f3() (float, int, string) { return 1, 2, "3" } func f3() (float32, int, string) { return 1, 2, "3" }
func x() (s string) { func x() (s string) {
a, b, s := f3() a, b, s := f3()
_, _ = a, b _, _ = a, b
return // tests that result var is in scope for redeclaration return // tests that result var is in scope for redeclaration
} }
func main() { func main() {
i, f, s := f3() i, f, s := f3()
j, f := f2() // redeclare f j, f := f2() // redeclare f
k := f1() k := f1()
m, g, s := f3() m, g, s := f3()
m, h, s := f3() m, h, s := f3()
{ {
// new block should be ok. // new block should be ok.
i, f, s := f3() i, f, s := f3()
j, f := f2() // redeclare f j, f := f2() // redeclare f
k := f1() k := f1()
m, g, s := f3() m, g, s := f3()
m, h, s := f3() m, h, s := f3()

View File

@ -8,51 +8,51 @@
package main package main
func f1() int { return 1 } func f1() int { return 1 }
func f2() (float, int) { return 1, 2 } func f2() (float32, int) { return 1, 2 }
func f3() (float, int, string) { return 1, 2, "3" } func f3() (float32, int, string) { return 1, 2, "3" }
func main() { func main() {
{ {
// simple redeclaration // simple redeclaration
i := f1() i := f1()
i := f1() // ERROR "redeclared|no new" i := f1() // ERROR "redeclared|no new"
_ = i _ = i
} }
{ {
// change of type for f // change of type for f
i, f, s := f3() i, f, s := f3()
f, g, t := f3() // ERROR "redeclared|cannot assign|incompatible" f, g, t := f3() // ERROR "redeclared|cannot assign|incompatible"
_, _, _, _, _ = i, f, s, g, t _, _, _, _, _ = i, f, s, g, t
} }
{ {
// change of type for i // change of type for i
i, f, s := f3() i, f, s := f3()
j, i, t := f3() // ERROR "redeclared|cannot assign|incompatible" j, i, t := f3() // ERROR "redeclared|cannot assign|incompatible"
_, _, _, _, _ = i, f, s, j, t _, _, _, _, _ = i, f, s, j, t
} }
{ {
// no new variables // no new variables
i, f, s := f3() i, f, s := f3()
i, f := f2() // ERROR "redeclared|no new" i, f := f2() // ERROR "redeclared|no new"
_, _, _ = i, f, s _, _, _ = i, f, s
} }
{ {
// single redeclaration // single redeclaration
i, f, s := f3() i, f, s := f3()
i := f1() // ERROR "redeclared|no new|incompatible" i := f1() // ERROR "redeclared|no new|incompatible"
_, _, _ = i, f, s _, _, _ = i, f, s
} }
// double redeclaration // double redeclaration
{ {
i, f, s := f3() i, f, s := f3()
i, f := f2() // ERROR "redeclared|no new" i, f := f2() // ERROR "redeclared|no new"
_, _, _ = i, f, s _, _, _ = i, f, s
} }
{ {
// triple redeclaration // triple redeclaration
i, f, s := f3() i, f, s := f3()
i, f, s := f3() // ERROR "redeclared|no new" i, f, s := f3() // ERROR "redeclared|no new"
_, _, _ = i, f, s _, _, _ = i, f, s
} }
} }

View File

@ -9,11 +9,16 @@ package main
import "os" import "os"
const ( const (
x float = iota; x float64 = iota
g float = 4.5 * iota; g float64 = 4.5 * iota
); )
func main() { func main() {
if g == 0.0 { print("zero\n");} if g == 0.0 {
if g != 4.5 { print(" fail\n"); os.Exit(1); } print("zero\n")
}
if g != 4.5 {
print(" fail\n")
os.Exit(1)
}
} }

View File

@ -7,7 +7,9 @@
package main package main
type ( type (
Point struct { x, y float }; Point struct {
x, y float64
}
Polar Point Polar Point
) )

View File

@ -7,14 +7,14 @@
package main package main
func f(i int, f float) { func f(i int, f float64) {
i = 8; i = 8
f = 8.0; f = 8.0
return; return
} }
func main() { func main() {
f(3, float(5)) f(3, float64(5))
} }
/* /*

View File

@ -8,19 +8,19 @@ package main
type T struct { type T struct {
x, y int; x, y int
} }
func (t *T) m(a int, b float) int { func (t *T) m(a int, b float64) int {
return (t.x+a) * (t.y+int(b)); return (t.x + a) * (t.y + int(b))
} }
func main() { func main() {
var t *T = new(T); var t *T = new(T)
t.x = 1; t.x = 1
t.y = 2; t.y = 2
r10 := t.m(1, 3.0); r10 := t.m(1, 3.0)
_ = r10; _ = r10
} }
/* /*
bug11.go:16: fatal error: walktype: switch 1 unknown op CALLMETH l(16) <int32>INT32 bug11.go:16: fatal error: walktype: switch 1 unknown op CALLMETH l(16) <int32>INT32

View File

@ -6,8 +6,8 @@
package main package main
func f9(a int) (i int, f float) { func f9(a int) (i int, f float64) {
i := 9; // ERROR "redecl|no new" i := 9 // ERROR "redecl|no new"
f := float(9); // ERROR "redecl|no new" f := float64(9) // ERROR "redecl|no new"
return i, f; return i, f
} }

View File

@ -9,15 +9,15 @@ package main
func main() { func main() {
type T struct { type T struct {
s string; s string
f float; f float64
}; }
var s string = "hello"; var s string = "hello"
var f float = 0.2; var f float64 = 0.2
t := T{s, f}; t := T{s, f}
type M map[int] int; type M map[int]int
m0 := M{7:8}; m0 := M{7: 8}
_, _ = t, m0; _, _ = t, m0
} }

View File

@ -4,18 +4,18 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package main package main
func f1() (x int, y float) { func f1() (x int, y float64) {
return; return
} }
func f2 (x int, y float) { func f2(x int, y float64) {
return; return
} }
func main() { func main() {
f2(f1()); // this should be a legal call f2(f1()) // this should be a legal call
} }
/* /*

View File

@ -5,10 +5,11 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package main package main
func f(a float) float {
e := 1.0; func f(a float64) float64 {
e = e * a; e := 1.0
return e; e = e * a
return e
} }
/* /*

View File

@ -7,20 +7,24 @@
package main package main
func f1() { func f1() {
type T struct { x int } type T struct {
x int
}
} }
func f2() { func f2() {
type T struct { x float } type T struct {
x float64
}
} }
func main() { func main() {
f1(); f1()
f2(); f2()
} }
/* /*
1606416576: conflicting definitions for main.T·bug167 1606416576: conflicting definitions for main.T·bug167
bug167.6: type main.T·bug167 struct { x int } bug167.6: type main.T·bug167 struct { x int }
bug167.6: type main.T·bug167 struct { x float } bug167.6: type main.T·bug167 struct { x float64 }
*/ */

View File

@ -7,10 +7,10 @@
package main package main
func main() { func main() {
s := uint(10); s := uint(10)
ss := 1<<s; ss := 1 << s
y1 := float(ss); y1 := float64(ss)
y2 := float(1<<s); // ERROR "shift" y2 := float64(1 << s) // ERROR "shift"
y3 := string(1<<s); // ERROR "shift" y3 := string(1 << s) // ERROR "shift"
_, _, _, _, _ = s, ss, y1, y2, y3; _, _, _, _, _ = s, ss, y1, y2, y3
} }

View File

@ -10,14 +10,14 @@ import "go/ast";
func g(list []ast.Expr) { func g(list []ast.Expr) {
n := len(list)-1; n := len(list)-1;
println(list[n].Pos().Line); println(list[n].Pos());
} }
// f is the same as g except that the expression assigned to n is inlined. // f is the same as g except that the expression assigned to n is inlined.
func f(list []ast.Expr) { func f(list []ast.Expr) {
// n := len(list)-1; // n := len(list)-1;
println(list[len(list)-1 /* n */].Pos().Line); println(list[len(list)-1 /* n */].Pos());
} }

View File

@ -7,8 +7,8 @@
package main package main
func main() { func main() {
m := make(map[int]map[uint]float); m := make(map[int]map[uint]float64)
m[0] = make(map[uint]float), false; // 6g used to reject this m[0] = make(map[uint]float64), false // 6g used to reject this
m[1] = nil; m[1] = nil
} }

View File

@ -8,14 +8,17 @@ package main
type S string type S string
type I int type I int
type F float type F float64
func (S) m() {} func (S) m() {}
func (I) m() {} func (I) m() {}
func (F) m() {} func (F) m() {}
func main() { func main() {
c := make(chan interface { m() }, 10) c := make(chan interface {
m()
},
10)
c <- I(0) c <- I(0)
c <- F(1) c <- F(1)
c <- S("hi") c <- S("hi")

View File

@ -17,6 +17,6 @@ const f struct{} = 6 // ERROR "convert|wrong|invalid"
const g interface{} = 7 // ERROR "constant|wrong|invalid" const g interface{} = 7 // ERROR "constant|wrong|invalid"
const h bool = false const h bool = false
const i int = 2 const i int = 2
const j float = 5 const j float64 = 5
func main() { println(a, b, c, d, e, f, g) } func main() { println(a, b, c, d, e, f, g) }

View File

@ -23,7 +23,7 @@ type t0 int
func (t0) M(p0.T) {} func (t0) M(p0.T) {}
type t1 float type t1 float64
func (t1) M(p1.T) {} func (t1) M(p1.T) {}

View File

@ -26,7 +26,7 @@ type t0 int
func (t0) M(p0.T) {} func (t0) M(p0.T) {}
// t1 satisfies I1 and p1.I // t1 satisfies I1 and p1.I
type t1 float type t1 float64
func (t1) M(p1.T) {} func (t1) M(p1.T) {}

View File

@ -11,9 +11,9 @@ type T struct {
x int x int
y (int) y (int)
int int
*float *float64
// not legal according to spec // not legal according to spec
(complex) // ERROR "non-declaration|expected|parenthesize" (complex128) // ERROR "non-declaration|expected|parenthesize"
(*string) // ERROR "non-declaration|expected|parenthesize" (*string) // ERROR "non-declaration|expected|parenthesize"
*(bool) // ERROR "non-declaration|expected|parenthesize" *(bool) // ERROR "non-declaration|expected|parenthesize"
} }

View File

@ -21,10 +21,10 @@ func f2(a int) {
} }
func f3(a, b int) int { func f3(a, b int) int {
return a+b return a + b
} }
func f4(a, b int, c float) int { func f4(a, b int, c float32) int {
return (a+b)/2 + int(c) return (a+b)/2 + int(c)
} }
@ -36,12 +36,12 @@ func f6(a int) (r int) {
return 6 return 6
} }
func f7(a int) (x int, y float) { func f7(a int) (x int, y float32) {
return 7, 7.0 return 7, 7.0
} }
func f8(a int) (x int, y float) { func f8(a int) (x int, y float32) {
return 8, 8.0 return 8, 8.0
} }
@ -49,12 +49,12 @@ type T struct {
x, y int x, y int
} }
func (t *T) m10(a int, b float) int { func (t *T) m10(a int, b float32) int {
return (t.x+a) * (t.y+int(b)) return (t.x + a) * (t.y + int(b))
} }
func f9(a int) (i int, f float) { func f9(a int) (i int, f float32) {
i = 9 i = 9
f = 9.0 f = 9.0
return return

View File

@ -8,11 +8,11 @@
package main package main
func f1(a int) (int, float) { // BUG (not caught by compiler): multiple return values must have names func f1(a int) (int, float32) { // BUG (not caught by compiler): multiple return values must have names
return 7, 7.0 return 7, 7.0
} }
func f2(a int) (a int, b float) { // ERROR "redeclared|definition" func f2(a int) (a int, b float32) { // ERROR "redeclared|definition"
return 8, 8.0 return 8, 8.0
} }

View File

@ -51,21 +51,25 @@ func main() {
t = T(e) // ERROR "need explicit|need type assertion|incompatible" t = T(e) // ERROR "need explicit|need type assertion|incompatible"
} }
type M interface { M() } type M interface {
M()
}
var m M var m M
var _ = m.(int) // ERROR "impossible type assertion" var _ = m.(int) // ERROR "impossible type assertion"
type Int int type Int int
func (Int) M(float) {}
var _ = m.(Int) // ERROR "impossible type assertion" func (Int) M(float64) {}
var _ = m.(Int) // ERROR "impossible type assertion"
var ii int var ii int
var jj Int var jj Int
var m1 M = ii // ERROR "incompatible|missing" var m1 M = ii // ERROR "incompatible|missing"
var m2 M = jj // ERROR "incompatible|wrong type for M method" var m2 M = jj // ERROR "incompatible|wrong type for M method"
var m3 = M(ii) // ERROR "invalid|missing" var m3 = M(ii) // ERROR "invalid|missing"
var m4 = M(jj) // ERROR "invalid|wrong type for M method" var m4 = M(jj) // ERROR "invalid|wrong type for M method"

View File

@ -17,8 +17,8 @@ const (
x int = iota x int = iota
y = iota y = iota
z = 1 << iota z = 1 << iota
f float = 2 * iota f float32 = 2 * iota
g float = 4.5 * float(iota) g float32 = 4.5 * float32(iota)
) )
const ( const (
@ -57,7 +57,7 @@ const (
) )
const ( const (
p = float(iota) p = float32(iota)
q q
r r
) )
@ -68,9 +68,9 @@ const (
) )
const ( const (
abit, amask = 1 << iota, 1 << iota - 1 abit, amask = 1 << iota, 1<<iota - 1
bbit, bmask = 1 << iota, 1 << iota - 1 bbit, bmask = 1 << iota, 1<<iota - 1
cbit, cmask = 1 << iota, 1 << iota - 1 cbit, cmask = 1 << iota, 1<<iota - 1
) )
func main() { func main() {

View File

@ -13,7 +13,7 @@ const (
C1 = R + I // ADD(5,6) C1 = R + I // ADD(5,6)
) )
func doprint(c complex) { println(c) } func doprint(c complex128) { println(c) }
func main() { func main() {

View File

@ -48,7 +48,7 @@ func main() {
booltest(6+9i, false) booltest(6+9i, false)
} }
func booltest(a complex, r bool) { func booltest(a complex64, r bool) {
var b bool var b bool
b = a == C1 b = a == C1

View File

@ -16,24 +16,18 @@ const (
C1 = R + I // ADD(5,6) C1 = R + I // ADD(5,6)
) )
var complexBits = reflect.Typeof(complex(0i)).Size() * 8
func main() { func main() {
c0 := C1 c0 := C1
c0 = (c0 + c0 + c0) / (c0 + c0 + 3i) c0 = (c0 + c0 + c0) / (c0 + c0 + 3i)
println(c0) println(c0)
c := *(*complex)(unsafe.Pointer(&c0)) c := *(*complex128)(unsafe.Pointer(&c0))
println(c) println(c)
println(complexBits)
var a interface{} var a interface{}
switch c := reflect.NewValue(a).(type) { switch c := reflect.NewValue(a).(type) {
case *reflect.ComplexValue: case *reflect.ComplexValue:
if complexBits == 64 { v := c.Get()
v := c.Get() _, _ = complex128(v), true
_, _ = complex64(v), true
}
} }
} }

View File

@ -15,7 +15,7 @@ const (
C1 = R + I // ADD(5,6) C1 = R + I // ADD(5,6)
) )
func doprint(c complex) { fmt.Printf("c = %f\n", c) } func doprint(c complex128) { fmt.Printf("c = %f\n", c) }
func main() { func main() {
@ -32,12 +32,12 @@ func main() {
c2 := complex128(C1) c2 := complex128(C1)
fmt.Printf("c = %G\n", c2) fmt.Printf("c = %G\n", c2)
// real, imag, cmplx // real, imag, complex
c3 := cmplx(real(c2)+3, imag(c2)-5) + c2 c3 := complex(real(c2)+3, imag(c2)-5) + c2
fmt.Printf("c = %G\n", c3) fmt.Printf("c = %G\n", c3)
// compiler used to crash on nested divide // compiler used to crash on nested divide
c4 := cmplx(real(c3/2), imag(c3/2)) c4 := complex(real(c3/2), imag(c3/2))
if c4 != c3/2 { if c4 != c3/2 {
fmt.Printf("BUG: c3 = %G != c4 = %G\n", c3, c4) fmt.Printf("BUG: c3 = %G != c4 = %G\n", c3, c4)
} }

View File

@ -6,49 +6,49 @@
package main package main
var a [12]complex var a [12]complex128
var s []complex var s []complex128
var c chan complex var c chan complex128
var f struct { var f struct {
c complex c complex128
} }
var m map[complex]complex var m map[complex128]complex128
func main() { func main() {
// array of complex // array of complex128
for i := 0; i < len(a); i++ { for i := 0; i < len(a); i++ {
a[i] = cmplx(float(i), float(-i)) a[i] = complex(float64(i), float64(-i))
} }
println(a[5]) println(a[5])
// slice of complex // slice of complex128
s = make([]complex, len(a)) s = make([]complex128, len(a))
for i := 0; i < len(s); i++ { for i := 0; i < len(s); i++ {
s[i] = a[i] s[i] = a[i]
} }
println(s[5]) println(s[5])
// chan // chan
c = make(chan complex) c = make(chan complex128)
go chantest(c) go chantest(c)
println(<-c) println(<-c)
// pointer of complex // pointer of complex128
v := a[5] v := a[5]
pv := &v pv := &v
println(*pv) println(*pv)
// field of complex // field of complex128
f.c = a[5] f.c = a[5]
println(f.c) println(f.c)
// map of complex // map of complex128
m = make(map[complex]complex) m = make(map[complex128]complex128)
for i := 0; i < len(s); i++ { for i := 0; i < len(s); i++ {
m[-a[i]] = a[i] m[-a[i]] = a[i]
} }
println(m[5i-5]) println(m[5i-5])
println(m[cmplx(-5, 5)]) println(m[complex(-5, 5)])
} }
func chantest(c chan complex) { c <- a[5] } func chantest(c chan complex128) { c <- a[5] }

View File

@ -8,8 +8,8 @@ package main
func assertequal(is, shouldbe int, msg string) { func assertequal(is, shouldbe int, msg string) {
if is != shouldbe { if is != shouldbe {
print("assertion fail" + msg + "\n"); print("assertion fail" + msg + "\n")
panic(1); panic(1)
} }
} }
@ -20,75 +20,75 @@ func f2(a int) {
} }
func f3(a, b int) int { func f3(a, b int) int {
return a+b; return a + b
} }
func f4(a, b int, c float) int { func f4(a, b int, c float64) int {
return (a+b)/2 + int(c); return (a+b)/2 + int(c)
} }
func f5(a int) int { func f5(a int) int {
return 5; return 5
} }
func f6(a int) (r int) { func f6(a int) (r int) {
return 6; return 6
} }
func f7(a int) (x int, y float) { func f7(a int) (x int, y float64) {
return 7, 7.0; return 7, 7.0
} }
func f8(a int) (x int, y float) { func f8(a int) (x int, y float64) {
return 8, 8.0; return 8, 8.0
} }
type T struct { type T struct {
x, y int; x, y int
} }
func (t *T) m10(a int, b float) int { func (t *T) m10(a int, b float64) int {
return (t.x+a) * (t.y+int(b)); return (t.x + a) * (t.y + int(b))
} }
func f9(a int) (in int, fl float) { func f9(a int) (in int, fl float64) {
i := 9; i := 9
f := float(9); f := float64(9)
return i, f; return i, f
} }
func main() { func main() {
f1(); f1()
f2(1); f2(1)
r3 := f3(1, 2); r3 := f3(1, 2)
assertequal(r3, 3, "3"); assertequal(r3, 3, "3")
r4 := f4(0, 2, 3.0); r4 := f4(0, 2, 3.0)
assertequal(r4, 4, "4"); assertequal(r4, 4, "4")
r5 := f5(1); r5 := f5(1)
assertequal(r5, 5, "5"); assertequal(r5, 5, "5")
r6 := f6(1); r6 := f6(1)
assertequal(r6, 6, "6"); assertequal(r6, 6, "6")
var r7 int; var r7 int
var s7 float; var s7 float64
r7, s7 = f7(1); r7, s7 = f7(1)
assertequal(r7, 7, "r7"); assertequal(r7, 7, "r7")
assertequal(int(s7), 7, "s7"); assertequal(int(s7), 7, "s7")
var r8 int; var r8 int
var s8 float; var s8 float64
r8, s8 = f8(1); r8, s8 = f8(1)
assertequal(r8, 8, "r8"); assertequal(r8, 8, "r8")
assertequal(int(s8), 8, "s8"); assertequal(int(s8), 8, "s8")
var r9 int; var r9 int
var s9 float; var s9 float64
r9, s9 = f9(1); r9, s9 = f9(1)
assertequal(r9, 9, "r9"); assertequal(r9, 9, "r9")
assertequal(int(s9), 9, "s9"); assertequal(int(s9), 9, "s9")
var t *T = new(T); var t *T = new(T)
t.x = 1; t.x = 1
t.y = 2; t.y = 2
r10 := t.m10(1, 3.0); r10 := t.m10(1, 3.0)
assertequal(r10, 10, "10"); assertequal(r10, 10, "10")
} }

View File

@ -6,20 +6,23 @@
package main package main
type vlong int64; type vlong int64
type short int16; type short int16
func func main() {
main() { s1 := vlong(0)
s1 := vlong(0); for i := short(0); i < 10; i = i + 1 {
for i:=short(0); i<10; i=i+1 { s1 = s1 + vlong(i)
s1 = s1 + vlong(i); }
if s1 != 45 {
panic(s1)
} }
if s1 != 45 { panic(s1); }
s2 := float(0); s2 := float64(0)
for i:=0; i<10; i=i+1 { for i := 0; i < 10; i = i + 1 {
s2 = s2 + float(i); s2 = s2 + float64(i)
}
if s2 != 45 {
panic(s2)
} }
if s2 != 45 { panic(s2); }
} }

View File

@ -8,8 +8,8 @@ package main
var bx [10]byte var bx [10]byte
var by []byte var by []byte
var fx [10]float var fx [10]float64
var fy []float var fy []float64
var lb, hb int var lb, hb int
var t int var t int
@ -87,7 +87,7 @@ func main() {
by = bx[2:8] by = bx[2:8]
tstb() tstb()
// width 4 (float) // width 4 (float64)
lb = 0 lb = 0
hb = 10 hb = 10
fy = fx[lb:hb] fy = fx[lb:hb]
@ -204,7 +204,7 @@ func init() {
by = nil by = nil
for i := 0; i < len(fx); i++ { for i := 0; i < len(fx); i++ {
fx[i] = float(i + 20) fx[i] = float64(i + 20)
} }
fy = nil fy = nil
} }

View File

@ -8,8 +8,8 @@ package main
var bx []byte var bx []byte
var by []byte var by []byte
var fx []float var fx []float64
var fy []float var fy []float64
var lb, hb int var lb, hb int
var t int var t int
@ -78,7 +78,7 @@ func main() {
by = bx[2:8] by = bx[2:8]
tstb() tstb()
// width 4 (float) // width 4 (float64)
lb = 0 lb = 0
hb = 10 hb = 10
fy = fx[lb:hb] fy = fx[lb:hb]
@ -195,9 +195,9 @@ func init() {
} }
by = nil by = nil
fx = make([]float, 10) fx = make([]float64, 10)
for i := 0; i < len(fx); i++ { for i := 0; i < len(fx); i++ {
fx[i] = float(i + 20) fx[i] = float64(i + 20)
} }
fy = nil fy = nil
} }

View File

@ -6,8 +6,6 @@
package main package main
import "os"
var nbad int var nbad int
func assert(cond bool, msg string) { func assert(cond bool, msg string) {
@ -20,16 +18,8 @@ func assert(cond bool, msg string) {
} }
} }
func equal(a, b float) bool { func equal(a, b float32) bool {
if os.Getenv("GOARCH") != "arm" { return a == b
return a == b
}
d := a-b
if a > b {
return d < a * 1.0e-7
}
d = -d
return d < b * 1.0e-7
} }
@ -47,7 +37,7 @@ func main() {
var i04 int8 = -127 var i04 int8 = -127
var i05 int8 = -128 var i05 int8 = -128
var i06 int8 = +127 var i06 int8 = +127
assert(i01 == i00 + 1, "i01") assert(i01 == i00+1, "i01")
assert(i02 == -i01, "i02") assert(i02 == -i01, "i02")
assert(i03 == -i04, "i03") assert(i03 == -i04, "i03")
assert(-(i05+1) == i06, "i05") assert(-(i05+1) == i06, "i05")
@ -60,7 +50,7 @@ func main() {
var i14 int16 = -32767 var i14 int16 = -32767
var i15 int16 = -32768 var i15 int16 = -32768
var i16 int16 = +32767 var i16 int16 = +32767
assert(i11 == i10 + 1, "i11") assert(i11 == i10+1, "i11")
assert(i12 == -i11, "i12") assert(i12 == -i11, "i12")
assert(i13 == -i14, "i13") assert(i13 == -i14, "i13")
assert(-(i15+1) == i16, "i15") assert(-(i15+1) == i16, "i15")
@ -73,11 +63,11 @@ func main() {
var i24 int32 = -2147483647 var i24 int32 = -2147483647
var i25 int32 = -2147483648 var i25 int32 = -2147483648
var i26 int32 = +2147483647 var i26 int32 = +2147483647
assert(i21 == i20 + 1, "i21") assert(i21 == i20+1, "i21")
assert(i22 == -i21, "i22") assert(i22 == -i21, "i22")
assert(i23 == -i24, "i23") assert(i23 == -i24, "i23")
assert(-(i25+1) == i26, "i25") assert(-(i25+1) == i26, "i25")
assert(i23 == (1 << 31) - 1, "i23 size") assert(i23 == (1<<31)-1, "i23 size")
// int64 // int64
var i30 int64 = 0 var i30 int64 = 0
@ -87,27 +77,27 @@ func main() {
var i34 int64 = -9223372036854775807 var i34 int64 = -9223372036854775807
var i35 int64 = -9223372036854775808 var i35 int64 = -9223372036854775808
var i36 int64 = +9223372036854775807 var i36 int64 = +9223372036854775807
assert(i31 == i30 + 1, "i31") assert(i31 == i30+1, "i31")
assert(i32 == -i31, "i32") assert(i32 == -i31, "i32")
assert(i33 == -i34, "i33") assert(i33 == -i34, "i33")
assert(-(i35+1) == i36, "i35") assert(-(i35+1) == i36, "i35")
assert(i33 == (1<<63) - 1, "i33 size") assert(i33 == (1<<63)-1, "i33 size")
// uint8 // uint8
var u00 uint8 = 0 var u00 uint8 = 0
var u01 uint8 = 1 var u01 uint8 = 1
var u02 uint8 = 255 var u02 uint8 = 255
var u03 uint8 = +255 var u03 uint8 = +255
assert(u01 == u00 + 1, "u01") assert(u01 == u00+1, "u01")
assert(u02 == u03, "u02") assert(u02 == u03, "u02")
assert(u03 == (1<<8) - 1, "u03 size") assert(u03 == (1<<8)-1, "u03 size")
// uint16 // uint16
var u10 uint16 = 0 var u10 uint16 = 0
var u11 uint16 = 1 var u11 uint16 = 1
var u12 uint16 = 65535 var u12 uint16 = 65535
var u13 uint16 = +65535 var u13 uint16 = +65535
assert(u11 == u10 + 1, "u11") assert(u11 == u10+1, "u11")
assert(u12 == u13, "u12") assert(u12 == u13, "u12")
// uint32 // uint32
@ -115,7 +105,7 @@ func main() {
var u21 uint32 = 1 var u21 uint32 = 1
var u22 uint32 = 4294967295 var u22 uint32 = 4294967295
var u23 uint32 = +4294967295 var u23 uint32 = +4294967295
assert(u21 == u20 + 1, "u21") assert(u21 == u20+1, "u21")
assert(u22 == u23, "u22") assert(u22 == u23, "u22")
// uint64 // uint64
@ -126,23 +116,23 @@ func main() {
_, _, _, _ = u30, u31, u32, u33 _, _, _, _ = u30, u31, u32, u33
// float // float
var f00 float = 3.14159 var f00 float32 = 3.14159
var f01 float = -3.14159 var f01 float32 = -3.14159
var f02 float = +3.14159 var f02 float32 = +3.14159
var f03 float = 0.0 var f03 float32 = 0.0
var f04 float = .0 var f04 float32 = .0
var f05 float = 0. var f05 float32 = 0.
var f06 float = -0.0 var f06 float32 = -0.0
var f07 float = 1e10 var f07 float32 = 1e10
var f08 float = -1e10 var f08 float32 = -1e10
var f09 float = 1e-10 var f09 float32 = 1e-10
var f10 float = 1e+10 var f10 float32 = 1e+10
var f11 float = 1.e-10 var f11 float32 = 1.e-10
var f12 float = 1.e+10 var f12 float32 = 1.e+10
var f13 float = .1e-10 var f13 float32 = .1e-10
var f14 float = .1e+10 var f14 float32 = .1e+10
var f15 float = 1.1e-10 var f15 float32 = 1.1e-10
var f16 float = 1.1e+10 var f16 float32 = 1.1e+10
assert(f01 == -f00, "f01") assert(f01 == -f00, "f01")
assert(f02 == -f01, "f02") assert(f02 == -f01, "f02")
assert(f03 == f04, "f03") assert(f03 == f04, "f03")
@ -179,7 +169,6 @@ func main() {
assert(c8 == 0x0b, "c8") assert(c8 == 0x0b, "c8")
assert(c9 == 0x672c, "c9") assert(c9 == 0x672c, "c9")
var c00 uint8 = '\000' var c00 uint8 = '\000'
var c01 uint8 = '\007' var c01 uint8 = '\007'
var c02 uint8 = '\177' var c02 uint8 = '\177'

View File

@ -21,73 +21,73 @@ func P(a []string) string {
} }
s += `"` + a[i] + `"` s += `"` + a[i] + `"`
} }
s +="}" s += "}"
return s return s
} }
func main() { func main() {
// Test a map literal. // Test a map literal.
mlit := map[string] int { "0":0, "1":1, "2":2, "3":3, "4":4 } mlit := map[string]int{"0": 0, "1": 1, "2": 2, "3": 3, "4": 4}
for i := 0; i < len(mlit); i++ { for i := 0; i < len(mlit); i++ {
s := string([]byte{byte(i)+'0'}) s := string([]byte{byte(i) + '0'})
if mlit[s] != i { if mlit[s] != i {
fmt.Printf("mlit[%s] = %d\n", s, mlit[s]) fmt.Printf("mlit[%s] = %d\n", s, mlit[s])
} }
} }
mib := make(map[int] bool) mib := make(map[int]bool)
mii := make(map[int] int) mii := make(map[int]int)
mfi := make(map[float] int) mfi := make(map[float32]int)
mif := make(map[int] float) mif := make(map[int]float32)
msi := make(map[string] int) msi := make(map[string]int)
mis := make(map[int] string) mis := make(map[int]string)
mss := make(map[string] string) mss := make(map[string]string)
mspa := make(map[string] []string) mspa := make(map[string][]string)
// BUG need an interface map both ways too // BUG need an interface map both ways too
type T struct { type T struct {
i int64 // can't use string here; struct values are only compared at the top level i int64 // can't use string here; struct values are only compared at the top level
f float f float32
} }
mipT := make(map[int] *T) mipT := make(map[int]*T)
mpTi := make(map[*T] int) mpTi := make(map[*T]int)
mit := make(map[int] T) mit := make(map[int]T)
// mti := make(map[T] int) // mti := make(map[T] int)
type M map[int] int type M map[int]int
mipM := make(map[int] M) mipM := make(map[int]M)
var apT [2*count]*T var apT [2 * count]*T
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
s := strconv.Itoa(i) s := strconv.Itoa(i)
s10 := strconv.Itoa(i*10) s10 := strconv.Itoa(i * 10)
f := float(i) f := float32(i)
t := T{int64(i),f} t := T{int64(i), f}
apT[i] = new(T) apT[i] = new(T)
apT[i].i = int64(i) apT[i].i = int64(i)
apT[i].f = f apT[i].f = f
apT[2*i] = new(T) // need twice as many entries as we use, for the nonexistence check apT[2*i] = new(T) // need twice as many entries as we use, for the nonexistence check
apT[2*i].i = int64(i) apT[2*i].i = int64(i)
apT[2*i].f = f apT[2*i].f = f
m := M{i: i+1} m := M{i: i + 1}
mib[i] = (i != 0) mib[i] = (i != 0)
mii[i] = 10*i mii[i] = 10 * i
mfi[float(i)] = 10*i mfi[float32(i)] = 10 * i
mif[i] = 10.0*f mif[i] = 10.0 * f
mis[i] = s mis[i] = s
msi[s] = i msi[s] = i
mss[s] = s10 mss[s] = s10
mss[s] = s10 mss[s] = s10
as := make([]string, 2) as := make([]string, 2)
as[0] = s10 as[0] = s10
as[1] = s10 as[1] = s10
mspa[s] = as mspa[s] = as
mipT[i] = apT[i] mipT[i] = apT[i]
mpTi[apT[i]] = i mpTi[apT[i]] = i
mipM[i] = m mipM[i] = m
mit[i] = t mit[i] = t
// mti[t] = i // mti[t] = i
} }
// test len // test len
@ -121,15 +121,15 @@ func main() {
if len(mpTi) != count { if len(mpTi) != count {
fmt.Printf("len(mpTi) = %d\n", len(mpTi)) fmt.Printf("len(mpTi) = %d\n", len(mpTi))
} }
// if len(mti) != count { // if len(mti) != count {
// fmt.Printf("len(mti) = %d\n", len(mti)) // fmt.Printf("len(mti) = %d\n", len(mti))
// } // }
if len(mipM) != count { if len(mipM) != count {
fmt.Printf("len(mipM) = %d\n", len(mipM)) fmt.Printf("len(mipM) = %d\n", len(mipM))
} }
// if len(mti) != count { // if len(mti) != count {
// fmt.Printf("len(mti) = %d\n", len(mti)) // fmt.Printf("len(mti) = %d\n", len(mti))
// } // }
if len(mit) != count { if len(mit) != count {
fmt.Printf("len(mit) = %d\n", len(mit)) fmt.Printf("len(mit) = %d\n", len(mit))
} }
@ -137,25 +137,25 @@ func main() {
// test construction directly // test construction directly
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
s := strconv.Itoa(i) s := strconv.Itoa(i)
s10 := strconv.Itoa(i*10) s10 := strconv.Itoa(i * 10)
f := float(i) f := float32(i)
// BUG m := M(i, i+1) // BUG m := M(i, i+1)
if mib[i] != (i != 0) { if mib[i] != (i != 0) {
fmt.Printf("mib[%d] = %t\n", i, mib[i]) fmt.Printf("mib[%d] = %t\n", i, mib[i])
} }
if(mii[i] != 10*i) { if mii[i] != 10*i {
fmt.Printf("mii[%d] = %d\n", i, mii[i]) fmt.Printf("mii[%d] = %d\n", i, mii[i])
} }
if(mfi[f] != 10*i) { if mfi[f] != 10*i {
fmt.Printf("mfi[%d] = %d\n", i, mfi[f]) fmt.Printf("mfi[%d] = %d\n", i, mfi[f])
} }
if(mif[i] != 10.0*f) { if mif[i] != 10.0*f {
fmt.Printf("mif[%d] = %g\n", i, mif[i]) fmt.Printf("mif[%d] = %g\n", i, mif[i])
} }
if(mis[i] != s) { if mis[i] != s {
fmt.Printf("mis[%d] = %s\n", i, mis[i]) fmt.Printf("mis[%d] = %s\n", i, mis[i])
} }
if(msi[s] != i) { if msi[s] != i {
fmt.Printf("msi[%s] = %d\n", s, msi[s]) fmt.Printf("msi[%s] = %d\n", s, msi[s])
} }
if mss[s] != s10 { if mss[s] != s10 {
@ -166,22 +166,22 @@ func main() {
fmt.Printf("mspa[%s][%d] = %s\n", s, j, mspa[s][j]) fmt.Printf("mspa[%s][%d] = %s\n", s, j, mspa[s][j])
} }
} }
if(mipT[i].i != int64(i) || mipT[i].f != f) { if mipT[i].i != int64(i) || mipT[i].f != f {
fmt.Printf("mipT[%d] = %v\n", i, mipT[i]) fmt.Printf("mipT[%d] = %v\n", i, mipT[i])
} }
if(mpTi[apT[i]] != i) { if mpTi[apT[i]] != i {
fmt.Printf("mpTi[apT[%d]] = %d\n", i, mpTi[apT[i]]) fmt.Printf("mpTi[apT[%d]] = %d\n", i, mpTi[apT[i]])
} }
// if(mti[t] != i) { // if(mti[t] != i) {
// fmt.Printf("mti[%s] = %s\n", s, mti[t]) // fmt.Printf("mti[%s] = %s\n", s, mti[t])
// } // }
if (mipM[i][i] != i + 1) { if mipM[i][i] != i+1 {
fmt.Printf("mipM[%d][%d] = %d\n", i, i, mipM[i][i]) fmt.Printf("mipM[%d][%d] = %d\n", i, i, mipM[i][i])
} }
// if(mti[t] != i) { // if(mti[t] != i) {
// fmt.Printf("mti[%v] = %d\n", t, mti[t]) // fmt.Printf("mti[%v] = %d\n", t, mti[t])
// } // }
if(mit[i].i != int64(i) || mit[i].f != f) { if mit[i].i != int64(i) || mit[i].f != f {
fmt.Printf("mit[%d] = {%d %g}\n", i, mit[i].i, mit[i].f) fmt.Printf("mit[%d] = {%d %g}\n", i, mit[i].i, mit[i].f)
} }
} }
@ -190,7 +190,7 @@ func main() {
// failed lookups yield a false value for the boolean. // failed lookups yield a false value for the boolean.
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
s := strconv.Itoa(i) s := strconv.Itoa(i)
f := float(i) f := float32(i)
{ {
_, b := mib[i] _, b := mib[i]
if !b { if !b {
@ -311,23 +311,23 @@ func main() {
fmt.Printf("tuple existence assign: mit[%d]\n", i) fmt.Printf("tuple existence assign: mit[%d]\n", i)
} }
} }
// { // {
// _, b := mti[t] // _, b := mti[t]
// if !b { // if !b {
// fmt.Printf("tuple existence decl: mti[%d]\n", i) // fmt.Printf("tuple existence decl: mti[%d]\n", i)
// } // }
// _, b = mti[t] // _, b = mti[t]
// if !b { // if !b {
// fmt.Printf("tuple existence assign: mti[%d]\n", i) // fmt.Printf("tuple existence assign: mti[%d]\n", i)
// } // }
// } // }
} }
// test nonexistence with tuple check // test nonexistence with tuple check
// failed lookups yield a false value for the boolean. // failed lookups yield a false value for the boolean.
for i := count; i < 2*count; i++ { for i := count; i < 2*count; i++ {
s := strconv.Itoa(i) s := strconv.Itoa(i)
f := float(i) f := float32(i)
{ {
_, b := mib[i] _, b := mib[i]
if b { if b {
@ -438,16 +438,16 @@ func main() {
fmt.Printf("tuple nonexistence assign: mipM[%d]", i) fmt.Printf("tuple nonexistence assign: mipM[%d]", i)
} }
} }
// { // {
// _, b := mti[t] // _, b := mti[t]
// if b { // if b {
// fmt.Printf("tuple nonexistence decl: mti[%d]", i) // fmt.Printf("tuple nonexistence decl: mti[%d]", i)
// } // }
// _, b = mti[t] // _, b = mti[t]
// if b { // if b {
// fmt.Printf("tuple nonexistence assign: mti[%d]", i) // fmt.Printf("tuple nonexistence assign: mti[%d]", i)
// } // }
// } // }
{ {
_, b := mit[i] _, b := mit[i]
if b { if b {
@ -460,32 +460,31 @@ func main() {
} }
} }
// tests for structured map element updates // tests for structured map element updates
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
s := strconv.Itoa(i) s := strconv.Itoa(i)
mspa[s][i % 2] = "deleted" mspa[s][i%2] = "deleted"
if mspa[s][i % 2] != "deleted" { if mspa[s][i%2] != "deleted" {
fmt.Printf("update mspa[%s][%d] = %s\n", s, i %2, mspa[s][i % 2]) fmt.Printf("update mspa[%s][%d] = %s\n", s, i%2, mspa[s][i%2])
} }
mipT[i].i += 1 mipT[i].i += 1
if mipT[i].i != int64(i)+1 { if mipT[i].i != int64(i)+1 {
fmt.Printf("update mipT[%d].i = %d\n", i, mipT[i].i) fmt.Printf("update mipT[%d].i = %d\n", i, mipT[i].i)
} }
mipT[i].f = float(i + 1) mipT[i].f = float32(i + 1)
if (mipT[i].f != float(i + 1)) { if mipT[i].f != float32(i+1) {
fmt.Printf("update mipT[%d].f = %g\n", i, mipT[i].f) fmt.Printf("update mipT[%d].f = %g\n", i, mipT[i].f)
} }
mipM[i][i]++ mipM[i][i]++
if mipM[i][i] != (i + 1) + 1 { if mipM[i][i] != (i+1)+1 {
fmt.Printf("update mipM[%d][%d] = %i\n", i, i, mipM[i][i]) fmt.Printf("update mipM[%d][%d] = %i\n", i, i, mipM[i][i])
} }
} }
// test range on nil map // test range on nil map
var mnil map[string] int var mnil map[string]int
for _, _ = range mnil { for _, _ = range mnil {
panic("range mnil") panic("range mnil")
} }

View File

@ -8,10 +8,10 @@ package main
type T struct { } type T struct { }
func (t *T) M(int, string) // GCCGO_ERROR "previous" func (t *T) M(int, string) // GCCGO_ERROR "previous"
func (t *T) M(int, float) { } // ERROR "redeclared|redefinition" func (t *T) M(int, float64) { } // ERROR "redeclared|redefinition"
func f(int, string) // GCCGO_ERROR "previous" func f(int, string) // GCCGO_ERROR "previous"
func f(int, float) { } // ERROR "redeclared|redefinition" func f(int, float64) { } // ERROR "redeclared|redefinition"
func g(a int, b string) // GCCGO_ERROR "previous" func g(a int, b string) // GCCGO_ERROR "previous"
func g(a int, c string) // ERROR "redeclared|redefinition" func g(a int, c string) // ERROR "redeclared|redefinition"

View File

@ -12,7 +12,7 @@ package main
type Array [10]byte type Array [10]byte
type Bool bool type Bool bool
type Chan chan int type Chan chan int
type Float float type Float float32
type Int int type Int int
type Map map[int]byte type Map map[int]byte
type Slice []byte type Slice []byte

View File

@ -10,14 +10,13 @@ type T struct {
i int i int
} }
type IN interface { type IN interface{}
}
func main() { func main() {
var i *int var i *int
var f *float var f *float32
var s *string var s *string
var m map[float] *int var m map[float32]*int
var c chan int var c chan int
var t *T var t *T
var in IN var in IN

View File

@ -7,7 +7,6 @@
// Test of recover for run-time errors. // Test of recover for run-time errors.
// TODO(rsc): // TODO(rsc):
// integer divide by zero?
// null pointer accesses // null pointer accesses
package main package main
@ -15,7 +14,6 @@ package main
import ( import (
"os" "os"
"strings" "strings"
"syscall"
) )
var x = make([]byte, 10) var x = make([]byte, 10)
@ -60,7 +58,7 @@ func test3() {
func test4() { func test4() {
defer mustRecover("interface") defer mustRecover("interface")
var x interface{} = 1 var x interface{} = 1
println(x.(float)) println(x.(float32))
} }
type T struct { type T struct {
@ -83,10 +81,6 @@ func test6() {
} }
func test7() { func test7() {
if syscall.ARCH == "arm" || syscall.OS == "nacl" {
// ARM doesn't have integer divide trap yet
return
}
defer mustRecover("divide by zero") defer mustRecover("divide by zero")
var x, y int var x, y int
println(x / y) println(x / y)

View File

@ -6,12 +6,11 @@
package main package main
const const a_const = 0
a_const = 0
const ( const (
pi = /* the usual */ 3.14159265358979323 pi = /* the usual */ 3.14159265358979323
e = 2.718281828 e = 2.718281828
mask1 int = 1 << iota mask1 int = 1 << iota
mask2 = 1 << iota mask2 = 1 << iota
mask3 = 1 << iota mask3 = 1 << iota
@ -19,7 +18,7 @@ const (
) )
type ( type (
Empty interface {} Empty interface{}
Point struct { Point struct {
x, y int x, y int
} }
@ -32,19 +31,21 @@ func (p *Point) Initialize(x, y int) *Point {
} }
func (p *Point) Distance() int { func (p *Point) Distance() int {
return p.x * p.x + p.y * p.y return p.x*p.x + p.y*p.y
} }
var ( var (
x1 int x1 int
x2 int x2 int
u, v, w float u, v, w float32
) )
func foo() {} func foo() {}
func min(x, y int) int { func min(x, y int) int {
if x < y { return x; } if x < y {
return x
}
return y return y
} }
@ -57,24 +58,29 @@ func swap(x, y int) (u, v int) {
func control_structs() { func control_structs() {
var p *Point = new(Point).Initialize(2, 3) var p *Point = new(Point).Initialize(2, 3)
i := p.Distance() i := p.Distance()
var f float = 0.3 var f float32 = 0.3
_ = f _ = f
for {} for {
for {} }
for {
}
for j := 0; j < i; j++ { for j := 0; j < i; j++ {
if i == 0 { if i == 0 {
} else i = 0 } else {
var x float i = 0
}
var x float32
_ = x _ = x
} }
foo: // a label foo: // a label
var j int var j int
switch y := 0; true { switch y := 0; true {
case i < y: case i < y:
fallthrough fallthrough
case i < j: case i < j:
case i == 0, i == 1, i == j: case i == 0, i == 1, i == j:
i++; i++ i++
i++
goto foo goto foo
default: default:
i = -+-+i i = -+-+i

View File

@ -21,12 +21,15 @@ const (
Last Last
) )
type S struct { a int } type S struct {
a int
}
var s S = S{1234} var s S = S{1234}
var c = make(chan int) var c = make(chan int)
var a = []int{0,1,2,3} var a = []int{0, 1, 2, 3}
var m = make(map[string]int) var m = make(map[string]int)
@ -68,10 +71,10 @@ func main() {
assert(x == true && i == Bool, "bool") assert(x == true && i == Bool, "bool")
case int: case int:
assert(x == 7 && i == Int, "int") assert(x == 7 && i == Int, "int")
case float: case float64:
assert(x == 7.4 && i == Float, "float") assert(x == 7.4 && i == Float, "float64")
case string: case string:
assert(x == "hello"&& i == String, "string") assert(x == "hello" && i == String, "string")
case S: case S:
assert(x.a == 1234 && i == Struct, "struct") assert(x.a == 1234 && i == Struct, "struct")
case chan int: case chan int:

View File

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"math" "math"
"strings" "strings"
"syscall"
) )
type Error interface { type Error interface {
@ -18,56 +17,90 @@ type Error interface {
} }
type ErrorTest struct { type ErrorTest struct {
name string name string
fn func() fn func()
err string err string
} }
var ( var (
i, j, k int = 0, 0, 1 i, j, k int = 0, 0, 1
i8, j8, k8 int8 = 0, 0, 1 i8, j8, k8 int8 = 0, 0, 1
i16, j16, k16 int16 = 0, 0, 1 i16, j16, k16 int16 = 0, 0, 1
i32, j32, k32 int32 = 0, 0, 1 i32, j32, k32 int32 = 0, 0, 1
i64, j64, k64 int64 = 0, 0, 1 i64, j64, k64 int64 = 0, 0, 1
u, v, w uint = 0, 0, 1 u, v, w uint = 0, 0, 1
u8, v8, w8 uint8 = 0, 0, 1 u8, v8, w8 uint8 = 0, 0, 1
u16, v16, w16 uint16 = 0, 0, 1 u16, v16, w16 uint16 = 0, 0, 1
u32, v32, w32 uint32 = 0, 0, 1 u32, v32, w32 uint32 = 0, 0, 1
u64, v64, w64 uint64 = 0, 0, 1 u64, v64, w64 uint64 = 0, 0, 1
up, vp, wp uintptr = 0, 0, 1 up, vp, wp uintptr = 0, 0, 1
f, g, h float = 0, 0, 1 f, g, h float64 = 0, 0, 1
f32, g32, h32 float32 = 0, 0, 1 f32, g32, h32 float32 = 0, 0, 1
f64, g64, h64, inf, negInf, nan float64 = 0, 0, 1, math.Inf(1), math.Inf(-1), math.NaN() f64, g64, h64, inf, negInf, nan float64 = 0, 0, 1, math.Inf(1), math.Inf(-1), math.NaN()
c, d, e complex = 0+0i, 0+0i, 1+1i c, d, e complex128 = 0 + 0i, 0 + 0i, 1 + 1i
c64, d64, e64 complex64 = 0+0i, 0+0i, 1+1i c64, d64, e64 complex64 = 0 + 0i, 0 + 0i, 1 + 1i
c128, d128, e128 complex128 = 0+0i, 0+0i, 1+1i c128, d128, e128 complex128 = 0 + 0i, 0 + 0i, 1 + 1i
) )
// Fool gccgo into thinking that these variables can change. // Fool gccgo into thinking that these variables can change.
func NotCalled() { func NotCalled() {
i++; j++; k++ i++
i8++; j8++; k8++ j++
i16++; j16++; k16++ k++
i32++; j32++; k32++ i8++
i64++; j64++; k64++ j8++
k8++
i16++
j16++
k16++
i32++
j32++
k32++
i64++
j64++
k64++
u++; v++; w++ u++
u8++; v8++; w8++ v++
u16++; v16++; w16++ w++
u32++; v32++; w32++ u8++
u64++; v64++; w64++ v8++
up++; vp++; wp++ w8++
u16++
v16++
w16++
u32++
v32++
w32++
u64++
v64++
w64++
up++
vp++
wp++
f += 1; g += 1; h += 1 f += 1
f32 += 1; g32 += 1; h32 += 1 g += 1
f64 += 1; g64 += 1; h64 += 1 h += 1
f32 += 1
g32 += 1
h32 += 1
f64 += 1
g64 += 1
h64 += 1
c += 1+1i; d += 1+1i; e += 1+1i c += 1 + 1i
c64 += 1+1i; d64 += 1+1i; e64 += 1+1i d += 1 + 1i
c128 += 1+1i; d128 += 1+1i; e128 += 1+1i e += 1 + 1i
c64 += 1 + 1i
d64 += 1 + 1i
e64 += 1 + 1i
c128 += 1 + 1i
d128 += 1 + 1i
e128 += 1 + 1i
} }
var tmp interface{} var tmp interface{}
@ -80,52 +113,52 @@ func use(v interface{}) {
// Verify error/no error for all types. // Verify error/no error for all types.
var errorTests = []ErrorTest{ var errorTests = []ErrorTest{
// All integer divide by zero should error. // All integer divide by zero should error.
ErrorTest{ "int 0/0", func() { use(i/j) }, "divide", }, ErrorTest{"int 0/0", func() { use(i / j) }, "divide"},
ErrorTest{ "int8 0/0", func() { use(i8/j8) }, "divide", }, ErrorTest{"int8 0/0", func() { use(i8 / j8) }, "divide"},
ErrorTest{ "int16 0/0", func() { use(i16/j16) }, "divide", }, ErrorTest{"int16 0/0", func() { use(i16 / j16) }, "divide"},
ErrorTest{ "int32 0/0", func() { use(i32/j32) }, "divide", }, ErrorTest{"int32 0/0", func() { use(i32 / j32) }, "divide"},
ErrorTest{ "int64 0/0", func() { use(i64/j64) }, "divide", }, ErrorTest{"int64 0/0", func() { use(i64 / j64) }, "divide"},
ErrorTest{ "int 1/0", func() { use(k/j) }, "divide", }, ErrorTest{"int 1/0", func() { use(k / j) }, "divide"},
ErrorTest{ "int8 1/0", func() { use(k8/j8) }, "divide", }, ErrorTest{"int8 1/0", func() { use(k8 / j8) }, "divide"},
ErrorTest{ "int16 1/0", func() { use(k16/j16) }, "divide", }, ErrorTest{"int16 1/0", func() { use(k16 / j16) }, "divide"},
ErrorTest{ "int32 1/0", func() { use(k32/j32) }, "divide", }, ErrorTest{"int32 1/0", func() { use(k32 / j32) }, "divide"},
ErrorTest{ "int64 1/0", func() { use(k64/j64) }, "divide", }, ErrorTest{"int64 1/0", func() { use(k64 / j64) }, "divide"},
ErrorTest{ "uint 0/0", func() { use(u/v) }, "divide", }, ErrorTest{"uint 0/0", func() { use(u / v) }, "divide"},
ErrorTest{ "uint8 0/0", func() { use(u8/v8) }, "divide", }, ErrorTest{"uint8 0/0", func() { use(u8 / v8) }, "divide"},
ErrorTest{ "uint16 0/0", func() { use(u16/v16) }, "divide", }, ErrorTest{"uint16 0/0", func() { use(u16 / v16) }, "divide"},
ErrorTest{ "uint32 0/0", func() { use(u32/v32) }, "divide", }, ErrorTest{"uint32 0/0", func() { use(u32 / v32) }, "divide"},
ErrorTest{ "uint64 0/0", func() { use(u64/v64) }, "divide", }, ErrorTest{"uint64 0/0", func() { use(u64 / v64) }, "divide"},
ErrorTest{ "uintptr 0/0", func() { use(up/vp) }, "divide", }, ErrorTest{"uintptr 0/0", func() { use(up / vp) }, "divide"},
ErrorTest{ "uint 1/0", func() { use(w/v) }, "divide", }, ErrorTest{"uint 1/0", func() { use(w / v) }, "divide"},
ErrorTest{ "uint8 1/0", func() { use(w8/v8) }, "divide", }, ErrorTest{"uint8 1/0", func() { use(w8 / v8) }, "divide"},
ErrorTest{ "uint16 1/0", func() { use(w16/v16) }, "divide", }, ErrorTest{"uint16 1/0", func() { use(w16 / v16) }, "divide"},
ErrorTest{ "uint32 1/0", func() { use(w32/v32) }, "divide", }, ErrorTest{"uint32 1/0", func() { use(w32 / v32) }, "divide"},
ErrorTest{ "uint64 1/0", func() { use(w64/v64) }, "divide", }, ErrorTest{"uint64 1/0", func() { use(w64 / v64) }, "divide"},
ErrorTest{ "uintptr 1/0", func() { use(wp/vp) }, "divide", }, ErrorTest{"uintptr 1/0", func() { use(wp / vp) }, "divide"},
// All floating divide by zero should not error. // All float64ing divide by zero should not error.
ErrorTest{ "float 0/0", func() { use(f/g) }, "", }, ErrorTest{"float64 0/0", func() { use(f / g) }, ""},
ErrorTest{ "float32 0/0", func() { use(f32/g32) }, "", }, ErrorTest{"float32 0/0", func() { use(f32 / g32) }, ""},
ErrorTest{ "float64 0/0", func() { use(f64/g64) }, "", }, ErrorTest{"float64 0/0", func() { use(f64 / g64) }, ""},
ErrorTest{ "float 1/0", func() { use(h/g) }, "", }, ErrorTest{"float64 1/0", func() { use(h / g) }, ""},
ErrorTest{ "float32 1/0", func() { use(h32/g32) }, "", }, ErrorTest{"float32 1/0", func() { use(h32 / g32) }, ""},
ErrorTest{ "float64 1/0", func() { use(h64/g64) }, "", }, ErrorTest{"float64 1/0", func() { use(h64 / g64) }, ""},
ErrorTest{ "float64 inf/0", func() { use(inf/g64) }, "", }, ErrorTest{"float64 inf/0", func() { use(inf / g64) }, ""},
ErrorTest{ "float64 -inf/0", func() { use(negInf/g64) }, "", }, ErrorTest{"float64 -inf/0", func() { use(negInf / g64) }, ""},
ErrorTest{ "float64 nan/0", func() { use(nan/g64) }, "", }, ErrorTest{"float64 nan/0", func() { use(nan / g64) }, ""},
// All complex divide by zero should not error. // All complex divide by zero should not error.
ErrorTest{ "complex 0/0", func() { use(c/d) }, "", }, ErrorTest{"complex 0/0", func() { use(c / d) }, ""},
ErrorTest{ "complex64 0/0", func() { use(c64/d64) }, "", }, ErrorTest{"complex64 0/0", func() { use(c64 / d64) }, ""},
ErrorTest{ "complex128 0/0", func() { use(c128/d128) }, "", }, ErrorTest{"complex128 0/0", func() { use(c128 / d128) }, ""},
ErrorTest{ "complex 1/0", func() { use(e/d) }, "", }, ErrorTest{"complex 1/0", func() { use(e / d) }, ""},
ErrorTest{ "complex64 1/0", func() { use(e64/d64) }, "", }, ErrorTest{"complex64 1/0", func() { use(e64 / d64) }, ""},
ErrorTest{ "complex128 1/0", func() { use(e128/d128) }, "", }, ErrorTest{"complex128 1/0", func() { use(e128 / d128) }, ""},
} }
func error(fn func()) (error string) { func error(fn func()) (error string) {
@ -138,12 +171,12 @@ func error(fn func()) (error string) {
return "" return ""
} }
type FloatTest struct{ type FloatTest struct {
f, g float64 f, g float64
out float64 out float64
} }
var floatTests = []FloatTest{ var float64Tests = []FloatTest{
FloatTest{0, 0, nan}, FloatTest{0, 0, nan},
FloatTest{nan, 0, nan}, FloatTest{nan, 0, nan},
FloatTest{inf, 0, inf}, FloatTest{inf, 0, inf},
@ -163,7 +196,7 @@ func alike(a, b float64) bool {
func main() { func main() {
bad := false bad := false
for _, t := range errorTests { for _, t := range errorTests {
if t.err != "" && syscall.OS == "nacl" { if t.err != "" {
continue continue
} }
err := error(t.fn) err := error(t.fn)
@ -195,8 +228,8 @@ func main() {
} }
// At this point we know we don't error on the values we're testing // At this point we know we don't error on the values we're testing
for _, t := range floatTests { for _, t := range float64Tests {
x := t.f/t.g x := t.f / t.g
if !alike(x, t.out) { if !alike(x, t.out) {
if !bad { if !bad {
bad = true bad = true

View File

@ -1,4 +1,4 @@
b547c5b04a18 559f12e8fcd5
The first line of this file holds the Mercurial revision number of the The first line of this file holds the Mercurial revision number of the
last merge done from the master library sources. last merge done from the master library sources.

View File

@ -177,6 +177,8 @@ toolexeclibgocrypto_DATA = \
crypto/block.gox \ crypto/block.gox \
crypto/blowfish.gox \ crypto/blowfish.gox \
crypto/cast5.gox \ crypto/cast5.gox \
crypto/cipher.gox \
crypto/elliptic.gox \
crypto/hmac.gox \ crypto/hmac.gox \
crypto/md4.gox \ crypto/md4.gox \
crypto/md5.gox \ crypto/md5.gox \
@ -190,9 +192,17 @@ toolexeclibgocrypto_DATA = \
crypto/sha512.gox \ crypto/sha512.gox \
crypto/subtle.gox \ crypto/subtle.gox \
crypto/tls.gox \ crypto/tls.gox \
crypto/twofish.gox \
crypto/x509.gox \ crypto/x509.gox \
crypto/xtea.gox crypto/xtea.gox
toolexeclibgocryptoopenpgpdir = $(toolexeclibgocryptodir)/openpgp
toolexeclibgocryptoopenpgp_DATA = \
crypto/openpgp/armor.gox \
crypto/openpgp/error.gox \
crypto/openpgp/s2k.gox
toolexeclibgodebugdir = $(toolexeclibgodir)/debug toolexeclibgodebugdir = $(toolexeclibgodir)/debug
toolexeclibgodebug_DATA = \ toolexeclibgodebug_DATA = \
@ -207,8 +217,10 @@ toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
toolexeclibgoencoding_DATA = \ toolexeclibgoencoding_DATA = \
encoding/ascii85.gox \ encoding/ascii85.gox \
encoding/base32.gox \
encoding/base64.gox \ encoding/base64.gox \
encoding/binary.gox \ encoding/binary.gox \
encoding/line.gox \
encoding/git85.gox \ encoding/git85.gox \
encoding/hex.gox \ encoding/hex.gox \
encoding/pem.gox encoding/pem.gox
@ -272,7 +284,15 @@ toolexeclibgonet_DATA = \
toolexeclibgoosdir = $(toolexeclibgodir)/os toolexeclibgoosdir = $(toolexeclibgodir)/os
if LIBGO_IS_LINUX
# os_inotify_gox = os/inotify.gox
os_inotify_gox =
else
os_inotify_gox =
endif
toolexeclibgoos_DATA = \ toolexeclibgoos_DATA = \
$(os_inotify_gox) \
os/signal.gox os/signal.gox
toolexeclibgorpcdir = $(toolexeclibgodir)/rpc toolexeclibgorpcdir = $(toolexeclibgodir)/rpc
@ -283,6 +303,7 @@ toolexeclibgorpc_DATA = \
toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
toolexeclibgoruntime_DATA = \ toolexeclibgoruntime_DATA = \
runtime/debug.gox \
runtime/pprof.gox runtime/pprof.gox
toolexeclibgotestingdir = $(toolexeclibgodir)/testing toolexeclibgotestingdir = $(toolexeclibgodir)/testing
@ -503,6 +524,7 @@ go_html_files = \
go/html/doc.go \ go/html/doc.go \
go/html/entity.go \ go/html/entity.go \
go/html/escape.go \ go/html/escape.go \
go/html/parse.go \
go/html/token.go go/html/token.go
go_http_files = \ go_http_files = \
@ -554,6 +576,7 @@ go_math_files = \
go/math/copysign.go \ go/math/copysign.go \
go/math/erf.go \ go/math/erf.go \
go/math/exp.go \ go/math/exp.go \
go/math/exp_port.go \
go/math/exp2.go \ go/math/exp2.go \
go/math/expm1.go \ go/math/expm1.go \
go/math/fabs.go \ go/math/fabs.go \
@ -658,7 +681,8 @@ go_patch_files = \
go_path_files = \ go_path_files = \
go/path/match.go \ go/path/match.go \
go/path/path.go go/path/path.go \
go/path/path_unix.go
go_rand_files = \ go_rand_files = \
go/rand/exp.go \ go/rand/exp.go \
@ -684,6 +708,8 @@ go_runtime_files = \
go/runtime/debug.go \ go/runtime/debug.go \
go/runtime/error.go \ go/runtime/error.go \
go/runtime/extern.go \ go/runtime/extern.go \
go/runtime/malloc_defs.go \
go/runtime/runtime_defs.go \
go/runtime/sig.go \ go/runtime/sig.go \
go/runtime/softfloat64.go \ go/runtime/softfloat64.go \
go/runtime/type.go \ go/runtime/type.go \
@ -708,6 +734,7 @@ go_smtp_files = \
go/smtp/smtp.go go/smtp/smtp.go
go_sort_files = \ go_sort_files = \
go/sort/search.go \
go/sort/sort.go go/sort/sort.go
go_strconv_files = \ go_strconv_files = \
@ -837,6 +864,16 @@ go_crypto_blowfish_files = \
go/crypto/blowfish/cipher.go go/crypto/blowfish/cipher.go
go_crypto_cast5_files = \ go_crypto_cast5_files = \
go/crypto/cast5/cast5.go go/crypto/cast5/cast5.go
go_crypto_cipher_files = \
go/crypto/cipher/cbc.go \
go/crypto/cipher/cfb.go \
go/crypto/cipher/cipher.go \
go/crypto/cipher/ctr.go \
go/crypto/cipher/io.go \
go/crypto/cipher/ocfb.go \
go/crypto/cipher/ofb.go
go_crypto_elliptic_files = \
go/crypto/elliptic/elliptic.go
go_crypto_hmac_files = \ go_crypto_hmac_files = \
go/crypto/hmac/hmac.go go/crypto/hmac/hmac.go
go_crypto_md4_files = \ go_crypto_md4_files = \
@ -872,19 +909,31 @@ go_crypto_subtle_files = \
go_crypto_tls_files = \ go_crypto_tls_files = \
go/crypto/tls/alert.go \ go/crypto/tls/alert.go \
go/crypto/tls/ca_set.go \ go/crypto/tls/ca_set.go \
go/crypto/tls/cipher_suites.go \
go/crypto/tls/common.go \ go/crypto/tls/common.go \
go/crypto/tls/conn.go \ go/crypto/tls/conn.go \
go/crypto/tls/handshake_client.go \ go/crypto/tls/handshake_client.go \
go/crypto/tls/handshake_messages.go \ go/crypto/tls/handshake_messages.go \
go/crypto/tls/handshake_server.go \ go/crypto/tls/handshake_server.go \
go/crypto/tls/key_agreement.go \
go/crypto/tls/prf.go \ go/crypto/tls/prf.go \
go/crypto/tls/tls.go go/crypto/tls/tls.go
go_crypto_twofish_files = \
go/crypto/twofish/twofish.go
go_crypto_x509_files = \ go_crypto_x509_files = \
go/crypto/x509/x509.go go/crypto/x509/x509.go
go_crypto_xtea_files = \ go_crypto_xtea_files = \
go/crypto/xtea/block.go \ go/crypto/xtea/block.go \
go/crypto/xtea/cipher.go go/crypto/xtea/cipher.go
go_crypto_openpgp_armor_files = \
go/crypto/openpgp/armor/armor.go \
go/crypto/openpgp/armor/encode.go
go_crypto_openpgp_error_files = \
go/crypto/openpgp/error/error.go
go_crypto_openpgp_s2k_files = \
go/crypto/openpgp/s2k/s2k.go
go_debug_dwarf_files = \ go_debug_dwarf_files = \
go/debug/dwarf/buf.go \ go/debug/dwarf/buf.go \
go/debug/dwarf/const.go \ go/debug/dwarf/const.go \
@ -912,6 +961,8 @@ go_debug_proc_files = \
go_encoding_ascii85_files = \ go_encoding_ascii85_files = \
go/encoding/ascii85/ascii85.go go/encoding/ascii85/ascii85.go
go_encoding_base32_files = \
go/encoding/base32/base32.go
go_encoding_base64_files = \ go_encoding_base64_files = \
go/encoding/base64/base64.go go/encoding/base64/base64.go
go_encoding_binary_files = \ go_encoding_binary_files = \
@ -920,6 +971,8 @@ go_encoding_git85_files = \
go/encoding/git85/git.go go/encoding/git85/git.go
go_encoding_hex_files = \ go_encoding_hex_files = \
go/encoding/hex/hex.go go/encoding/hex/hex.go
go_encoding_line_files = \
go/encoding/line/line.go
go_encoding_pem_files = \ go_encoding_pem_files = \
go/encoding/pem/pem.go go/encoding/pem/pem.go
@ -962,6 +1015,7 @@ go_go_scanner_files = \
go/go/scanner/errors.go \ go/go/scanner/errors.go \
go/go/scanner/scanner.go go/go/scanner/scanner.go
go_go_token_files = \ go_go_token_files = \
go/go/token/position.go \
go/go/token/token.go go/go/token/token.go
go_go_typechecker_files = \ go_go_typechecker_files = \
go/go/typechecker/scope.go \ go/go/typechecker/scope.go \
@ -988,6 +1042,7 @@ go_image_png_files = \
go/image/png/writer.go go/image/png/writer.go
go_index_suffixarray_files = \ go_index_suffixarray_files = \
go/index/suffixarray/qsufsort.go \
go/index/suffixarray/suffixarray.go go/index/suffixarray/suffixarray.go
go_io_ioutil_files = \ go_io_ioutil_files = \
@ -1006,6 +1061,9 @@ go_net_textproto_files = \
go/net/textproto/textproto.go \ go/net/textproto/textproto.go \
go/net/textproto/writer.go go/net/textproto/writer.go
go_os_inotify_files = \
go/os/inotify/inotify_linux.go
go_os_signal_files = \ go_os_signal_files = \
go/os/signal/signal.go \ go/os/signal/signal.go \
unix.go unix.go
@ -1014,6 +1072,8 @@ go_rpc_jsonrpc_files = \
go/rpc/jsonrpc/client.go \ go/rpc/jsonrpc/client.go \
go/rpc/jsonrpc/server.go go/rpc/jsonrpc/server.go
go_runtime_debug_files = \
go/runtime/debug/stack.go
go_runtime_pprof_files = \ go_runtime_pprof_files = \
go/runtime/pprof/pprof.go go/runtime/pprof/pprof.go
@ -1136,6 +1196,13 @@ go_syscall_files = \
go_syscall_c_files = \ go_syscall_c_files = \
syscalls/errno.c syscalls/errno.c
if LIBGO_IS_LINUX
# os_lib_inotify_la = os/libinotify.la
os_lib_inotify_la =
else
os_lib_inotify_la =
endif
libgo_go_objs = \ libgo_go_objs = \
asn1/libasn1.la \ asn1/libasn1.la \
big/libbig.la \ big/libbig.la \
@ -1196,6 +1263,8 @@ libgo_go_objs = \
crypto/libblock.la \ crypto/libblock.la \
crypto/libblowfish.la \ crypto/libblowfish.la \
crypto/libcast5.la \ crypto/libcast5.la \
crypto/libcipher.la \
crypto/libelliptic.la \
crypto/libhmac.la \ crypto/libhmac.la \
crypto/libmd4.la \ crypto/libmd4.la \
crypto/libmd5.la \ crypto/libmd5.la \
@ -1209,8 +1278,12 @@ libgo_go_objs = \
crypto/libsha512.la \ crypto/libsha512.la \
crypto/libsubtle.la \ crypto/libsubtle.la \
crypto/libtls.la \ crypto/libtls.la \
crypto/libtwofish.la \
crypto/libx509.la \ crypto/libx509.la \
crypto/libxtea.la \ crypto/libxtea.la \
crypto/openpgp/libarmor.la \
crypto/openpgp/liberror.la \
crypto/openpgp/libs2k.la \
debug/libdwarf.la \ debug/libdwarf.la \
debug/libelf.la \ debug/libelf.la \
debug/libgosym.la \ debug/libgosym.la \
@ -1218,10 +1291,12 @@ libgo_go_objs = \
debug/libpe.la \ debug/libpe.la \
debug/libproc.la \ debug/libproc.la \
encoding/libascii85.la \ encoding/libascii85.la \
encoding/libbase32.la \
encoding/libbase64.la \ encoding/libbase64.la \
encoding/libbinary.la \ encoding/libbinary.la \
encoding/libgit85.la \ encoding/libgit85.la \
encoding/libhex.la \ encoding/libhex.la \
encoding/libline.la \
encoding/libpem.la \ encoding/libpem.la \
exp/libdatafmt.la \ exp/libdatafmt.la \
exp/libdraw.la \ exp/libdraw.la \
@ -1244,8 +1319,10 @@ libgo_go_objs = \
mime/libmultipart.la \ mime/libmultipart.la \
net/libdict.la \ net/libdict.la \
net/libtextproto.la \ net/libtextproto.la \
$(os_lib_inotify_la) \
os/libsignal.la \ os/libsignal.la \
rpc/libjsonrpc.la \ rpc/libjsonrpc.la \
runtime/libdebug.la \
runtime/libpprof.la \ runtime/libpprof.la \
syscalls/libsyscall.la \ syscalls/libsyscall.la \
testing/libtesting.la \ testing/libtesting.la \
@ -1418,7 +1495,8 @@ fmt/check: $(CHECK_DEPS)
.PHONY: fmt/check .PHONY: fmt/check
gob/libgob.a: $(go_gob_files) bytes.gox fmt.gox io.gox math.gox os.gox \ gob/libgob.a: $(go_gob_files) bytes.gox fmt.gox io.gox math.gox os.gox \
reflect.gox runtime.gox strings.gox sync.gox unicode.gox reflect.gox runtime.gox strings.gox sync.gox unicode.gox \
utf8.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
gob/libgob.la: gob/libgob.a gob/libgob.la: gob/libgob.a
gob/check: $(CHECK_DEPS) gob/check: $(CHECK_DEPS)
@ -1475,7 +1553,7 @@ json/check: $(CHECK_DEPS)
.PHONY: json/check .PHONY: json/check
log/liblog.a: $(go_log_files) bytes.gox fmt.gox io.gox runtime.gox os.gox \ log/liblog.a: $(go_log_files) bytes.gox fmt.gox io.gox runtime.gox os.gox \
time.gox sync.gox time.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
log/liblog.la: log/liblog.a log/liblog.la: log/liblog.a
log/check: $(CHECK_DEPS) log/check: $(CHECK_DEPS)
@ -1497,8 +1575,8 @@ mime/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: mime/check .PHONY: mime/check
net/libnet.a: $(go_net_files) fmt.gox io.gox os.gox reflect.gox strconv.gox \ net/libnet.a: $(go_net_files) bytes.gox fmt.gox io.gox os.gox reflect.gox \
strings.gox sync.gox syscall.gox strconv.gox strings.gox sync.gox syscall.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
net/libnet.la: net/libnet.a net/libnet.la: net/libnet.a
net/check: $(CHECK_DEPS) net/check: $(CHECK_DEPS)
@ -1506,7 +1584,7 @@ net/check: $(CHECK_DEPS)
.PHONY: net/check .PHONY: net/check
netchan/libnetchan.a: $(go_netchan_files) gob.gox log.gox net.gox os.gox \ netchan/libnetchan.a: $(go_netchan_files) gob.gox log.gox net.gox os.gox \
reflect.gox sync.gox time.gox reflect.gox strconv.gox sync.gox time.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
netchan/libnetchan.la: netchan/libnetchan.a netchan/libnetchan.la: netchan/libnetchan.a
netchan/check: $(CHECK_DEPS) netchan/check: $(CHECK_DEPS)
@ -1657,8 +1735,8 @@ testing/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: testing/check .PHONY: testing/check
time/libtime.a: $(go_time_files) bytes.gox io/ioutil.gox os.gox strconv.gox \ time/libtime.a: $(go_time_files) bytes.gox container/heap.gox io/ioutil.gox \
sync.gox syscall.gox os.gox strconv.gox sync.gox syscall.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
time/libtime.la: time/libtime.a time/libtime.la: time/libtime.a
time/check: $(CHECK_DEPS) time/check: $(CHECK_DEPS)
@ -1703,8 +1781,8 @@ websocket/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: websocket/check .PHONY: websocket/check
xml/libxml.a: $(go_xml_files) bufio.gox bytes.gox io.gox os.gox reflect.gox \ xml/libxml.a: $(go_xml_files) bufio.gox bytes.gox fmt.gox io.gox os.gox \
strconv.gox strings.gox unicode.gox utf8.gox reflect.gox strconv.gox strings.gox unicode.gox utf8.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
xml/libxml.la: xml/libxml.a xml/libxml.la: xml/libxml.a
xml/check: $(CHECK_DEPS) xml/check: $(CHECK_DEPS)
@ -1821,8 +1899,25 @@ crypt/cast5/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/cast5/check .PHONY: crypto/cast5/check
crypto/libcipher.a: $(go_crypto_cipher_files) io.gox os.gox
$(BUILDARCHIVE)
crypto/libcipher.la: crypto/libcipher.a
crypto/cipher/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/cipher
$(CHECK)
.PHONY: crypto/cipher/check
crypto/libelliptic.a: $(go_crypto_elliptic_files) big.gox io.gox os.gox \
sync.gox
$(BUILDARCHIVE)
crypto/libelliptic.la: crypto/libelliptic.a
crypto/elliptic/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/elliptic
$(CHECK)
.PHONY: crypto/elliptic/check
crypto/libhmac.a: $(go_crypto_hmac_files) crypto/md5.gox crypto/sha1.gox \ crypto/libhmac.a: $(go_crypto_hmac_files) crypto/md5.gox crypto/sha1.gox \
hash.gox os.gox crypto/sha256.gox hash.gox os.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
crypto/libhmac.la: crypto/libhmac.a crypto/libhmac.la: crypto/libhmac.a
crypto/hmac/check: $(CHECK_DEPS) crypto/hmac/check: $(CHECK_DEPS)
@ -1921,12 +2016,13 @@ crypto/subtle/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/subtle/check .PHONY: crypto/subtle/check
crypto/libtls.a: $(go_crypto_tls_files) bufio.gox bytes.gox container/list.gox \ crypto/libtls.a: $(go_crypto_tls_files) big.gox bufio.gox bytes.gox \
crypto/hmac.gox crypto/md5.gox crypto/rc4.gox crypto/rand.gox \ container/list.gox crypto/aes.gox crypto/cipher.gox \
crypto/rsa.gox crypto/sha1.gox crypto/subtle.gox \ crypto/elliptic.gox crypto/hmac.gox crypto/md5.gox \
crypto/rsa.gox crypto/x509.gox encoding/pem.gox fmt.gox \ crypto/rc4.gox crypto/rand.gox crypto/rsa.gox crypto/sha1.gox \
hash.gox io.gox io/ioutil.gox net.gox os.gox strings.gox \ crypto/subtle.gox crypto/rsa.gox crypto/sha1.gox \
sync.gox time.gox crypto/x509.gox encoding/pem.gox fmt.gox hash.gox io.gox \
io/ioutil.gox net.gox os.gox strings.gox sync.gox time.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
crypto/libtls.la: crypto/libtls.a crypto/libtls.la: crypto/libtls.a
crypto/tls/check: $(CHECK_DEPS) crypto/tls/check: $(CHECK_DEPS)
@ -1934,6 +2030,14 @@ crypto/tls/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/tls/check .PHONY: crypto/tls/check
crypto/libtwofish.a: $(go_crypto_twofish_files) os.gox strconv.gox
$(BUILDARCHIVE)
crypto/libtwofish.la: crypto/libtwofish.a
crypto/twofish/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/twofish
$(CHECK)
.PHONY: crypto/twofish/check
crypto/libx509.a: $(go_crypto_x509_files) asn1.gox big.gox \ crypto/libx509.a: $(go_crypto_x509_files) asn1.gox big.gox \
container/vector.gox crypto/rsa.gox crypto/sha1.gox hash.gox \ container/vector.gox crypto/rsa.gox crypto/sha1.gox hash.gox \
os.gox strings.gox time.gox os.gox strings.gox time.gox
@ -1952,6 +2056,34 @@ crypto/xtea/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/xtea/check .PHONY: crypto/xtea/check
crypto/openpgp/libarmor.a: $(go_crypto_openpgp_armor_files) bytes.gox \
crypto/openpgp/error.gox encoding/base64.gox \
encoding/line.gox io.gox os.gox
$(BUILDARCHIVE)
crypto/openpgp/libarmor.la: crypto/openpgp/libarmor.a
crypto/openpgp/armor/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/openpgp/armor
$(CHECK)
.PHONY: crypto/openpgp/armor/check
crypto/openpgp/liberror.a: $(go_crypto_openpgp_error_files)
$(BUILDARCHIVE)
crypto/openpgp/liberror.la: crypto/openpgp/liberror.a
crypto/openpgp/error/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/openpgp/error
$(CHECK)
.PHONY: crypto/openpgp/error/check
crypto/openpgp/libs2k.a: $(go_crypto_openpgp_s2k_files) crypto/md5.gox \
crypto/openpgp/error.gox crypto/ripemd160.gox crypto/sha1.gox \
crypto/sha256.gox crypto/sha512.gox hash.gox io.gox os.gox
$(BUILDARCHIVE)
crypto/openpgp/libs2k.la: crypto/openpgp/libs2k.a
crypto/openpgp/s2k/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/openpgp/s2k
$(CHECK)
.PHONY: crypto/openpgp/s2k/check
debug/libdwarf.a: $(go_debug_dwarf_files) encoding/binary.gox os.gox \ debug/libdwarf.a: $(go_debug_dwarf_files) encoding/binary.gox os.gox \
strconv.gox strconv.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
@ -2015,6 +2147,14 @@ encoding/ascii85/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: encoding/ascii85/check .PHONY: encoding/ascii85/check
encoding/libbase32.a: $(go_encoding_base32_files) io.gox os.gox strconv.gox
$(BUILDARCHIVE)
encoding/libbase32.la: encoding/libbase32.a
encoding/base32/check: $(CHECK_DEPS)
@$(MKDIR_P) encoding/base32
$(CHECK)
.PHONY: encoding/base32/check
encoding/libbase64.a: $(go_encoding_base64_files) io.gox os.gox strconv.gox encoding/libbase64.a: $(go_encoding_base64_files) io.gox os.gox strconv.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
encoding/libbase64.la: encoding/libbase64.a encoding/libbase64.la: encoding/libbase64.a
@ -2049,6 +2189,14 @@ encoding/hex/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: encoding/hex/check .PHONY: encoding/hex/check
encoding/libline.a: $(go_encoding_line_files) io.gox os.gox
$(BUILDARCHIVE)
encoding/libline.la: encoding/libline.a
encoding/line/check: $(CHECK_DEPS)
@$(MKDIR_P) encoding/line
$(CHECK)
.PHONY: encoding/line/check
encoding/libpem.a: $(go_encoding_pem_files) bytes.gox encoding/base64.gox encoding/libpem.a: $(go_encoding_pem_files) bytes.gox encoding/base64.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
encoding/libpem.la: encoding/libpem.a encoding/libpem.la: encoding/libpem.a
@ -2200,8 +2348,8 @@ image/png/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: image/png/check .PHONY: image/png/check
index/libsuffixarray.a: $(go_index_suffixarray_files) bytes.gox \ index/libsuffixarray.a: $(go_index_suffixarray_files) bytes.gox regexp.gox \
container/vector.gox sort.gox sort.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
index/libsuffixarray.la: index/libsuffixarray.a index/libsuffixarray.la: index/libsuffixarray.a
index/suffixarray/check: $(CHECK_DEPS) index/suffixarray/check: $(CHECK_DEPS)
@ -2242,6 +2390,15 @@ net/textproto/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: net/textproto/check .PHONY: net/textproto/check
os/libinotify.a: $(go_os_inotify_files) fmt.gox os.gox strings.gox \
syscall.gox
$(BUILDARCHIVE)
os/libinotify.la: os/libinotify.a
os/inotify/check: $(CHECK_DEPS)
@$(MKDIR_P) os/inotify
$(CHECK)
.PHONY: os/inotify/check
os/libsignal.a: $(go_os_signal_files) runtime.gox strconv.gox os/libsignal.a: $(go_os_signal_files) runtime.gox strconv.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
os/libsignal.la: os/libsignal.a os/libsignal.la: os/libsignal.a
@ -2263,6 +2420,15 @@ rpc/jsonrpc/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: rpc/jsonrpc/check .PHONY: rpc/jsonrpc/check
runtime/libdebug.a: $(go_runtime_debug_files) bytes.gox fmt.gox io/ioutil.gox \
os.gox runtime.gox
$(BUILDARCHIVE)
runtime/libdebug.la: runtime/libdebug.a
runtime/debug/check: $(CHECK_DEPS)
@$(MKDIR_P) runtime/debug
$(CHECK)
.PHONY: runtime/debug/check
runtime/libpprof.a: $(go_runtime_pprof_files) bufio.gox fmt.gox io.gox os.gox \ runtime/libpprof.a: $(go_runtime_pprof_files) bufio.gox fmt.gox io.gox os.gox \
runtime.gox runtime.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
@ -2445,6 +2611,10 @@ crypto/blowfish.gox: crypto/libblowfish.a
$(BUILDGOX) $(BUILDGOX)
crypto/cast5.gox: crypto/libcast5.a crypto/cast5.gox: crypto/libcast5.a
$(BUILDGOX) $(BUILDGOX)
crypto/cipher.gox: crypto/libcipher.a
$(BUILDGOX)
crypto/elliptic.gox: crypto/libelliptic.a
$(BUILDGOX)
crypto/hmac.gox: crypto/libhmac.a crypto/hmac.gox: crypto/libhmac.a
$(BUILDGOX) $(BUILDGOX)
crypto/md4.gox: crypto/libmd4.a crypto/md4.gox: crypto/libmd4.a
@ -2471,11 +2641,20 @@ crypto/subtle.gox: crypto/libsubtle.a
$(BUILDGOX) $(BUILDGOX)
crypto/tls.gox: crypto/libtls.a crypto/tls.gox: crypto/libtls.a
$(BUILDGOX) $(BUILDGOX)
crypto/twofish.gox: crypto/libtwofish.a
$(BUILDGOX)
crypto/x509.gox: crypto/libx509.a crypto/x509.gox: crypto/libx509.a
$(BUILDGOX) $(BUILDGOX)
crypto/xtea.gox: crypto/libxtea.a crypto/xtea.gox: crypto/libxtea.a
$(BUILDGOX) $(BUILDGOX)
crypto/openpgp/armor.gox: crypto/openpgp/libarmor.a
$(BUILDGOX)
crypto/openpgp/error.gox: crypto/openpgp/liberror.a
$(BUILDGOX)
crypto/openpgp/s2k.gox: crypto/openpgp/libs2k.a
$(BUILDGOX)
debug/dwarf.gox: debug/libdwarf.a debug/dwarf.gox: debug/libdwarf.a
$(BUILDGOX) $(BUILDGOX)
debug/elf.gox: debug/libelf.a debug/elf.gox: debug/libelf.a
@ -2491,6 +2670,8 @@ debug/proc.gox: debug/libproc.a
encoding/ascii85.gox: encoding/libascii85.a encoding/ascii85.gox: encoding/libascii85.a
$(BUILDGOX) $(BUILDGOX)
encoding/base32.gox: encoding/libbase32.a
$(BUILDGOX)
encoding/base64.gox: encoding/libbase64.a encoding/base64.gox: encoding/libbase64.a
$(BUILDGOX) $(BUILDGOX)
encoding/binary.gox: encoding/libbinary.a encoding/binary.gox: encoding/libbinary.a
@ -2499,6 +2680,8 @@ encoding/git85.gox: encoding/libgit85.a
$(BUILDGOX) $(BUILDGOX)
encoding/hex.gox: encoding/libhex.a encoding/hex.gox: encoding/libhex.a
$(BUILDGOX) $(BUILDGOX)
encoding/line.gox: encoding/libline.a
$(BUILDGOX)
encoding/pem.gox: encoding/libpem.a encoding/pem.gox: encoding/libpem.a
$(BUILDGOX) $(BUILDGOX)
@ -2553,12 +2736,16 @@ net/dict.gox: net/libdict.a
net/textproto.gox: net/libtextproto.a net/textproto.gox: net/libtextproto.a
$(BUILDGOX) $(BUILDGOX)
os/inotify.gox: os/libinotify.a
$(BUILDGOX)
os/signal.gox: os/libsignal.a os/signal.gox: os/libsignal.a
$(BUILDGOX) $(BUILDGOX)
rpc/jsonrpc.gox: rpc/libjsonrpc.a rpc/jsonrpc.gox: rpc/libjsonrpc.a
$(BUILDGOX) $(BUILDGOX)
runtime/debug.gox: runtime/libdebug.a
$(BUILDGOX)
runtime/pprof.gox: runtime/libpprof.a runtime/pprof.gox: runtime/libpprof.a
$(BUILDGOX) $(BUILDGOX)
@ -2569,6 +2756,13 @@ testing/quick.gox: testing/libquick.a
testing/script.gox: testing/libscript.a testing/script.gox: testing/libscript.a
$(BUILDGOX) $(BUILDGOX)
if LIBGO_IS_LINUX
# os_inotify_check = os/inotify/check
os_inotify_check =
else
os_inotify_check =
endif
TEST_PACKAGES = \ TEST_PACKAGES = \
asn1/check \ asn1/check \
big/check \ big/check \
@ -2627,6 +2821,8 @@ TEST_PACKAGES = \
crypto/block/check \ crypto/block/check \
crypto/blowfish/check \ crypto/blowfish/check \
crypto/cast5/check \ crypto/cast5/check \
crypto/cipher/check \
crypto/elliptic/check \
crypto/hmac/check \ crypto/hmac/check \
crypto/md4/check \ crypto/md4/check \
crypto/md5/check \ crypto/md5/check \
@ -2640,17 +2836,22 @@ TEST_PACKAGES = \
crypto/sha512/check \ crypto/sha512/check \
crypto/subtle/check \ crypto/subtle/check \
crypto/tls/check \ crypto/tls/check \
crypto/twofish/check \
crypto/x509/check \ crypto/x509/check \
crypto/xtea/check \ crypto/xtea/check \
crypto/openpgp/armor/check \
crypto/openpgp/s2k/check \
debug/dwarf/check \ debug/dwarf/check \
debug/elf/check \ debug/elf/check \
debug/macho/check \ debug/macho/check \
debug/pe/check \ debug/pe/check \
encoding/ascii85/check \ encoding/ascii85/check \
encoding/base32/check \
encoding/base64/check \ encoding/base64/check \
encoding/binary/check \ encoding/binary/check \
encoding/git85/check \ encoding/git85/check \
encoding/hex/check \ encoding/hex/check \
encoding/line/check \
encoding/pem/check \ encoding/pem/check \
exp/datafmt/check \ exp/datafmt/check \
exp/draw/check \ exp/draw/check \
@ -2658,6 +2859,7 @@ TEST_PACKAGES = \
go/parser/check \ go/parser/check \
go/printer/check \ go/printer/check \
go/scanner/check \ go/scanner/check \
go/token/check \
go/typechecker/check \ go/typechecker/check \
hash/adler32/check \ hash/adler32/check \
hash/crc32/check \ hash/crc32/check \
@ -2667,6 +2869,7 @@ TEST_PACKAGES = \
io/ioutil/check \ io/ioutil/check \
mime/multipart/check \ mime/multipart/check \
net/textproto/check \ net/textproto/check \
$(os_inotify_check) \
os/signal/check \ os/signal/check \
rpc/jsonrpc/check \ rpc/jsonrpc/check \
testing/quick/check \ testing/quick/check \

View File

@ -97,6 +97,7 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
"$(DESTDIR)$(toolexeclibgocompressdir)" \ "$(DESTDIR)$(toolexeclibgocompressdir)" \
"$(DESTDIR)$(toolexeclibgocontainerdir)" \ "$(DESTDIR)$(toolexeclibgocontainerdir)" \
"$(DESTDIR)$(toolexeclibgocryptodir)" \ "$(DESTDIR)$(toolexeclibgocryptodir)" \
"$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" \
"$(DESTDIR)$(toolexeclibgodebugdir)" \ "$(DESTDIR)$(toolexeclibgodebugdir)" \
"$(DESTDIR)$(toolexeclibgoencodingdir)" \ "$(DESTDIR)$(toolexeclibgoencodingdir)" \
"$(DESTDIR)$(toolexeclibgoexpdir)" \ "$(DESTDIR)$(toolexeclibgoexpdir)" \
@ -120,7 +121,49 @@ am_libgobegin_a_OBJECTS = go-main.$(OBJEXT)
libgobegin_a_OBJECTS = $(am_libgobegin_a_OBJECTS) libgobegin_a_OBJECTS = $(am_libgobegin_a_OBJECTS)
LTLIBRARIES = $(toolexeclib_LTLIBRARIES) LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
am__DEPENDENCIES_1 = am__DEPENDENCIES_1 =
libgo_la_DEPENDENCIES = $(libgo_go_objs) $(am__DEPENDENCIES_1) \ am__DEPENDENCIES_2 = asn1/libasn1.la big/libbig.la bufio/libbufio.la \
bytes/libbytes.la cmath/libcmath.la ebnf/libebnf.la \
exec/libexec.la expvar/libexpvar.la flag/libflag.la \
fmt/libfmt.la gob/libgob.la hash/libhash.la html/libhtml.la \
http/libhttp.la image/libimage.la io/libio.la json/libjson.la \
log/liblog.la math/libmath.la mime/libmime.la net/libnet.la \
netchan/libnetchan.la os/libos.la patch/libpatch.la \
path/libpath.la rand/librand.la reflect/libreflect.la \
regexp/libregexp.la rpc/librpc.la runtime/libruntime.la \
scanner/libscanner.la smtp/libsmtp.la sort/libsort.la \
strconv/libstrconv.la strings/libstrings.la sync/libsync.la \
syslog/libsyslog.la tabwriter/libtabwriter.la \
template/libtemplate.la time/libtime.la try/libtry.la \
unicode/libunicode.la utf16/libutf16.la utf8/libutf8.la \
websocket/libwebsocket.la xml/libxml.la archive/libtar.la \
archive/libzip.la compress/libflate.la compress/libgzip.la \
compress/libzlib.la container/libheap.la container/liblist.la \
container/libring.la container/libvector.la crypto/libaes.la \
crypto/libblock.la crypto/libblowfish.la crypto/libcast5.la \
crypto/libcipher.la crypto/libelliptic.la crypto/libhmac.la \
crypto/libmd4.la crypto/libmd5.la crypto/libocsp.la \
crypto/librand.la crypto/librc4.la crypto/libripemd160.la \
crypto/librsa.la crypto/libsha1.la crypto/libsha256.la \
crypto/libsha512.la crypto/libsubtle.la crypto/libtls.la \
crypto/libtwofish.la crypto/libx509.la crypto/libxtea.la \
crypto/openpgp/libarmor.la crypto/openpgp/liberror.la \
crypto/openpgp/libs2k.la debug/libdwarf.la debug/libelf.la \
debug/libgosym.la debug/libmacho.la debug/libpe.la \
debug/libproc.la encoding/libascii85.la encoding/libbase32.la \
encoding/libbase64.la encoding/libbinary.la \
encoding/libgit85.la encoding/libhex.la encoding/libline.la \
encoding/libpem.la exp/libdatafmt.la exp/libdraw.la \
exp/libeval.la go/libast.la go/libdoc.la go/libparser.la \
go/libprinter.la go/libscanner.la go/libtoken.la \
go/libtypechecker.la hash/libadler32.la hash/libcrc32.la \
hash/libcrc64.la http/libpprof.la image/libjpeg.la \
image/libpng.la index/libsuffixarray.la io/libioutil.la \
mime/libmultipart.la net/libdict.la net/libtextproto.la \
$(am__DEPENDENCIES_1) os/libsignal.la rpc/libjsonrpc.la \
runtime/libdebug.la runtime/libpprof.la syscalls/libsyscall.la \
testing/libtesting.la testing/libiotest.la testing/libquick.la \
testing/libscript.la
libgo_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
@ -231,14 +274,15 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
ps-recursive uninstall-recursive ps-recursive uninstall-recursive
DATA = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ DATA = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \
$(toolexeclibgocompress_DATA) $(toolexeclibgocontainer_DATA) \ $(toolexeclibgocompress_DATA) $(toolexeclibgocontainer_DATA) \
$(toolexeclibgocrypto_DATA) $(toolexeclibgodebug_DATA) \ $(toolexeclibgocrypto_DATA) $(toolexeclibgocryptoopenpgp_DATA) \
$(toolexeclibgoencoding_DATA) $(toolexeclibgoexp_DATA) \ $(toolexeclibgodebug_DATA) $(toolexeclibgoencoding_DATA) \
$(toolexeclibgogo_DATA) $(toolexeclibgohash_DATA) \ $(toolexeclibgoexp_DATA) $(toolexeclibgogo_DATA) \
$(toolexeclibgohttp_DATA) $(toolexeclibgoimage_DATA) \ $(toolexeclibgohash_DATA) $(toolexeclibgohttp_DATA) \
$(toolexeclibgoindex_DATA) $(toolexeclibgoio_DATA) \ $(toolexeclibgoimage_DATA) $(toolexeclibgoindex_DATA) \
$(toolexeclibgomime_DATA) $(toolexeclibgonet_DATA) \ $(toolexeclibgoio_DATA) $(toolexeclibgomime_DATA) \
$(toolexeclibgoos_DATA) $(toolexeclibgorpc_DATA) \ $(toolexeclibgonet_DATA) $(toolexeclibgoos_DATA) \
$(toolexeclibgoruntime_DATA) $(toolexeclibgotesting_DATA) $(toolexeclibgorpc_DATA) $(toolexeclibgoruntime_DATA) \
$(toolexeclibgotesting_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
@ -570,6 +614,8 @@ toolexeclibgocrypto_DATA = \
crypto/block.gox \ crypto/block.gox \
crypto/blowfish.gox \ crypto/blowfish.gox \
crypto/cast5.gox \ crypto/cast5.gox \
crypto/cipher.gox \
crypto/elliptic.gox \
crypto/hmac.gox \ crypto/hmac.gox \
crypto/md4.gox \ crypto/md4.gox \
crypto/md5.gox \ crypto/md5.gox \
@ -583,9 +629,16 @@ toolexeclibgocrypto_DATA = \
crypto/sha512.gox \ crypto/sha512.gox \
crypto/subtle.gox \ crypto/subtle.gox \
crypto/tls.gox \ crypto/tls.gox \
crypto/twofish.gox \
crypto/x509.gox \ crypto/x509.gox \
crypto/xtea.gox crypto/xtea.gox
toolexeclibgocryptoopenpgpdir = $(toolexeclibgocryptodir)/openpgp
toolexeclibgocryptoopenpgp_DATA = \
crypto/openpgp/armor.gox \
crypto/openpgp/error.gox \
crypto/openpgp/s2k.gox
toolexeclibgodebugdir = $(toolexeclibgodir)/debug toolexeclibgodebugdir = $(toolexeclibgodir)/debug
toolexeclibgodebug_DATA = \ toolexeclibgodebug_DATA = \
debug/dwarf.gox \ debug/dwarf.gox \
@ -598,8 +651,10 @@ toolexeclibgodebug_DATA = \
toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
toolexeclibgoencoding_DATA = \ toolexeclibgoencoding_DATA = \
encoding/ascii85.gox \ encoding/ascii85.gox \
encoding/base32.gox \
encoding/base64.gox \ encoding/base64.gox \
encoding/binary.gox \ encoding/binary.gox \
encoding/line.gox \
encoding/git85.gox \ encoding/git85.gox \
encoding/hex.gox \ encoding/hex.gox \
encoding/pem.gox encoding/pem.gox
@ -653,7 +708,12 @@ toolexeclibgonet_DATA = \
net/textproto.gox net/textproto.gox
toolexeclibgoosdir = $(toolexeclibgodir)/os toolexeclibgoosdir = $(toolexeclibgodir)/os
@LIBGO_IS_LINUX_FALSE@os_inotify_gox =
# os_inotify_gox = os/inotify.gox
@LIBGO_IS_LINUX_TRUE@os_inotify_gox =
toolexeclibgoos_DATA = \ toolexeclibgoos_DATA = \
$(os_inotify_gox) \
os/signal.gox os/signal.gox
toolexeclibgorpcdir = $(toolexeclibgodir)/rpc toolexeclibgorpcdir = $(toolexeclibgodir)/rpc
@ -662,6 +722,7 @@ toolexeclibgorpc_DATA = \
toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
toolexeclibgoruntime_DATA = \ toolexeclibgoruntime_DATA = \
runtime/debug.gox \
runtime/pprof.gox runtime/pprof.gox
toolexeclibgotestingdir = $(toolexeclibgodir)/testing toolexeclibgotestingdir = $(toolexeclibgodir)/testing
@ -848,6 +909,7 @@ go_html_files = \
go/html/doc.go \ go/html/doc.go \
go/html/entity.go \ go/html/entity.go \
go/html/escape.go \ go/html/escape.go \
go/html/parse.go \
go/html/token.go go/html/token.go
go_http_files = \ go_http_files = \
@ -899,6 +961,7 @@ go_math_files = \
go/math/copysign.go \ go/math/copysign.go \
go/math/erf.go \ go/math/erf.go \
go/math/exp.go \ go/math/exp.go \
go/math/exp_port.go \
go/math/exp2.go \ go/math/exp2.go \
go/math/expm1.go \ go/math/expm1.go \
go/math/fabs.go \ go/math/fabs.go \
@ -996,7 +1059,8 @@ go_patch_files = \
go_path_files = \ go_path_files = \
go/path/match.go \ go/path/match.go \
go/path/path.go go/path/path.go \
go/path/path_unix.go
go_rand_files = \ go_rand_files = \
go/rand/exp.go \ go/rand/exp.go \
@ -1022,6 +1086,8 @@ go_runtime_files = \
go/runtime/debug.go \ go/runtime/debug.go \
go/runtime/error.go \ go/runtime/error.go \
go/runtime/extern.go \ go/runtime/extern.go \
go/runtime/malloc_defs.go \
go/runtime/runtime_defs.go \
go/runtime/sig.go \ go/runtime/sig.go \
go/runtime/softfloat64.go \ go/runtime/softfloat64.go \
go/runtime/type.go \ go/runtime/type.go \
@ -1035,6 +1101,7 @@ go_smtp_files = \
go/smtp/smtp.go go/smtp/smtp.go
go_sort_files = \ go_sort_files = \
go/sort/search.go \
go/sort/sort.go go/sort/sort.go
go_strconv_files = \ go_strconv_files = \
@ -1169,6 +1236,18 @@ go_crypto_blowfish_files = \
go_crypto_cast5_files = \ go_crypto_cast5_files = \
go/crypto/cast5/cast5.go go/crypto/cast5/cast5.go
go_crypto_cipher_files = \
go/crypto/cipher/cbc.go \
go/crypto/cipher/cfb.go \
go/crypto/cipher/cipher.go \
go/crypto/cipher/ctr.go \
go/crypto/cipher/io.go \
go/crypto/cipher/ocfb.go \
go/crypto/cipher/ofb.go
go_crypto_elliptic_files = \
go/crypto/elliptic/elliptic.go
go_crypto_hmac_files = \ go_crypto_hmac_files = \
go/crypto/hmac/hmac.go go/crypto/hmac/hmac.go
@ -1216,14 +1295,19 @@ go_crypto_subtle_files = \
go_crypto_tls_files = \ go_crypto_tls_files = \
go/crypto/tls/alert.go \ go/crypto/tls/alert.go \
go/crypto/tls/ca_set.go \ go/crypto/tls/ca_set.go \
go/crypto/tls/cipher_suites.go \
go/crypto/tls/common.go \ go/crypto/tls/common.go \
go/crypto/tls/conn.go \ go/crypto/tls/conn.go \
go/crypto/tls/handshake_client.go \ go/crypto/tls/handshake_client.go \
go/crypto/tls/handshake_messages.go \ go/crypto/tls/handshake_messages.go \
go/crypto/tls/handshake_server.go \ go/crypto/tls/handshake_server.go \
go/crypto/tls/key_agreement.go \
go/crypto/tls/prf.go \ go/crypto/tls/prf.go \
go/crypto/tls/tls.go go/crypto/tls/tls.go
go_crypto_twofish_files = \
go/crypto/twofish/twofish.go
go_crypto_x509_files = \ go_crypto_x509_files = \
go/crypto/x509/x509.go go/crypto/x509/x509.go
@ -1231,6 +1315,16 @@ go_crypto_xtea_files = \
go/crypto/xtea/block.go \ go/crypto/xtea/block.go \
go/crypto/xtea/cipher.go go/crypto/xtea/cipher.go
go_crypto_openpgp_armor_files = \
go/crypto/openpgp/armor/armor.go \
go/crypto/openpgp/armor/encode.go
go_crypto_openpgp_error_files = \
go/crypto/openpgp/error/error.go
go_crypto_openpgp_s2k_files = \
go/crypto/openpgp/s2k/s2k.go
go_debug_dwarf_files = \ go_debug_dwarf_files = \
go/debug/dwarf/buf.go \ go/debug/dwarf/buf.go \
go/debug/dwarf/const.go \ go/debug/dwarf/const.go \
@ -1263,6 +1357,9 @@ go_debug_proc_files = \
go_encoding_ascii85_files = \ go_encoding_ascii85_files = \
go/encoding/ascii85/ascii85.go go/encoding/ascii85/ascii85.go
go_encoding_base32_files = \
go/encoding/base32/base32.go
go_encoding_base64_files = \ go_encoding_base64_files = \
go/encoding/base64/base64.go go/encoding/base64/base64.go
@ -1275,6 +1372,9 @@ go_encoding_git85_files = \
go_encoding_hex_files = \ go_encoding_hex_files = \
go/encoding/hex/hex.go go/encoding/hex/hex.go
go_encoding_line_files = \
go/encoding/line/line.go
go_encoding_pem_files = \ go_encoding_pem_files = \
go/encoding/pem/pem.go go/encoding/pem/pem.go
@ -1324,6 +1424,7 @@ go_go_scanner_files = \
go/go/scanner/scanner.go go/go/scanner/scanner.go
go_go_token_files = \ go_go_token_files = \
go/go/token/position.go \
go/go/token/token.go go/go/token/token.go
go_go_typechecker_files = \ go_go_typechecker_files = \
@ -1353,6 +1454,7 @@ go_image_png_files = \
go/image/png/writer.go go/image/png/writer.go
go_index_suffixarray_files = \ go_index_suffixarray_files = \
go/index/suffixarray/qsufsort.go \
go/index/suffixarray/suffixarray.go go/index/suffixarray/suffixarray.go
go_io_ioutil_files = \ go_io_ioutil_files = \
@ -1371,6 +1473,9 @@ go_net_textproto_files = \
go/net/textproto/textproto.go \ go/net/textproto/textproto.go \
go/net/textproto/writer.go go/net/textproto/writer.go
go_os_inotify_files = \
go/os/inotify/inotify_linux.go
go_os_signal_files = \ go_os_signal_files = \
go/os/signal/signal.go \ go/os/signal/signal.go \
unix.go unix.go
@ -1379,6 +1484,9 @@ go_rpc_jsonrpc_files = \
go/rpc/jsonrpc/client.go \ go/rpc/jsonrpc/client.go \
go/rpc/jsonrpc/server.go go/rpc/jsonrpc/server.go
go_runtime_debug_files = \
go/runtime/debug/stack.go
go_runtime_pprof_files = \ go_runtime_pprof_files = \
go/runtime/pprof/pprof.go go/runtime/pprof/pprof.go
@ -1458,6 +1566,10 @@ go_syscall_files = \
go_syscall_c_files = \ go_syscall_c_files = \
syscalls/errno.c syscalls/errno.c
@LIBGO_IS_LINUX_FALSE@os_lib_inotify_la =
# os_lib_inotify_la = os/libinotify.la
@LIBGO_IS_LINUX_TRUE@os_lib_inotify_la =
libgo_go_objs = \ libgo_go_objs = \
asn1/libasn1.la \ asn1/libasn1.la \
big/libbig.la \ big/libbig.la \
@ -1518,6 +1630,8 @@ libgo_go_objs = \
crypto/libblock.la \ crypto/libblock.la \
crypto/libblowfish.la \ crypto/libblowfish.la \
crypto/libcast5.la \ crypto/libcast5.la \
crypto/libcipher.la \
crypto/libelliptic.la \
crypto/libhmac.la \ crypto/libhmac.la \
crypto/libmd4.la \ crypto/libmd4.la \
crypto/libmd5.la \ crypto/libmd5.la \
@ -1531,8 +1645,12 @@ libgo_go_objs = \
crypto/libsha512.la \ crypto/libsha512.la \
crypto/libsubtle.la \ crypto/libsubtle.la \
crypto/libtls.la \ crypto/libtls.la \
crypto/libtwofish.la \
crypto/libx509.la \ crypto/libx509.la \
crypto/libxtea.la \ crypto/libxtea.la \
crypto/openpgp/libarmor.la \
crypto/openpgp/liberror.la \
crypto/openpgp/libs2k.la \
debug/libdwarf.la \ debug/libdwarf.la \
debug/libelf.la \ debug/libelf.la \
debug/libgosym.la \ debug/libgosym.la \
@ -1540,10 +1658,12 @@ libgo_go_objs = \
debug/libpe.la \ debug/libpe.la \
debug/libproc.la \ debug/libproc.la \
encoding/libascii85.la \ encoding/libascii85.la \
encoding/libbase32.la \
encoding/libbase64.la \ encoding/libbase64.la \
encoding/libbinary.la \ encoding/libbinary.la \
encoding/libgit85.la \ encoding/libgit85.la \
encoding/libhex.la \ encoding/libhex.la \
encoding/libline.la \
encoding/libpem.la \ encoding/libpem.la \
exp/libdatafmt.la \ exp/libdatafmt.la \
exp/libdraw.la \ exp/libdraw.la \
@ -1566,8 +1686,10 @@ libgo_go_objs = \
mime/libmultipart.la \ mime/libmultipart.la \
net/libdict.la \ net/libdict.la \
net/libtextproto.la \ net/libtextproto.la \
$(os_lib_inotify_la) \
os/libsignal.la \ os/libsignal.la \
rpc/libjsonrpc.la \ rpc/libjsonrpc.la \
runtime/libdebug.la \
runtime/libpprof.la \ runtime/libpprof.la \
syscalls/libsyscall.la \ syscalls/libsyscall.la \
testing/libtesting.la \ testing/libtesting.la \
@ -1659,6 +1781,10 @@ BUILDGOX = \
mv -f $@.tmp $@; \ mv -f $@.tmp $@; \
rm -f $@.$(OBJEXT) rm -f $@.$(OBJEXT)
@LIBGO_IS_LINUX_FALSE@os_inotify_check =
# os_inotify_check = os/inotify/check
@LIBGO_IS_LINUX_TRUE@os_inotify_check =
TEST_PACKAGES = \ TEST_PACKAGES = \
asn1/check \ asn1/check \
big/check \ big/check \
@ -1717,6 +1843,8 @@ TEST_PACKAGES = \
crypto/block/check \ crypto/block/check \
crypto/blowfish/check \ crypto/blowfish/check \
crypto/cast5/check \ crypto/cast5/check \
crypto/cipher/check \
crypto/elliptic/check \
crypto/hmac/check \ crypto/hmac/check \
crypto/md4/check \ crypto/md4/check \
crypto/md5/check \ crypto/md5/check \
@ -1730,17 +1858,22 @@ TEST_PACKAGES = \
crypto/sha512/check \ crypto/sha512/check \
crypto/subtle/check \ crypto/subtle/check \
crypto/tls/check \ crypto/tls/check \
crypto/twofish/check \
crypto/x509/check \ crypto/x509/check \
crypto/xtea/check \ crypto/xtea/check \
crypto/openpgp/armor/check \
crypto/openpgp/s2k/check \
debug/dwarf/check \ debug/dwarf/check \
debug/elf/check \ debug/elf/check \
debug/macho/check \ debug/macho/check \
debug/pe/check \ debug/pe/check \
encoding/ascii85/check \ encoding/ascii85/check \
encoding/base32/check \
encoding/base64/check \ encoding/base64/check \
encoding/binary/check \ encoding/binary/check \
encoding/git85/check \ encoding/git85/check \
encoding/hex/check \ encoding/hex/check \
encoding/line/check \
encoding/pem/check \ encoding/pem/check \
exp/datafmt/check \ exp/datafmt/check \
exp/draw/check \ exp/draw/check \
@ -1748,6 +1881,7 @@ TEST_PACKAGES = \
go/parser/check \ go/parser/check \
go/printer/check \ go/printer/check \
go/scanner/check \ go/scanner/check \
go/token/check \
go/typechecker/check \ go/typechecker/check \
hash/adler32/check \ hash/adler32/check \
hash/crc32/check \ hash/crc32/check \
@ -1757,6 +1891,7 @@ TEST_PACKAGES = \
io/ioutil/check \ io/ioutil/check \
mime/multipart/check \ mime/multipart/check \
net/textproto/check \ net/textproto/check \
$(os_inotify_check) \
os/signal/check \ os/signal/check \
rpc/jsonrpc/check \ rpc/jsonrpc/check \
testing/quick/check \ testing/quick/check \
@ -2793,6 +2928,26 @@ uninstall-toolexeclibgocryptoDATA:
test -n "$$files" || exit 0; \ test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(toolexeclibgocryptodir)' && rm -f" $$files ")"; \ echo " ( cd '$(DESTDIR)$(toolexeclibgocryptodir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(toolexeclibgocryptodir)" && rm -f $$files cd "$(DESTDIR)$(toolexeclibgocryptodir)" && rm -f $$files
install-toolexeclibgocryptoopenpgpDATA: $(toolexeclibgocryptoopenpgp_DATA)
@$(NORMAL_INSTALL)
test -z "$(toolexeclibgocryptoopenpgpdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)"
@list='$(toolexeclibgocryptoopenpgp_DATA)'; test -n "$(toolexeclibgocryptoopenpgpdir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" || exit $$?; \
done
uninstall-toolexeclibgocryptoopenpgpDATA:
@$(NORMAL_UNINSTALL)
@list='$(toolexeclibgocryptoopenpgp_DATA)'; test -n "$(toolexeclibgocryptoopenpgpdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" && rm -f $$files
install-toolexeclibgodebugDATA: $(toolexeclibgodebug_DATA) install-toolexeclibgodebugDATA: $(toolexeclibgodebug_DATA)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
test -z "$(toolexeclibgodebugdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgodebugdir)" test -z "$(toolexeclibgodebugdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgodebugdir)"
@ -3410,7 +3565,7 @@ all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) all-multi $(DATA) \
config.h config.h
installdirs: installdirs-recursive installdirs: installdirs-recursive
installdirs-am: installdirs-am:
for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohttpdir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgorpcdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgotestingdir)"; do \ for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohttpdir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgorpcdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgotestingdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done done
install: install-recursive install: install-recursive
@ -3475,7 +3630,9 @@ install-exec-am: install-multi install-toolexeclibLIBRARIES \
install-toolexeclibgoarchiveDATA \ install-toolexeclibgoarchiveDATA \
install-toolexeclibgocompressDATA \ install-toolexeclibgocompressDATA \
install-toolexeclibgocontainerDATA \ install-toolexeclibgocontainerDATA \
install-toolexeclibgocryptoDATA install-toolexeclibgodebugDATA \ install-toolexeclibgocryptoDATA \
install-toolexeclibgocryptoopenpgpDATA \
install-toolexeclibgodebugDATA \
install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \ install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \
install-toolexeclibgogoDATA install-toolexeclibgohashDATA \ install-toolexeclibgogoDATA install-toolexeclibgohashDATA \
install-toolexeclibgohttpDATA install-toolexeclibgoimageDATA \ install-toolexeclibgohttpDATA install-toolexeclibgoimageDATA \
@ -3531,6 +3688,7 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
uninstall-toolexeclibgocompressDATA \ uninstall-toolexeclibgocompressDATA \
uninstall-toolexeclibgocontainerDATA \ uninstall-toolexeclibgocontainerDATA \
uninstall-toolexeclibgocryptoDATA \ uninstall-toolexeclibgocryptoDATA \
uninstall-toolexeclibgocryptoopenpgpDATA \
uninstall-toolexeclibgodebugDATA \ uninstall-toolexeclibgodebugDATA \
uninstall-toolexeclibgoencodingDATA \ uninstall-toolexeclibgoencodingDATA \
uninstall-toolexeclibgoexpDATA uninstall-toolexeclibgogoDATA \ uninstall-toolexeclibgoexpDATA uninstall-toolexeclibgogoDATA \
@ -3566,7 +3724,9 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
install-toolexeclibgoDATA install-toolexeclibgoarchiveDATA \ install-toolexeclibgoDATA install-toolexeclibgoarchiveDATA \
install-toolexeclibgocompressDATA \ install-toolexeclibgocompressDATA \
install-toolexeclibgocontainerDATA \ install-toolexeclibgocontainerDATA \
install-toolexeclibgocryptoDATA install-toolexeclibgodebugDATA \ install-toolexeclibgocryptoDATA \
install-toolexeclibgocryptoopenpgpDATA \
install-toolexeclibgodebugDATA \
install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \ install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \
install-toolexeclibgogoDATA install-toolexeclibgohashDATA \ install-toolexeclibgogoDATA install-toolexeclibgohashDATA \
install-toolexeclibgohttpDATA install-toolexeclibgoimageDATA \ install-toolexeclibgohttpDATA install-toolexeclibgoimageDATA \
@ -3586,6 +3746,7 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
uninstall-toolexeclibgocompressDATA \ uninstall-toolexeclibgocompressDATA \
uninstall-toolexeclibgocontainerDATA \ uninstall-toolexeclibgocontainerDATA \
uninstall-toolexeclibgocryptoDATA \ uninstall-toolexeclibgocryptoDATA \
uninstall-toolexeclibgocryptoopenpgpDATA \
uninstall-toolexeclibgodebugDATA \ uninstall-toolexeclibgodebugDATA \
uninstall-toolexeclibgoencodingDATA \ uninstall-toolexeclibgoencodingDATA \
uninstall-toolexeclibgoexpDATA uninstall-toolexeclibgogoDATA \ uninstall-toolexeclibgoexpDATA uninstall-toolexeclibgogoDATA \
@ -3731,7 +3892,8 @@ fmt/check: $(CHECK_DEPS)
.PHONY: fmt/check .PHONY: fmt/check
gob/libgob.a: $(go_gob_files) bytes.gox fmt.gox io.gox math.gox os.gox \ gob/libgob.a: $(go_gob_files) bytes.gox fmt.gox io.gox math.gox os.gox \
reflect.gox runtime.gox strings.gox sync.gox unicode.gox reflect.gox runtime.gox strings.gox sync.gox unicode.gox \
utf8.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
gob/libgob.la: gob/libgob.a gob/libgob.la: gob/libgob.a
gob/check: $(CHECK_DEPS) gob/check: $(CHECK_DEPS)
@ -3788,7 +3950,7 @@ json/check: $(CHECK_DEPS)
.PHONY: json/check .PHONY: json/check
log/liblog.a: $(go_log_files) bytes.gox fmt.gox io.gox runtime.gox os.gox \ log/liblog.a: $(go_log_files) bytes.gox fmt.gox io.gox runtime.gox os.gox \
time.gox sync.gox time.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
log/liblog.la: log/liblog.a log/liblog.la: log/liblog.a
log/check: $(CHECK_DEPS) log/check: $(CHECK_DEPS)
@ -3810,8 +3972,8 @@ mime/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: mime/check .PHONY: mime/check
net/libnet.a: $(go_net_files) fmt.gox io.gox os.gox reflect.gox strconv.gox \ net/libnet.a: $(go_net_files) bytes.gox fmt.gox io.gox os.gox reflect.gox \
strings.gox sync.gox syscall.gox strconv.gox strings.gox sync.gox syscall.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
net/libnet.la: net/libnet.a net/libnet.la: net/libnet.a
net/check: $(CHECK_DEPS) net/check: $(CHECK_DEPS)
@ -3819,7 +3981,7 @@ net/check: $(CHECK_DEPS)
.PHONY: net/check .PHONY: net/check
netchan/libnetchan.a: $(go_netchan_files) gob.gox log.gox net.gox os.gox \ netchan/libnetchan.a: $(go_netchan_files) gob.gox log.gox net.gox os.gox \
reflect.gox sync.gox time.gox reflect.gox strconv.gox sync.gox time.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
netchan/libnetchan.la: netchan/libnetchan.a netchan/libnetchan.la: netchan/libnetchan.a
netchan/check: $(CHECK_DEPS) netchan/check: $(CHECK_DEPS)
@ -3970,8 +4132,8 @@ testing/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: testing/check .PHONY: testing/check
time/libtime.a: $(go_time_files) bytes.gox io/ioutil.gox os.gox strconv.gox \ time/libtime.a: $(go_time_files) bytes.gox container/heap.gox io/ioutil.gox \
sync.gox syscall.gox os.gox strconv.gox sync.gox syscall.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
time/libtime.la: time/libtime.a time/libtime.la: time/libtime.a
time/check: $(CHECK_DEPS) time/check: $(CHECK_DEPS)
@ -4016,8 +4178,8 @@ websocket/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: websocket/check .PHONY: websocket/check
xml/libxml.a: $(go_xml_files) bufio.gox bytes.gox io.gox os.gox reflect.gox \ xml/libxml.a: $(go_xml_files) bufio.gox bytes.gox fmt.gox io.gox os.gox \
strconv.gox strings.gox unicode.gox utf8.gox reflect.gox strconv.gox strings.gox unicode.gox utf8.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
xml/libxml.la: xml/libxml.a xml/libxml.la: xml/libxml.a
xml/check: $(CHECK_DEPS) xml/check: $(CHECK_DEPS)
@ -4134,8 +4296,25 @@ crypt/cast5/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/cast5/check .PHONY: crypto/cast5/check
crypto/libcipher.a: $(go_crypto_cipher_files) io.gox os.gox
$(BUILDARCHIVE)
crypto/libcipher.la: crypto/libcipher.a
crypto/cipher/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/cipher
$(CHECK)
.PHONY: crypto/cipher/check
crypto/libelliptic.a: $(go_crypto_elliptic_files) big.gox io.gox os.gox \
sync.gox
$(BUILDARCHIVE)
crypto/libelliptic.la: crypto/libelliptic.a
crypto/elliptic/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/elliptic
$(CHECK)
.PHONY: crypto/elliptic/check
crypto/libhmac.a: $(go_crypto_hmac_files) crypto/md5.gox crypto/sha1.gox \ crypto/libhmac.a: $(go_crypto_hmac_files) crypto/md5.gox crypto/sha1.gox \
hash.gox os.gox crypto/sha256.gox hash.gox os.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
crypto/libhmac.la: crypto/libhmac.a crypto/libhmac.la: crypto/libhmac.a
crypto/hmac/check: $(CHECK_DEPS) crypto/hmac/check: $(CHECK_DEPS)
@ -4234,12 +4413,13 @@ crypto/subtle/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/subtle/check .PHONY: crypto/subtle/check
crypto/libtls.a: $(go_crypto_tls_files) bufio.gox bytes.gox container/list.gox \ crypto/libtls.a: $(go_crypto_tls_files) big.gox bufio.gox bytes.gox \
crypto/hmac.gox crypto/md5.gox crypto/rc4.gox crypto/rand.gox \ container/list.gox crypto/aes.gox crypto/cipher.gox \
crypto/rsa.gox crypto/sha1.gox crypto/subtle.gox \ crypto/elliptic.gox crypto/hmac.gox crypto/md5.gox \
crypto/rsa.gox crypto/x509.gox encoding/pem.gox fmt.gox \ crypto/rc4.gox crypto/rand.gox crypto/rsa.gox crypto/sha1.gox \
hash.gox io.gox io/ioutil.gox net.gox os.gox strings.gox \ crypto/subtle.gox crypto/rsa.gox crypto/sha1.gox \
sync.gox time.gox crypto/x509.gox encoding/pem.gox fmt.gox hash.gox io.gox \
io/ioutil.gox net.gox os.gox strings.gox sync.gox time.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
crypto/libtls.la: crypto/libtls.a crypto/libtls.la: crypto/libtls.a
crypto/tls/check: $(CHECK_DEPS) crypto/tls/check: $(CHECK_DEPS)
@ -4247,6 +4427,14 @@ crypto/tls/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/tls/check .PHONY: crypto/tls/check
crypto/libtwofish.a: $(go_crypto_twofish_files) os.gox strconv.gox
$(BUILDARCHIVE)
crypto/libtwofish.la: crypto/libtwofish.a
crypto/twofish/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/twofish
$(CHECK)
.PHONY: crypto/twofish/check
crypto/libx509.a: $(go_crypto_x509_files) asn1.gox big.gox \ crypto/libx509.a: $(go_crypto_x509_files) asn1.gox big.gox \
container/vector.gox crypto/rsa.gox crypto/sha1.gox hash.gox \ container/vector.gox crypto/rsa.gox crypto/sha1.gox hash.gox \
os.gox strings.gox time.gox os.gox strings.gox time.gox
@ -4265,6 +4453,34 @@ crypto/xtea/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: crypto/xtea/check .PHONY: crypto/xtea/check
crypto/openpgp/libarmor.a: $(go_crypto_openpgp_armor_files) bytes.gox \
crypto/openpgp/error.gox encoding/base64.gox \
encoding/line.gox io.gox os.gox
$(BUILDARCHIVE)
crypto/openpgp/libarmor.la: crypto/openpgp/libarmor.a
crypto/openpgp/armor/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/openpgp/armor
$(CHECK)
.PHONY: crypto/openpgp/armor/check
crypto/openpgp/liberror.a: $(go_crypto_openpgp_error_files)
$(BUILDARCHIVE)
crypto/openpgp/liberror.la: crypto/openpgp/liberror.a
crypto/openpgp/error/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/openpgp/error
$(CHECK)
.PHONY: crypto/openpgp/error/check
crypto/openpgp/libs2k.a: $(go_crypto_openpgp_s2k_files) crypto/md5.gox \
crypto/openpgp/error.gox crypto/ripemd160.gox crypto/sha1.gox \
crypto/sha256.gox crypto/sha512.gox hash.gox io.gox os.gox
$(BUILDARCHIVE)
crypto/openpgp/libs2k.la: crypto/openpgp/libs2k.a
crypto/openpgp/s2k/check: $(CHECK_DEPS)
@$(MKDIR_P) crypto/openpgp/s2k
$(CHECK)
.PHONY: crypto/openpgp/s2k/check
debug/libdwarf.a: $(go_debug_dwarf_files) encoding/binary.gox os.gox \ debug/libdwarf.a: $(go_debug_dwarf_files) encoding/binary.gox os.gox \
strconv.gox strconv.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
@ -4328,6 +4544,14 @@ encoding/ascii85/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: encoding/ascii85/check .PHONY: encoding/ascii85/check
encoding/libbase32.a: $(go_encoding_base32_files) io.gox os.gox strconv.gox
$(BUILDARCHIVE)
encoding/libbase32.la: encoding/libbase32.a
encoding/base32/check: $(CHECK_DEPS)
@$(MKDIR_P) encoding/base32
$(CHECK)
.PHONY: encoding/base32/check
encoding/libbase64.a: $(go_encoding_base64_files) io.gox os.gox strconv.gox encoding/libbase64.a: $(go_encoding_base64_files) io.gox os.gox strconv.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
encoding/libbase64.la: encoding/libbase64.a encoding/libbase64.la: encoding/libbase64.a
@ -4362,6 +4586,14 @@ encoding/hex/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: encoding/hex/check .PHONY: encoding/hex/check
encoding/libline.a: $(go_encoding_line_files) io.gox os.gox
$(BUILDARCHIVE)
encoding/libline.la: encoding/libline.a
encoding/line/check: $(CHECK_DEPS)
@$(MKDIR_P) encoding/line
$(CHECK)
.PHONY: encoding/line/check
encoding/libpem.a: $(go_encoding_pem_files) bytes.gox encoding/base64.gox encoding/libpem.a: $(go_encoding_pem_files) bytes.gox encoding/base64.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
encoding/libpem.la: encoding/libpem.a encoding/libpem.la: encoding/libpem.a
@ -4513,8 +4745,8 @@ image/png/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: image/png/check .PHONY: image/png/check
index/libsuffixarray.a: $(go_index_suffixarray_files) bytes.gox \ index/libsuffixarray.a: $(go_index_suffixarray_files) bytes.gox regexp.gox \
container/vector.gox sort.gox sort.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
index/libsuffixarray.la: index/libsuffixarray.a index/libsuffixarray.la: index/libsuffixarray.a
index/suffixarray/check: $(CHECK_DEPS) index/suffixarray/check: $(CHECK_DEPS)
@ -4555,6 +4787,15 @@ net/textproto/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: net/textproto/check .PHONY: net/textproto/check
os/libinotify.a: $(go_os_inotify_files) fmt.gox os.gox strings.gox \
syscall.gox
$(BUILDARCHIVE)
os/libinotify.la: os/libinotify.a
os/inotify/check: $(CHECK_DEPS)
@$(MKDIR_P) os/inotify
$(CHECK)
.PHONY: os/inotify/check
os/libsignal.a: $(go_os_signal_files) runtime.gox strconv.gox os/libsignal.a: $(go_os_signal_files) runtime.gox strconv.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
os/libsignal.la: os/libsignal.a os/libsignal.la: os/libsignal.a
@ -4576,6 +4817,15 @@ rpc/jsonrpc/check: $(CHECK_DEPS)
$(CHECK) $(CHECK)
.PHONY: rpc/jsonrpc/check .PHONY: rpc/jsonrpc/check
runtime/libdebug.a: $(go_runtime_debug_files) bytes.gox fmt.gox io/ioutil.gox \
os.gox runtime.gox
$(BUILDARCHIVE)
runtime/libdebug.la: runtime/libdebug.a
runtime/debug/check: $(CHECK_DEPS)
@$(MKDIR_P) runtime/debug
$(CHECK)
.PHONY: runtime/debug/check
runtime/libpprof.a: $(go_runtime_pprof_files) bufio.gox fmt.gox io.gox os.gox \ runtime/libpprof.a: $(go_runtime_pprof_files) bufio.gox fmt.gox io.gox os.gox \
runtime.gox runtime.gox
$(BUILDARCHIVE) $(BUILDARCHIVE)
@ -4749,6 +4999,10 @@ crypto/blowfish.gox: crypto/libblowfish.a
$(BUILDGOX) $(BUILDGOX)
crypto/cast5.gox: crypto/libcast5.a crypto/cast5.gox: crypto/libcast5.a
$(BUILDGOX) $(BUILDGOX)
crypto/cipher.gox: crypto/libcipher.a
$(BUILDGOX)
crypto/elliptic.gox: crypto/libelliptic.a
$(BUILDGOX)
crypto/hmac.gox: crypto/libhmac.a crypto/hmac.gox: crypto/libhmac.a
$(BUILDGOX) $(BUILDGOX)
crypto/md4.gox: crypto/libmd4.a crypto/md4.gox: crypto/libmd4.a
@ -4775,11 +5029,20 @@ crypto/subtle.gox: crypto/libsubtle.a
$(BUILDGOX) $(BUILDGOX)
crypto/tls.gox: crypto/libtls.a crypto/tls.gox: crypto/libtls.a
$(BUILDGOX) $(BUILDGOX)
crypto/twofish.gox: crypto/libtwofish.a
$(BUILDGOX)
crypto/x509.gox: crypto/libx509.a crypto/x509.gox: crypto/libx509.a
$(BUILDGOX) $(BUILDGOX)
crypto/xtea.gox: crypto/libxtea.a crypto/xtea.gox: crypto/libxtea.a
$(BUILDGOX) $(BUILDGOX)
crypto/openpgp/armor.gox: crypto/openpgp/libarmor.a
$(BUILDGOX)
crypto/openpgp/error.gox: crypto/openpgp/liberror.a
$(BUILDGOX)
crypto/openpgp/s2k.gox: crypto/openpgp/libs2k.a
$(BUILDGOX)
debug/dwarf.gox: debug/libdwarf.a debug/dwarf.gox: debug/libdwarf.a
$(BUILDGOX) $(BUILDGOX)
debug/elf.gox: debug/libelf.a debug/elf.gox: debug/libelf.a
@ -4795,6 +5058,8 @@ debug/proc.gox: debug/libproc.a
encoding/ascii85.gox: encoding/libascii85.a encoding/ascii85.gox: encoding/libascii85.a
$(BUILDGOX) $(BUILDGOX)
encoding/base32.gox: encoding/libbase32.a
$(BUILDGOX)
encoding/base64.gox: encoding/libbase64.a encoding/base64.gox: encoding/libbase64.a
$(BUILDGOX) $(BUILDGOX)
encoding/binary.gox: encoding/libbinary.a encoding/binary.gox: encoding/libbinary.a
@ -4803,6 +5068,8 @@ encoding/git85.gox: encoding/libgit85.a
$(BUILDGOX) $(BUILDGOX)
encoding/hex.gox: encoding/libhex.a encoding/hex.gox: encoding/libhex.a
$(BUILDGOX) $(BUILDGOX)
encoding/line.gox: encoding/libline.a
$(BUILDGOX)
encoding/pem.gox: encoding/libpem.a encoding/pem.gox: encoding/libpem.a
$(BUILDGOX) $(BUILDGOX)
@ -4857,12 +5124,16 @@ net/dict.gox: net/libdict.a
net/textproto.gox: net/libtextproto.a net/textproto.gox: net/libtextproto.a
$(BUILDGOX) $(BUILDGOX)
os/inotify.gox: os/libinotify.a
$(BUILDGOX)
os/signal.gox: os/libsignal.a os/signal.gox: os/libsignal.a
$(BUILDGOX) $(BUILDGOX)
rpc/jsonrpc.gox: rpc/libjsonrpc.a rpc/jsonrpc.gox: rpc/libjsonrpc.a
$(BUILDGOX) $(BUILDGOX)
runtime/debug.gox: runtime/libdebug.a
$(BUILDGOX)
runtime/pprof.gox: runtime/libpprof.a runtime/pprof.gox: runtime/libpprof.a
$(BUILDGOX) $(BUILDGOX)

View File

@ -136,7 +136,7 @@ testLoop:
break break
} }
if hdr != nil || err != nil { if hdr != nil || err != nil {
t.Errorf("test %d: Unexpected entry or error: hdr=%v err=%v", i, err) t.Errorf("test %d: Unexpected entry or error: hdr=%v err=%v", i, hdr, err)
} }
f.Close() f.Close()
} }

View File

@ -141,7 +141,7 @@ testLoop:
} }
} }
if err := tw.Close(); err != nil { if err := tw.Close(); err != nil {
t.Errorf("test %d: Failed closing archive: %v", err) t.Errorf("test %d: Failed closing archive: %v", i, err)
continue testLoop continue testLoop
} }

View File

@ -111,7 +111,7 @@ func readTestZip(t *testing.T, zt ZipTest) {
var b bytes.Buffer var b bytes.Buffer
_, err = io.Copy(&b, r) _, err = io.Copy(&b, r)
if err != ChecksumError { if err != ChecksumError {
t.Errorf("%s: copy error=%v, want %v", err, ChecksumError) t.Errorf("%s: copy error=%v, want %v", z.File[0].Name, err, ChecksumError)
} }
} }
@ -144,7 +144,7 @@ func readTestFile(t *testing.T, ft ZipTestFile, f *File) {
} }
for i, b := range b.Bytes() { for i, b := range b.Bytes() {
if b != c[i] { if b != c[i] {
t.Errorf("%s: content[%d]=%q want %q", i, b, c[i]) t.Errorf("%s: content[%d]=%q want %q", f.Name, i, b, c[i])
return return
} }
} }

View File

@ -591,7 +591,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
sliceValue := v.(*reflect.SliceValue) sliceValue := v.(*reflect.SliceValue)
sliceValue.Set(reflect.MakeSlice(sliceValue.Type().(*reflect.SliceType), len(newSlice), len(newSlice))) sliceValue.Set(reflect.MakeSlice(sliceValue.Type().(*reflect.SliceType), len(newSlice), len(newSlice)))
if err1 == nil { if err1 == nil {
reflect.ArrayCopy(sliceValue, reflect.NewValue(newSlice).(reflect.ArrayOrSliceValue)) reflect.Copy(sliceValue, reflect.NewValue(newSlice).(reflect.ArrayOrSliceValue))
} }
err = err1 err = err1
return return
@ -683,7 +683,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
sliceType := fieldType.(*reflect.SliceType) sliceType := fieldType.(*reflect.SliceType)
if sliceType.Elem().Kind() == reflect.Uint8 { if sliceType.Elem().Kind() == reflect.Uint8 {
val.Set(reflect.MakeSlice(sliceType, len(innerBytes), len(innerBytes))) val.Set(reflect.MakeSlice(sliceType, len(innerBytes), len(innerBytes)))
reflect.ArrayCopy(val, reflect.NewValue(innerBytes).(reflect.ArrayOrSliceValue)) reflect.Copy(val, reflect.NewValue(innerBytes).(reflect.ArrayOrSliceValue))
return return
} }
newSlice, err1 := parseSequenceOf(innerBytes, sliceType, sliceType.Elem()) newSlice, err1 := parseSequenceOf(innerBytes, sliceType, sliceType.Elem())

View File

@ -94,7 +94,7 @@ func testFunZZ(t *testing.T, msg string, f funZZ, a argZZ) {
var z Int var z Int
f(&z, a.x, a.y) f(&z, a.x, a.y)
if !isNormalized(&z) { if !isNormalized(&z) {
t.Errorf("msg: %v is not normalized", z, msg) t.Errorf("%s%v is not normalized", z, msg)
} }
if (&z).Cmp(a.z) != 0 { if (&z).Cmp(a.z) != 0 {
t.Errorf("%s%+v\n\tgot z = %v; want %v", msg, a, &z, a.z) t.Errorf("%s%+v\n\tgot z = %v; want %v", msg, a, &z, a.z)

View File

@ -35,9 +35,8 @@ func (z *Rat) SetFrac(a, b *Int) *Rat {
func (z *Rat) SetFrac64(a, b int64) *Rat { func (z *Rat) SetFrac64(a, b int64) *Rat {
z.a.SetInt64(a) z.a.SetInt64(a)
if b < 0 { if b < 0 {
z.b.setUint64(uint64(-b)) b = -b
z.a.neg = !z.a.neg z.a.neg = !z.a.neg
return z.norm()
} }
z.b = z.b.setUint64(uint64(b)) z.b = z.b.setUint64(uint64(b))
return z.norm() return z.norm()

View File

@ -257,3 +257,26 @@ func TestIssue820(t *testing.T) {
t.Errorf("got %s want %s", z, q) t.Errorf("got %s want %s", z, q)
} }
} }
var setFrac64Tests = []struct {
a, b int64
out string
}{
{0, 1, "0"},
{0, -1, "0"},
{1, 1, "1"},
{-1, 1, "-1"},
{1, -1, "-1"},
{-1, -1, "1"},
{-9223372036854775808, -9223372036854775808, "1"},
}
func TestRatSetFrac64Rat(t *testing.T) {
for i, test := range setFrac64Tests {
x := new(Rat).SetFrac64(test.a, test.b)
if x.RatString() != test.out {
t.Errorf("#%d got %s want %s", i, x.RatString(), test.out)
}
}
}

View File

@ -128,43 +128,42 @@ func (b *Reader) Peek(n int) ([]byte, os.Error) {
// Read reads data into p. // Read reads data into p.
// It returns the number of bytes read into p. // It returns the number of bytes read into p.
// If nn < len(p), also returns an error explaining // It calls Read at most once on the underlying Reader,
// why the read is short. At EOF, the count will be // hence n may be less than len(p).
// zero and err will be os.EOF. // At EOF, the count will be zero and err will be os.EOF.
func (b *Reader) Read(p []byte) (nn int, err os.Error) { func (b *Reader) Read(p []byte) (n int, err os.Error) {
nn = 0 n = len(p)
for len(p) > 0 { if n == 0 {
n := len(p) return 0, b.err
if b.w == b.r {
if b.err != nil {
return nn, b.err
}
if len(p) >= len(b.buf) {
// Large read, empty buffer.
// Read directly into p to avoid copy.
n, b.err = b.rd.Read(p)
if n > 0 {
b.lastByte = int(p[n-1])
b.lastRuneSize = -1
}
p = p[n:]
nn += n
continue
}
b.fill()
continue
}
if n > b.w-b.r {
n = b.w - b.r
}
copy(p[0:n], b.buf[b.r:])
p = p[n:]
b.r += n
b.lastByte = int(b.buf[b.r-1])
b.lastRuneSize = -1
nn += n
} }
return nn, nil if b.w == b.r {
if b.err != nil {
return 0, b.err
}
if len(p) >= len(b.buf) {
// Large read, empty buffer.
// Read directly into p to avoid copy.
n, b.err = b.rd.Read(p)
if n > 0 {
b.lastByte = int(p[n-1])
b.lastRuneSize = -1
}
return n, b.err
}
b.fill()
if b.w == b.r {
return 0, b.err
}
}
if n > b.w-b.r {
n = b.w - b.r
}
copy(p[0:n], b.buf[b.r:])
b.r += n
b.lastByte = int(b.buf[b.r-1])
b.lastRuneSize = -1
return n, nil
} }
// ReadByte reads and returns a single byte. // ReadByte reads and returns a single byte.
@ -482,7 +481,7 @@ func (b *Writer) WriteRune(rune int) (size int, err os.Error) {
return b.WriteString(string(rune)) return b.WriteString(string(rune))
} }
} }
size = utf8.EncodeRune(rune, b.buf[b.n:]) size = utf8.EncodeRune(b.buf[b.n:], rune)
b.n += size b.n += size
return size, nil return size, nil
} }

View File

@ -337,7 +337,7 @@ func TestReadWriteRune(t *testing.T) {
// Write the runes out using WriteRune // Write the runes out using WriteRune
buf := make([]byte, utf8.UTFMax) buf := make([]byte, utf8.UTFMax)
for rune := 0; rune < NRune; rune++ { for rune := 0; rune < NRune; rune++ {
size := utf8.EncodeRune(rune, buf) size := utf8.EncodeRune(buf, rune)
nbytes, err := w.WriteRune(rune) nbytes, err := w.WriteRune(rune)
if err != nil { if err != nil {
t.Fatalf("WriteRune(0x%x) error: %s", rune, err) t.Fatalf("WriteRune(0x%x) error: %s", rune, err)
@ -351,7 +351,7 @@ func TestReadWriteRune(t *testing.T) {
r := NewReader(byteBuf) r := NewReader(byteBuf)
// Read them back with ReadRune // Read them back with ReadRune
for rune := 0; rune < NRune; rune++ { for rune := 0; rune < NRune; rune++ {
size := utf8.EncodeRune(rune, buf) size := utf8.EncodeRune(buf, rune)
nr, nbytes, err := r.ReadRune() nr, nbytes, err := r.ReadRune()
if nr != rune || nbytes != size || err != nil { if nr != rune || nbytes != size || err != nil {
t.Fatalf("ReadRune(0x%x) got 0x%x,%d not 0x%x,%d (err=%s)", r, nr, nbytes, r, size, err) t.Fatalf("ReadRune(0x%x) got 0x%x,%d not 0x%x,%d (err=%s)", r, nr, nbytes, r, size, err)
@ -397,9 +397,9 @@ func TestWriter(t *testing.T) {
} }
for l := 0; l < len(written); l++ { for l := 0; l < len(written); l++ {
if written[i] != data[i] { if written[i] != data[i] {
t.Errorf("%s: wrong bytes written") t.Errorf("wrong bytes written")
t.Errorf("want=%s", data[0:len(written)]) t.Errorf("want=%q", data[0:len(written)])
t.Errorf("have=%s", written) t.Errorf("have=%q", written)
} }
} }
} }

View File

@ -19,8 +19,20 @@ type Buffer struct {
off int // read at &buf[off], write at &buf[len(buf)] off int // read at &buf[off], write at &buf[len(buf)]
runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each WriteByte or Rune runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each WriteByte or Rune
bootstrap [64]byte // memory to hold first slice; helps small buffers (Printf) avoid allocation. bootstrap [64]byte // memory to hold first slice; helps small buffers (Printf) avoid allocation.
lastRead readOp // last read operation, so that Unread* can work correctly.
} }
// The readOp constants describe the last action performed on
// the buffer, so that UnreadRune and UnreadByte can
// check for invalid usage.
type readOp int
const (
opInvalid readOp = iota // Non-read operation.
opReadRune // Read rune.
opRead // Any other read operation.
)
// Bytes returns a slice of the contents of the unread portion of the buffer; // Bytes returns a slice of the contents of the unread portion of the buffer;
// len(b.Bytes()) == b.Len(). If the caller changes the contents of the // len(b.Bytes()) == b.Len(). If the caller changes the contents of the
// returned slice, the contents of the buffer will change provided there // returned slice, the contents of the buffer will change provided there
@ -44,6 +56,7 @@ func (b *Buffer) Len() int { return len(b.buf) - b.off }
// Truncate discards all but the first n unread bytes from the buffer. // Truncate discards all but the first n unread bytes from the buffer.
// It is an error to call b.Truncate(n) with n > b.Len(). // It is an error to call b.Truncate(n) with n > b.Len().
func (b *Buffer) Truncate(n int) { func (b *Buffer) Truncate(n int) {
b.lastRead = opInvalid
if n == 0 { if n == 0 {
// Reuse buffer space. // Reuse buffer space.
b.off = 0 b.off = 0
@ -82,6 +95,7 @@ func (b *Buffer) grow(n int) int {
// Write appends the contents of p to the buffer. The return // Write appends the contents of p to the buffer. The return
// value n is the length of p; err is always nil. // value n is the length of p; err is always nil.
func (b *Buffer) Write(p []byte) (n int, err os.Error) { func (b *Buffer) Write(p []byte) (n int, err os.Error) {
b.lastRead = opInvalid
m := b.grow(len(p)) m := b.grow(len(p))
copy(b.buf[m:], p) copy(b.buf[m:], p)
return len(p), nil return len(p), nil
@ -90,6 +104,7 @@ func (b *Buffer) Write(p []byte) (n int, err os.Error) {
// WriteString appends the contents of s to the buffer. The return // WriteString appends the contents of s to the buffer. The return
// value n is the length of s; err is always nil. // value n is the length of s; err is always nil.
func (b *Buffer) WriteString(s string) (n int, err os.Error) { func (b *Buffer) WriteString(s string) (n int, err os.Error) {
b.lastRead = opInvalid
m := b.grow(len(s)) m := b.grow(len(s))
return copy(b.buf[m:], s), nil return copy(b.buf[m:], s), nil
} }
@ -105,6 +120,7 @@ const MinRead = 512
// Any error except os.EOF encountered during the read // Any error except os.EOF encountered during the read
// is also returned. // is also returned.
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err os.Error) { func (b *Buffer) ReadFrom(r io.Reader) (n int64, err os.Error) {
b.lastRead = opInvalid
// If buffer is empty, reset to recover space. // If buffer is empty, reset to recover space.
if b.off >= len(b.buf) { if b.off >= len(b.buf) {
b.Truncate(0) b.Truncate(0)
@ -141,6 +157,7 @@ func (b *Buffer) ReadFrom(r io.Reader) (n int64, err os.Error) {
// occurs. The return value n is the number of bytes written. // occurs. The return value n is the number of bytes written.
// Any error encountered during the write is also returned. // Any error encountered during the write is also returned.
func (b *Buffer) WriteTo(w io.Writer) (n int64, err os.Error) { func (b *Buffer) WriteTo(w io.Writer) (n int64, err os.Error) {
b.lastRead = opInvalid
for b.off < len(b.buf) { for b.off < len(b.buf) {
m, e := w.Write(b.buf[b.off:]) m, e := w.Write(b.buf[b.off:])
n += int64(m) n += int64(m)
@ -158,6 +175,7 @@ func (b *Buffer) WriteTo(w io.Writer) (n int64, err os.Error) {
// The returned error is always nil, but is included // The returned error is always nil, but is included
// to match bufio.Writer's WriteByte. // to match bufio.Writer's WriteByte.
func (b *Buffer) WriteByte(c byte) os.Error { func (b *Buffer) WriteByte(c byte) os.Error {
b.lastRead = opInvalid
m := b.grow(1) m := b.grow(1)
b.buf[m] = c b.buf[m] = c
return nil return nil
@ -172,7 +190,7 @@ func (b *Buffer) WriteRune(r int) (n int, err os.Error) {
b.WriteByte(byte(r)) b.WriteByte(byte(r))
return 1, nil return 1, nil
} }
n = utf8.EncodeRune(r, b.runeBytes[0:]) n = utf8.EncodeRune(b.runeBytes[0:], r)
b.Write(b.runeBytes[0:n]) b.Write(b.runeBytes[0:n])
return n, nil return n, nil
} }
@ -182,6 +200,7 @@ func (b *Buffer) WriteRune(r int) (n int, err os.Error) {
// buffer has no data to return, err is os.EOF even if len(p) is zero; // buffer has no data to return, err is os.EOF even if len(p) is zero;
// otherwise it is nil. // otherwise it is nil.
func (b *Buffer) Read(p []byte) (n int, err os.Error) { func (b *Buffer) Read(p []byte) (n int, err os.Error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) { if b.off >= len(b.buf) {
// Buffer is empty, reset to recover space. // Buffer is empty, reset to recover space.
b.Truncate(0) b.Truncate(0)
@ -189,6 +208,9 @@ func (b *Buffer) Read(p []byte) (n int, err os.Error) {
} }
n = copy(p, b.buf[b.off:]) n = copy(p, b.buf[b.off:])
b.off += n b.off += n
if n > 0 {
b.lastRead = opRead
}
return return
} }
@ -197,18 +219,23 @@ func (b *Buffer) Read(p []byte) (n int, err os.Error) {
// If there are fewer than n bytes in the buffer, Next returns the entire buffer. // If there are fewer than n bytes in the buffer, Next returns the entire buffer.
// The slice is only valid until the next call to a read or write method. // The slice is only valid until the next call to a read or write method.
func (b *Buffer) Next(n int) []byte { func (b *Buffer) Next(n int) []byte {
b.lastRead = opInvalid
m := b.Len() m := b.Len()
if n > m { if n > m {
n = m n = m
} }
data := b.buf[b.off : b.off+n] data := b.buf[b.off : b.off+n]
b.off += n b.off += n
if n > 0 {
b.lastRead = opRead
}
return data return data
} }
// ReadByte reads and returns the next byte from the buffer. // ReadByte reads and returns the next byte from the buffer.
// If no byte is available, it returns error os.EOF. // If no byte is available, it returns error os.EOF.
func (b *Buffer) ReadByte() (c byte, err os.Error) { func (b *Buffer) ReadByte() (c byte, err os.Error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) { if b.off >= len(b.buf) {
// Buffer is empty, reset to recover space. // Buffer is empty, reset to recover space.
b.Truncate(0) b.Truncate(0)
@ -216,6 +243,7 @@ func (b *Buffer) ReadByte() (c byte, err os.Error) {
} }
c = b.buf[b.off] c = b.buf[b.off]
b.off++ b.off++
b.lastRead = opRead
return c, nil return c, nil
} }
@ -225,11 +253,13 @@ func (b *Buffer) ReadByte() (c byte, err os.Error) {
// If the bytes are an erroneous UTF-8 encoding, it // If the bytes are an erroneous UTF-8 encoding, it
// consumes one byte and returns U+FFFD, 1. // consumes one byte and returns U+FFFD, 1.
func (b *Buffer) ReadRune() (r int, size int, err os.Error) { func (b *Buffer) ReadRune() (r int, size int, err os.Error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) { if b.off >= len(b.buf) {
// Buffer is empty, reset to recover space. // Buffer is empty, reset to recover space.
b.Truncate(0) b.Truncate(0)
return 0, 0, os.EOF return 0, 0, os.EOF
} }
b.lastRead = opReadRune
c := b.buf[b.off] c := b.buf[b.off]
if c < utf8.RuneSelf { if c < utf8.RuneSelf {
b.off++ b.off++
@ -240,9 +270,40 @@ func (b *Buffer) ReadRune() (r int, size int, err os.Error) {
return r, n, nil return r, n, nil
} }
// UnreadRune unreads the last rune returned by ReadRune.
// If the most recent read or write operation on the buffer was
// not a ReadRune, UnreadRune returns an error. (In this regard
// it is stricter than UnreadByte, which will unread the last byte
// from any read operation.)
func (b *Buffer) UnreadRune() os.Error {
if b.lastRead != opReadRune {
return os.ErrorString("bytes.Buffer: UnreadRune: previous operation was not ReadRune")
}
b.lastRead = opInvalid
if b.off > 0 {
_, n := utf8.DecodeLastRune(b.buf[0:b.off])
b.off -= n
}
return nil
}
// UnreadByte unreads the last byte returned by the most recent
// read operation. If write has happened since the last read, UnreadByte
// returns an error.
func (b *Buffer) UnreadByte() os.Error {
if b.lastRead != opReadRune && b.lastRead != opRead {
return os.ErrorString("bytes.Buffer: UnreadByte: previous operation was not a read")
}
b.lastRead = opInvalid
if b.off > 0 {
b.off--
}
return nil
}
// NewBuffer creates and initializes a new Buffer using buf as its initial // NewBuffer creates and initializes a new Buffer using buf as its initial
// contents. It is intended to prepare a Buffer to read existing data. It // contents. It is intended to prepare a Buffer to read existing data. It
// can also be used to to size the internal buffer for writing. To do that, // can also be used to size the internal buffer for writing. To do that,
// buf should have the desired capacity but a length of zero. // buf should have the desired capacity but a length of zero.
func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} } func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} }

View File

@ -165,7 +165,7 @@ func TestBasicOperations(t *testing.T) {
t.Error("ReadByte unexpected eof") t.Error("ReadByte unexpected eof")
} }
if c != data[1] { if c != data[1] {
t.Error("ReadByte wrong value c=%v", c) t.Errorf("ReadByte wrong value c=%v", c)
} }
c, err = buf.ReadByte() c, err = buf.ReadByte()
if err == nil { if err == nil {
@ -272,13 +272,13 @@ func TestRuneIO(t *testing.T) {
var buf Buffer var buf Buffer
n := 0 n := 0
for r := 0; r < NRune; r++ { for r := 0; r < NRune; r++ {
size := utf8.EncodeRune(r, b[n:]) size := utf8.EncodeRune(b[n:], r)
nbytes, err := buf.WriteRune(r) nbytes, err := buf.WriteRune(r)
if err != nil { if err != nil {
t.Fatalf("WriteRune(0x%x) error: %s", r, err) t.Fatalf("WriteRune(%U) error: %s", r, err)
} }
if nbytes != size { if nbytes != size {
t.Fatalf("WriteRune(0x%x) expected %d, got %d", r, size, nbytes) t.Fatalf("WriteRune(%U) expected %d, got %d", r, size, nbytes)
} }
n += size n += size
} }
@ -289,12 +289,27 @@ func TestRuneIO(t *testing.T) {
t.Fatalf("incorrect result from WriteRune: %q not %q", buf.Bytes(), b) t.Fatalf("incorrect result from WriteRune: %q not %q", buf.Bytes(), b)
} }
p := make([]byte, utf8.UTFMax)
// Read it back with ReadRune // Read it back with ReadRune
for r := 0; r < NRune; r++ { for r := 0; r < NRune; r++ {
size := utf8.EncodeRune(r, b) size := utf8.EncodeRune(p, r)
nr, nbytes, err := buf.ReadRune() nr, nbytes, err := buf.ReadRune()
if nr != r || nbytes != size || err != nil { if nr != r || nbytes != size || err != nil {
t.Fatalf("ReadRune(0x%x) got 0x%x,%d not 0x%x,%d (err=%s)", r, nr, nbytes, r, size, err) t.Fatalf("ReadRune(%U) got %U,%d not %U,%d (err=%s)", r, nr, nbytes, r, size, err)
}
}
// Check that UnreadRune works
buf.Reset()
buf.Write(b)
for r := 0; r < NRune; r++ {
r1, size, _ := buf.ReadRune()
if err := buf.UnreadRune(); err != nil {
t.Fatalf("UnreadRune(%U) got error %q", r, err)
}
r2, nbytes, err := buf.ReadRune()
if r1 != r2 || r1 != r || nbytes != size || err != nil {
t.Fatalf("ReadRune(%U) after UnreadRune got %U,%d not %U,%d (err=%s)", r, r2, nbytes, r, size, err)
} }
} }
} }

View File

@ -165,6 +165,25 @@ func IndexAny(s []byte, chars string) int {
return -1 return -1
} }
// LastIndexAny interprets s as a sequence of UTF-8-encoded Unicode code
// points. It returns the byte index of the last occurrence in s of any of
// the Unicode code points in chars. It returns -1 if chars is empty or if
// there is no code point in common.
func LastIndexAny(s []byte, chars string) int {
if len(chars) > 0 {
for i := len(s); i > 0; {
rune, size := utf8.DecodeLastRune(s[0:i])
i -= size
for _, m := range chars {
if rune == m {
return i
}
}
}
}
return -1
}
// Generic split: splits after each instance of sep, // Generic split: splits after each instance of sep,
// including sepSave bytes of sep in the subarrays. // including sepSave bytes of sep in the subarrays.
func genSplit(s, sep []byte, sepSave, n int) [][]byte { func genSplit(s, sep []byte, sepSave, n int) [][]byte {
@ -328,7 +347,7 @@ func Map(mapping func(rune int) int, s []byte) []byte {
copy(nb, b[0:nbytes]) copy(nb, b[0:nbytes])
b = nb b = nb
} }
nbytes += utf8.EncodeRune(rune, b[nbytes:maxbytes]) nbytes += utf8.EncodeRune(b[nbytes:maxbytes], rune)
} }
i += wid i += wid
} }
@ -528,53 +547,11 @@ func TrimRight(s []byte, cutset string) []byte {
} }
// TrimSpace returns a subslice of s by slicing off all leading and // TrimSpace returns a subslice of s by slicing off all leading and
// trailing white space, as as defined by Unicode. // trailing white space, as defined by Unicode.
func TrimSpace(s []byte) []byte { func TrimSpace(s []byte) []byte {
return TrimFunc(s, unicode.IsSpace) return TrimFunc(s, unicode.IsSpace)
} }
// How big to make a byte array when growing.
// Heuristic: Scale by 50% to give n log n time.
func resize(n int) int {
if n < 16 {
n = 16
}
return n + n/2
}
// Add appends the contents of t to the end of s and returns the result.
// If s has enough capacity, it is extended in place; otherwise a
// new array is allocated and returned.
func Add(s, t []byte) []byte { // TODO
lens := len(s)
lent := len(t)
if lens+lent <= cap(s) {
s = s[0 : lens+lent]
} else {
news := make([]byte, lens+lent, resize(lens+lent))
copy(news, s)
s = news
}
copy(s[lens:lens+lent], t)
return s
}
// AddByte appends byte t to the end of s and returns the result.
// If s has enough capacity, it is extended in place; otherwise a
// new array is allocated and returned.
func AddByte(s []byte, t byte) []byte { // TODO
lens := len(s)
if lens+1 <= cap(s) {
s = s[0 : lens+1]
} else {
news := make([]byte, lens+1, resize(lens+1))
copy(news, s)
s = news
}
s[lens] = t
return s
}
// Runes returns a slice of runes (Unicode code points) equivalent to s. // Runes returns a slice of runes (Unicode code points) equivalent to s.
func Runes(s []byte) []int { func Runes(s []byte) []int {
t := make([]int, utf8.RuneCount(s)) t := make([]int, utf8.RuneCount(s))

View File

@ -128,6 +128,20 @@ var indexAnyTests = []BinOpTest{
{dots + dots + dots, " ", -1}, {dots + dots + dots, " ", -1},
} }
var lastIndexAnyTests = []BinOpTest{
{"", "", -1},
{"", "a", -1},
{"", "abc", -1},
{"a", "", -1},
{"a", "a", 0},
{"aaa", "a", 2},
{"abc", "xyz", -1},
{"abc", "ab", 1},
{"a☺b☻c☹d", "uvw☻xyz", 2 + len("☺")},
{"a.RegExp*", ".(|)*+?^$[]", 8},
{dots + dots + dots, " ", -1},
}
var indexRuneTests = []BinOpTest{ var indexRuneTests = []BinOpTest{
{"", "a", -1}, {"", "a", -1},
{"", "☺", -1}, {"", "☺", -1},
@ -150,18 +164,23 @@ func runIndexTests(t *testing.T, f func(s, sep []byte) int, funcName string, tes
} }
} }
func TestIndex(t *testing.T) { runIndexTests(t, Index, "Index", indexTests) } func runIndexAnyTests(t *testing.T, f func(s []byte, chars string) int, funcName string, testCases []BinOpTest) {
func TestLastIndex(t *testing.T) { runIndexTests(t, LastIndex, "LastIndex", lastIndexTests) } for _, test := range testCases {
func TestIndexAny(t *testing.T) {
for _, test := range indexAnyTests {
a := []byte(test.a) a := []byte(test.a)
actual := IndexAny(a, test.b) actual := f(a, test.b)
if actual != test.i { if actual != test.i {
t.Errorf("IndexAny(%q,%q) = %v; want %v", a, test.b, actual, test.i) t.Errorf("%s(%q,%q) = %v; want %v", funcName, a, test.b, actual, test.i)
} }
} }
} }
func TestIndex(t *testing.T) { runIndexTests(t, Index, "Index", indexTests) }
func TestLastIndex(t *testing.T) { runIndexTests(t, LastIndex, "LastIndex", lastIndexTests) }
func TestIndexAny(t *testing.T) { runIndexAnyTests(t, IndexAny, "IndexAny", indexAnyTests) }
func TestLastIndexAny(t *testing.T) {
runIndexAnyTests(t, LastIndexAny, "LastIndexAny", lastIndexAnyTests)
}
func TestIndexByte(t *testing.T) { func TestIndexByte(t *testing.T) {
for _, tt := range indexTests { for _, tt := range indexTests {
if len(tt.b) != 1 { if len(tt.b) != 1 {
@ -554,45 +573,6 @@ func TestToLower(t *testing.T) { runStringTests(t, ToLower, "ToLower", lowerTest
func TestTrimSpace(t *testing.T) { runStringTests(t, TrimSpace, "TrimSpace", trimSpaceTests) } func TestTrimSpace(t *testing.T) { runStringTests(t, TrimSpace, "TrimSpace", trimSpaceTests) }
type AddTest struct {
s, t string
cap int
}
var addtests = []AddTest{
{"", "", 0},
{"a", "", 1},
{"a", "b", 1},
{"abc", "def", 100},
}
func TestAdd(t *testing.T) {
for _, test := range addtests {
b := make([]byte, len(test.s), test.cap)
copy(b, test.s)
b = Add(b, []byte(test.t))
if string(b) != test.s+test.t {
t.Errorf("Add(%q,%q) = %q", test.s, test.t, string(b))
}
}
}
func TestAddByte(t *testing.T) {
const N = 2e5
b := make([]byte, 0)
for i := 0; i < N; i++ {
b = AddByte(b, byte(i))
}
if len(b) != N {
t.Errorf("AddByte: too small; expected %d got %d", N, len(b))
}
for i, c := range b {
if c != byte(i) {
t.Fatalf("AddByte: b[%d] should be %d is %d", i, c, byte(i))
}
}
}
type RepeatTest struct { type RepeatTest struct {
in, out string in, out string
count int count int

View File

@ -51,16 +51,16 @@ import "math"
func Asin(x complex128) complex128 { func Asin(x complex128) complex128 {
if imag(x) == 0 { if imag(x) == 0 {
if math.Fabs(real(x)) > 1 { if math.Fabs(real(x)) > 1 {
return cmplx(math.Pi/2, 0) // DOMAIN error return complex(math.Pi/2, 0) // DOMAIN error
} }
return cmplx(math.Asin(real(x)), 0) return complex(math.Asin(real(x)), 0)
} }
ct := cmplx(-imag(x), real(x)) // i * x ct := complex(-imag(x), real(x)) // i * x
xx := x * x xx := x * x
x1 := cmplx(1-real(xx), -imag(xx)) // 1 - x*x x1 := complex(1-real(xx), -imag(xx)) // 1 - x*x
x2 := Sqrt(x1) // x2 = sqrt(1 - x*x) x2 := Sqrt(x1) // x2 = sqrt(1 - x*x)
w := Log(ct + x2) w := Log(ct + x2)
return cmplx(imag(w), -real(w)) // -i * w return complex(imag(w), -real(w)) // -i * w
} }
// Asinh returns the inverse hyperbolic sine of x. // Asinh returns the inverse hyperbolic sine of x.
@ -68,13 +68,13 @@ func Asinh(x complex128) complex128 {
// TODO check range // TODO check range
if imag(x) == 0 { if imag(x) == 0 {
if math.Fabs(real(x)) > 1 { if math.Fabs(real(x)) > 1 {
return cmplx(math.Pi/2, 0) // DOMAIN error return complex(math.Pi/2, 0) // DOMAIN error
} }
return cmplx(math.Asinh(real(x)), 0) return complex(math.Asinh(real(x)), 0)
} }
xx := x * x xx := x * x
x1 := cmplx(1+real(xx), imag(xx)) // 1 + x*x x1 := complex(1+real(xx), imag(xx)) // 1 + x*x
return Log(x + Sqrt(x1)) // log(x + sqrt(1 + x*x)) return Log(x + Sqrt(x1)) // log(x + sqrt(1 + x*x))
} }
// Complex circular arc cosine // Complex circular arc cosine
@ -93,16 +93,16 @@ func Asinh(x complex128) complex128 {
// Acos returns the inverse cosine of x. // Acos returns the inverse cosine of x.
func Acos(x complex128) complex128 { func Acos(x complex128) complex128 {
w := Asin(x) w := Asin(x)
return cmplx(math.Pi/2-real(w), -imag(w)) return complex(math.Pi/2-real(w), -imag(w))
} }
// Acosh returns the inverse hyperbolic cosine of x. // Acosh returns the inverse hyperbolic cosine of x.
func Acosh(x complex128) complex128 { func Acosh(x complex128) complex128 {
w := Acos(x) w := Acos(x)
if imag(w) <= 0 { if imag(w) <= 0 {
return cmplx(-imag(w), real(w)) // i * w return complex(-imag(w), real(w)) // i * w
} }
return cmplx(imag(w), -real(w)) // -i * w return complex(imag(w), -real(w)) // -i * w
} }
// Complex circular arc tangent // Complex circular arc tangent
@ -159,12 +159,12 @@ func Atan(x complex128) complex128 {
} }
t = imag(x) + 1 t = imag(x) + 1
c := (x2 + t*t) / b c := (x2 + t*t) / b
return cmplx(w, 0.25*math.Log(c)) return complex(w, 0.25*math.Log(c))
} }
// Atanh returns the inverse hyperbolic tangent of x. // Atanh returns the inverse hyperbolic tangent of x.
func Atanh(x complex128) complex128 { func Atanh(x complex128) complex128 {
z := cmplx(-imag(x), real(x)) // z = i * x z := complex(-imag(x), real(x)) // z = i * x
z = Atan(z) z = Atan(z)
return cmplx(imag(z), -real(z)) // z = -i * z return complex(imag(z), -real(z)) // z = -i * z
} }

View File

@ -355,15 +355,15 @@ var expSC = []complex128{
NaN(), NaN(),
} }
var vcIsNaNSC = []complex128{ var vcIsNaNSC = []complex128{
cmplx(math.Inf(-1), math.Inf(-1)), complex(math.Inf(-1), math.Inf(-1)),
cmplx(math.Inf(-1), math.NaN()), complex(math.Inf(-1), math.NaN()),
cmplx(math.NaN(), math.Inf(-1)), complex(math.NaN(), math.Inf(-1)),
cmplx(0, math.NaN()), complex(0, math.NaN()),
cmplx(math.NaN(), 0), complex(math.NaN(), 0),
cmplx(math.Inf(1), math.Inf(1)), complex(math.Inf(1), math.Inf(1)),
cmplx(math.Inf(1), math.NaN()), complex(math.Inf(1), math.NaN()),
cmplx(math.NaN(), math.Inf(1)), complex(math.NaN(), math.Inf(1)),
cmplx(math.NaN(), math.NaN()), complex(math.NaN(), math.NaN()),
} }
var isNaNSC = []bool{ var isNaNSC = []bool{
false, false,
@ -615,7 +615,7 @@ func TestExp(t *testing.T) {
func TestIsNaN(t *testing.T) { func TestIsNaN(t *testing.T) {
for i := 0; i < len(vcIsNaNSC); i++ { for i := 0; i < len(vcIsNaNSC); i++ {
if f := IsNaN(vcIsNaNSC[i]); isNaNSC[i] != f { if f := IsNaN(vcIsNaNSC[i]); isNaNSC[i] != f {
t.Errorf("IsNaN(%g) = %g, want %g", vcIsNaNSC[i], f, isNaNSC[i]) t.Errorf("IsNaN(%v) = %v, want %v", vcIsNaNSC[i], f, isNaNSC[i])
} }
} }
} }
@ -656,7 +656,7 @@ func TestPolar(t *testing.T) {
} }
} }
func TestPow(t *testing.T) { func TestPow(t *testing.T) {
var a = cmplx(float64(3), float64(3)) var a = complex(3.0, 3.0)
for i := 0; i < len(vc); i++ { for i := 0; i < len(vc); i++ {
if f := Pow(a, vc[i]); !cSoclose(pow[i], f, 4e-15) { if f := Pow(a, vc[i]); !cSoclose(pow[i], f, 4e-15) {
t.Errorf("Pow(%g, %g) = %g, want %g", a, vc[i], f, pow[i]) t.Errorf("Pow(%g, %g) = %g, want %g", a, vc[i], f, pow[i])
@ -743,82 +743,82 @@ func TestTanh(t *testing.T) {
func BenchmarkAbs(b *testing.B) { func BenchmarkAbs(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Abs(cmplx(2.5, 3.5)) Abs(complex(2.5, 3.5))
} }
} }
func BenchmarkAcos(b *testing.B) { func BenchmarkAcos(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Acos(cmplx(2.5, 3.5)) Acos(complex(2.5, 3.5))
} }
} }
func BenchmarkAcosh(b *testing.B) { func BenchmarkAcosh(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Acosh(cmplx(2.5, 3.5)) Acosh(complex(2.5, 3.5))
} }
} }
func BenchmarkAsin(b *testing.B) { func BenchmarkAsin(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Asin(cmplx(2.5, 3.5)) Asin(complex(2.5, 3.5))
} }
} }
func BenchmarkAsinh(b *testing.B) { func BenchmarkAsinh(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Asinh(cmplx(2.5, 3.5)) Asinh(complex(2.5, 3.5))
} }
} }
func BenchmarkAtan(b *testing.B) { func BenchmarkAtan(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Atan(cmplx(2.5, 3.5)) Atan(complex(2.5, 3.5))
} }
} }
func BenchmarkAtanh(b *testing.B) { func BenchmarkAtanh(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Atanh(cmplx(2.5, 3.5)) Atanh(complex(2.5, 3.5))
} }
} }
func BenchmarkConj(b *testing.B) { func BenchmarkConj(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Conj(cmplx(2.5, 3.5)) Conj(complex(2.5, 3.5))
} }
} }
func BenchmarkCos(b *testing.B) { func BenchmarkCos(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Cos(cmplx(2.5, 3.5)) Cos(complex(2.5, 3.5))
} }
} }
func BenchmarkCosh(b *testing.B) { func BenchmarkCosh(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Cosh(cmplx(2.5, 3.5)) Cosh(complex(2.5, 3.5))
} }
} }
func BenchmarkExp(b *testing.B) { func BenchmarkExp(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Exp(cmplx(2.5, 3.5)) Exp(complex(2.5, 3.5))
} }
} }
func BenchmarkLog(b *testing.B) { func BenchmarkLog(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Log(cmplx(2.5, 3.5)) Log(complex(2.5, 3.5))
} }
} }
func BenchmarkLog10(b *testing.B) { func BenchmarkLog10(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Log10(cmplx(2.5, 3.5)) Log10(complex(2.5, 3.5))
} }
} }
func BenchmarkPhase(b *testing.B) { func BenchmarkPhase(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Phase(cmplx(2.5, 3.5)) Phase(complex(2.5, 3.5))
} }
} }
func BenchmarkPolar(b *testing.B) { func BenchmarkPolar(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Polar(cmplx(2.5, 3.5)) Polar(complex(2.5, 3.5))
} }
} }
func BenchmarkPow(b *testing.B) { func BenchmarkPow(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Pow(cmplx(2.5, 3.5), cmplx(2.5, 3.5)) Pow(complex(2.5, 3.5), complex(2.5, 3.5))
} }
} }
func BenchmarkRect(b *testing.B) { func BenchmarkRect(b *testing.B) {
@ -828,26 +828,26 @@ func BenchmarkRect(b *testing.B) {
} }
func BenchmarkSin(b *testing.B) { func BenchmarkSin(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Sin(cmplx(2.5, 3.5)) Sin(complex(2.5, 3.5))
} }
} }
func BenchmarkSinh(b *testing.B) { func BenchmarkSinh(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Sinh(cmplx(2.5, 3.5)) Sinh(complex(2.5, 3.5))
} }
} }
func BenchmarkSqrt(b *testing.B) { func BenchmarkSqrt(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Sqrt(cmplx(2.5, 3.5)) Sqrt(complex(2.5, 3.5))
} }
} }
func BenchmarkTan(b *testing.B) { func BenchmarkTan(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Tan(cmplx(2.5, 3.5)) Tan(complex(2.5, 3.5))
} }
} }
func BenchmarkTanh(b *testing.B) { func BenchmarkTanh(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
Tanh(cmplx(2.5, 3.5)) Tanh(complex(2.5, 3.5))
} }
} }

View File

@ -5,4 +5,4 @@
package cmath package cmath
// Conj returns the complex conjugate of x. // Conj returns the complex conjugate of x.
func Conj(x complex128) complex128 { return cmplx(real(x), -imag(x)) } func Conj(x complex128) complex128 { return complex(real(x), -imag(x)) }

View File

@ -51,5 +51,5 @@ import "math"
func Exp(x complex128) complex128 { func Exp(x complex128) complex128 {
r := math.Exp(real(x)) r := math.Exp(real(x))
s, c := math.Sincos(imag(x)) s, c := math.Sincos(imag(x))
return cmplx(r*c, r*s) return complex(r*c, r*s)
} }

View File

@ -14,8 +14,8 @@ func IsInf(x complex128) bool {
return false return false
} }
// Inf returns a complex infinity, cmplx(+Inf, +Inf). // Inf returns a complex infinity, complex(+Inf, +Inf).
func Inf() complex128 { func Inf() complex128 {
inf := math.Inf(1) inf := math.Inf(1)
return cmplx(inf, inf) return complex(inf, inf)
} }

View File

@ -21,5 +21,5 @@ func IsNaN(x complex128) bool {
// NaN returns a complex ``not-a-number'' value. // NaN returns a complex ``not-a-number'' value.
func NaN() complex128 { func NaN() complex128 {
nan := math.NaN() nan := math.NaN()
return cmplx(nan, nan) return complex(nan, nan)
} }

View File

@ -55,7 +55,7 @@ import "math"
// Log returns the natural logarithm of x. // Log returns the natural logarithm of x.
func Log(x complex128) complex128 { func Log(x complex128) complex128 {
return cmplx(math.Log(Abs(x)), Phase(x)) return complex(math.Log(Abs(x)), Phase(x))
} }
// Log10 returns the decimal logarithm of x. // Log10 returns the decimal logarithm of x.

View File

@ -46,7 +46,7 @@ import "math"
func Pow(x, y complex128) complex128 { func Pow(x, y complex128) complex128 {
modulus := Abs(x) modulus := Abs(x)
if modulus == 0 { if modulus == 0 {
return cmplx(0, 0) return complex(0, 0)
} }
r := math.Pow(modulus, real(y)) r := math.Pow(modulus, real(y))
arg := Phase(x) arg := Phase(x)
@ -56,5 +56,5 @@ func Pow(x, y complex128) complex128 {
theta += imag(y) * math.Log(modulus) theta += imag(y) * math.Log(modulus)
} }
s, c := math.Sincos(theta) s, c := math.Sincos(theta)
return cmplx(r*c, r*s) return complex(r*c, r*s)
} }

View File

@ -9,5 +9,5 @@ import "math"
// Rect returns the complex number x with polar coordinates r, θ. // Rect returns the complex number x with polar coordinates r, θ.
func Rect(r, θ float64) complex128 { func Rect(r, θ float64) complex128 {
s, c := math.Sincos(θ) s, c := math.Sincos(θ)
return cmplx(r*c, r*s) return complex(r*c, r*s)
} }

View File

@ -53,7 +53,7 @@ import "math"
func Sin(x complex128) complex128 { func Sin(x complex128) complex128 {
s, c := math.Sincos(real(x)) s, c := math.Sincos(real(x))
sh, ch := sinhcosh(imag(x)) sh, ch := sinhcosh(imag(x))
return cmplx(s*ch, c*sh) return complex(s*ch, c*sh)
} }
// Complex hyperbolic sine // Complex hyperbolic sine
@ -73,7 +73,7 @@ func Sin(x complex128) complex128 {
func Sinh(x complex128) complex128 { func Sinh(x complex128) complex128 {
s, c := math.Sincos(imag(x)) s, c := math.Sincos(imag(x))
sh, ch := sinhcosh(real(x)) sh, ch := sinhcosh(real(x))
return cmplx(c*sh, s*ch) return complex(c*sh, s*ch)
} }
// Complex circular cosine // Complex circular cosine
@ -98,7 +98,7 @@ func Sinh(x complex128) complex128 {
func Cos(x complex128) complex128 { func Cos(x complex128) complex128 {
s, c := math.Sincos(real(x)) s, c := math.Sincos(real(x))
sh, ch := sinhcosh(imag(x)) sh, ch := sinhcosh(imag(x))
return cmplx(c*ch, -s*sh) return complex(c*ch, -s*sh)
} }
// Complex hyperbolic cosine // Complex hyperbolic cosine
@ -117,7 +117,7 @@ func Cos(x complex128) complex128 {
func Cosh(x complex128) complex128 { func Cosh(x complex128) complex128 {
s, c := math.Sincos(imag(x)) s, c := math.Sincos(imag(x))
sh, ch := sinhcosh(real(x)) sh, ch := sinhcosh(real(x))
return cmplx(c*ch, s*sh) return complex(c*ch, s*sh)
} }
// calculate sinh and cosh // calculate sinh and cosh

View File

@ -57,20 +57,20 @@ import "math"
func Sqrt(x complex128) complex128 { func Sqrt(x complex128) complex128 {
if imag(x) == 0 { if imag(x) == 0 {
if real(x) == 0 { if real(x) == 0 {
return cmplx(0, 0) return complex(0, 0)
} }
if real(x) < 0 { if real(x) < 0 {
return cmplx(0, math.Sqrt(-real(x))) return complex(0, math.Sqrt(-real(x)))
} }
return cmplx(math.Sqrt(real(x)), 0) return complex(math.Sqrt(real(x)), 0)
} }
if real(x) == 0 { if real(x) == 0 {
if imag(x) < 0 { if imag(x) < 0 {
r := math.Sqrt(-0.5 * imag(x)) r := math.Sqrt(-0.5 * imag(x))
return cmplx(r, -r) return complex(r, -r)
} }
r := math.Sqrt(0.5 * imag(x)) r := math.Sqrt(0.5 * imag(x))
return cmplx(r, r) return complex(r, r)
} }
a := real(x) a := real(x)
b := imag(x) b := imag(x)
@ -97,7 +97,7 @@ func Sqrt(x complex128) complex128 {
r *= scale r *= scale
} }
if b < 0 { if b < 0 {
return cmplx(t, -r) return complex(t, -r)
} }
return cmplx(t, r) return complex(t, r)
} }

View File

@ -64,7 +64,7 @@ func Tan(x complex128) complex128 {
if d == 0 { if d == 0 {
return Inf() return Inf()
} }
return cmplx(math.Sin(2*real(x))/d, math.Sinh(2*imag(x))/d) return complex(math.Sin(2*real(x))/d, math.Sinh(2*imag(x))/d)
} }
// Complex hyperbolic tangent // Complex hyperbolic tangent
@ -85,7 +85,7 @@ func Tanh(x complex128) complex128 {
if d == 0 { if d == 0 {
return Inf() return Inf()
} }
return cmplx(math.Sinh(2*real(x))/d, math.Sin(2*imag(x))/d) return complex(math.Sinh(2*real(x))/d, math.Sin(2*imag(x))/d)
} }
// Program to subtract nearest integer multiple of PI // Program to subtract nearest integer multiple of PI
@ -114,11 +114,11 @@ func tanSeries(z complex128) float64 {
x = reducePi(x) x = reducePi(x)
x = x * x x = x * x
y = y * y y = y * y
x2 := float64(1) x2 := 1.0
y2 := float64(1) y2 := 1.0
f := float64(1) f := 1.0
rn := float64(0) rn := 0.0
d := float64(0) d := 0.0
for { for {
rn += 1 rn += 1
f *= rn f *= rn
@ -180,5 +180,5 @@ func Cot(x complex128) complex128 {
if d == 0 { if d == 0 {
return Inf() return Inf()
} }
return cmplx(math.Sin(2*real(x))/d, -math.Sinh(2*imag(x))/d) return complex(math.Sin(2*real(x))/d, -math.Sinh(2*imag(x))/d)
} }

View File

@ -89,6 +89,10 @@ type compressor struct {
// (1 << logWindowSize) - 1. // (1 << logWindowSize) - 1.
windowMask int windowMask int
eof bool // has eof been reached on input?
sync bool // writer wants to flush
syncChan chan os.Error
// hashHead[hashValue] contains the largest inputIndex with the specified hash value // hashHead[hashValue] contains the largest inputIndex with the specified hash value
hashHead []int hashHead []int
@ -124,6 +128,9 @@ func (d *compressor) flush() os.Error {
} }
func (d *compressor) fillWindow(index int) (int, os.Error) { func (d *compressor) fillWindow(index int) (int, os.Error) {
if d.sync {
return index, nil
}
wSize := d.windowMask + 1 wSize := d.windowMask + 1
if index >= wSize+wSize-(minMatchLength+maxMatchLength) { if index >= wSize+wSize-(minMatchLength+maxMatchLength) {
// shift the window by wSize // shift the window by wSize
@ -142,12 +149,14 @@ func (d *compressor) fillWindow(index int) (int, os.Error) {
d.hashPrev[i] = max(h-wSize, -1) d.hashPrev[i] = max(h-wSize, -1)
} }
} }
var count int count, err := d.r.Read(d.window[d.windowEnd:])
var err os.Error
count, err = io.ReadAtLeast(d.r, d.window[d.windowEnd:], 1)
d.windowEnd += count d.windowEnd += count
if count == 0 && err == nil {
d.sync = true
}
if err == os.EOF { if err == os.EOF {
return index, nil d.eof = true
err = nil
} }
return index, err return index, err
} }
@ -227,10 +236,17 @@ func (d *compressor) storedDeflate() os.Error {
buf := make([]byte, maxStoreBlockSize) buf := make([]byte, maxStoreBlockSize)
for { for {
n, err := d.r.Read(buf) n, err := d.r.Read(buf)
if n > 0 { if n == 0 && err == nil {
d.sync = true
}
if n > 0 || d.sync {
if err := d.writeStoredBlock(buf[0:n]); err != nil { if err := d.writeStoredBlock(buf[0:n]); err != nil {
return err return err
} }
if d.sync {
d.syncChan <- nil
d.sync = false
}
} }
if err != nil { if err != nil {
if err == os.EOF { if err == os.EOF {
@ -275,6 +291,7 @@ func (d *compressor) doDeflate() (err os.Error) {
hash = int(d.window[index])<<hashShift + int(d.window[index+1]) hash = int(d.window[index])<<hashShift + int(d.window[index+1])
} }
chainHead := -1 chainHead := -1
Loop:
for { for {
if index > windowEnd { if index > windowEnd {
panic("index > windowEnd") panic("index > windowEnd")
@ -291,7 +308,31 @@ func (d *compressor) doDeflate() (err os.Error) {
maxInsertIndex = windowEnd - (minMatchLength - 1) maxInsertIndex = windowEnd - (minMatchLength - 1)
lookahead = windowEnd - index lookahead = windowEnd - index
if lookahead == 0 { if lookahead == 0 {
break // Flush current output block if any.
if byteAvailable {
// There is still one pending token that needs to be flushed
tokens[ti] = literalToken(uint32(d.window[index-1]) & 0xFF)
ti++
byteAvailable = false
}
if ti > 0 {
if err = d.writeBlock(tokens[0:ti], index, false); err != nil {
return
}
ti = 0
}
if d.sync {
d.w.writeStoredHeader(0, false)
d.w.flush()
d.syncChan <- d.w.err
d.sync = false
}
// If this was only a sync (not at EOF) keep going.
if !d.eof {
continue
}
break Loop
} }
} }
if index < maxInsertIndex { if index < maxInsertIndex {
@ -383,23 +424,11 @@ func (d *compressor) doDeflate() (err os.Error) {
byteAvailable = true byteAvailable = true
} }
} }
}
if byteAvailable {
// There is still one pending token that needs to be flushed
tokens[ti] = literalToken(uint32(d.window[index-1]) & 0xFF)
ti++
}
if ti > 0 {
if err = d.writeBlock(tokens[0:ti], index, false); err != nil {
return
}
} }
return return
} }
func (d *compressor) compressor(r io.Reader, w io.Writer, level int, logWindowSize uint) (err os.Error) { func (d *compressor) compress(r io.Reader, w io.Writer, level int, logWindowSize uint) (err os.Error) {
d.r = r d.r = r
d.w = newHuffmanBitWriter(w) d.w = newHuffmanBitWriter(w)
d.level = level d.level = level
@ -417,6 +446,10 @@ func (d *compressor) compressor(r io.Reader, w io.Writer, level int, logWindowSi
return WrongValueError{"level", 0, 9, int32(level)} return WrongValueError{"level", 0, 9, int32(level)}
} }
if d.sync {
d.syncChan <- err
d.sync = false
}
if err != nil { if err != nil {
return err return err
} }
@ -426,16 +459,63 @@ func (d *compressor) compressor(r io.Reader, w io.Writer, level int, logWindowSi
return d.flush() return d.flush()
} }
func newCompressor(w io.Writer, level int, logWindowSize uint) io.WriteCloser { // NewWriter returns a new Writer compressing
// data at the given level. Following zlib, levels
// range from 1 (BestSpeed) to 9 (BestCompression);
// higher levels typically run slower but compress more.
// Level 0 (NoCompression) does not attempt any
// compression; it only adds the necessary DEFLATE framing.
func NewWriter(w io.Writer, level int) *Writer {
const logWindowSize = logMaxOffsetSize
var d compressor var d compressor
d.syncChan = make(chan os.Error, 1)
pr, pw := syncPipe() pr, pw := syncPipe()
go func() { go func() {
err := d.compressor(pr, w, level, logWindowSize) err := d.compress(pr, w, level, logWindowSize)
pr.CloseWithError(err) pr.CloseWithError(err)
}() }()
return pw return &Writer{pw, &d}
} }
func NewWriter(w io.Writer, level int) io.WriteCloser { // A Writer takes data written to it and writes the compressed
return newCompressor(w, level, logMaxOffsetSize) // form of that data to an underlying writer (see NewWriter).
type Writer struct {
w *syncPipeWriter
d *compressor
}
// Write writes data to w, which will eventually write the
// compressed form of data to its underlying writer.
func (w *Writer) Write(data []byte) (n int, err os.Error) {
if len(data) == 0 {
// no point, and nil interferes with sync
return
}
return w.w.Write(data)
}
// Flush flushes any pending compressed data to the underlying writer.
// It is useful mainly in compressed network protocols, to ensure that
// a remote reader has enough data to reconstruct a packet.
// Flush does not return until the data has been written.
// If the underlying writer returns an error, Flush returns that error.
//
// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH.
func (w *Writer) Flush() os.Error {
// For more about flushing:
// http://www.bolet.org/~pornin/deflate-flush.html
if w.d.sync {
panic("compress/flate: double Flush")
}
_, err := w.w.Write(nil)
err1 := <-w.d.syncChan
if err == nil {
err = err1
}
return err
}
// Close flushes and closes the writer.
func (w *Writer) Close() os.Error {
return w.w.Close()
} }

View File

@ -7,8 +7,10 @@ package flate
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"os" "os"
"sync"
"testing" "testing"
) )
@ -79,7 +81,7 @@ func getLargeDataChunk() []byte {
func TestDeflate(t *testing.T) { func TestDeflate(t *testing.T) {
for _, h := range deflateTests { for _, h := range deflateTests {
buffer := bytes.NewBuffer([]byte{}) buffer := bytes.NewBuffer(nil)
w := NewWriter(buffer, h.level) w := NewWriter(buffer, h.level)
w.Write(h.in) w.Write(h.in)
w.Close() w.Close()
@ -90,21 +92,144 @@ func TestDeflate(t *testing.T) {
} }
} }
type syncBuffer struct {
buf bytes.Buffer
mu sync.RWMutex
closed bool
ready chan bool
}
func newSyncBuffer() *syncBuffer {
return &syncBuffer{ready: make(chan bool, 1)}
}
func (b *syncBuffer) Read(p []byte) (n int, err os.Error) {
for {
b.mu.RLock()
n, err = b.buf.Read(p)
b.mu.RUnlock()
if n > 0 || b.closed {
return
}
<-b.ready
}
panic("unreachable")
}
func (b *syncBuffer) Write(p []byte) (n int, err os.Error) {
n, err = b.buf.Write(p)
_ = b.ready <- true
return
}
func (b *syncBuffer) WriteMode() {
b.mu.Lock()
}
func (b *syncBuffer) ReadMode() {
b.mu.Unlock()
_ = b.ready <- true
}
func (b *syncBuffer) Close() os.Error {
b.closed = true
_ = b.ready <- true
return nil
}
func testSync(t *testing.T, level int, input []byte, name string) {
if len(input) == 0 {
return
}
t.Logf("--testSync %d, %d, %s", level, len(input), name)
buf := newSyncBuffer()
buf1 := new(bytes.Buffer)
buf.WriteMode()
w := NewWriter(io.MultiWriter(buf, buf1), level)
r := NewReader(buf)
// Write half the input and read back.
for i := 0; i < 2; i++ {
var lo, hi int
if i == 0 {
lo, hi = 0, (len(input)+1)/2
} else {
lo, hi = (len(input)+1)/2, len(input)
}
t.Logf("#%d: write %d-%d", i, lo, hi)
if _, err := w.Write(input[lo:hi]); err != nil {
t.Errorf("testSync: write: %v", err)
return
}
if i == 0 {
if err := w.Flush(); err != nil {
t.Errorf("testSync: flush: %v", err)
return
}
} else {
if err := w.Close(); err != nil {
t.Errorf("testSync: close: %v", err)
}
}
buf.ReadMode()
out := make([]byte, hi-lo+1)
m, err := io.ReadAtLeast(r, out, hi-lo)
t.Logf("#%d: read %d", i, m)
if m != hi-lo || err != nil {
t.Errorf("testSync/%d (%d, %d, %s): read %d: %d, %v (%d left)", i, level, len(input), name, hi-lo, m, err, buf.buf.Len())
return
}
if !bytes.Equal(input[lo:hi], out[:hi-lo]) {
t.Errorf("testSync/%d: read wrong bytes: %x vs %x", i, input[lo:hi], out[:hi-lo])
return
}
if i == 0 && buf.buf.Len() != 0 {
t.Errorf("testSync/%d (%d, %d, %s): extra data after %d", i, level, len(input), name, hi-lo)
}
buf.WriteMode()
}
buf.ReadMode()
out := make([]byte, 10)
if n, err := r.Read(out); n > 0 || err != os.EOF {
t.Errorf("testSync (%d, %d, %s): final Read: %d, %v (hex: %x)", level, len(input), name, n, err, out[0:n])
}
if buf.buf.Len() != 0 {
t.Errorf("testSync (%d, %d, %s): extra data at end", level, len(input), name)
}
r.Close()
// stream should work for ordinary reader too
r = NewReader(buf1)
out, err := ioutil.ReadAll(r)
if err != nil {
t.Errorf("testSync: read: %s", err)
return
}
r.Close()
if !bytes.Equal(input, out) {
t.Errorf("testSync: decompress(compress(data)) != data: level=%d input=%s", level, name)
}
}
func testToFromWithLevel(t *testing.T, level int, input []byte, name string) os.Error { func testToFromWithLevel(t *testing.T, level int, input []byte, name string) os.Error {
buffer := bytes.NewBuffer([]byte{}) buffer := bytes.NewBuffer(nil)
w := NewWriter(buffer, level) w := NewWriter(buffer, level)
w.Write(input) w.Write(input)
w.Close() w.Close()
decompressor := NewReader(buffer) r := NewReader(buffer)
decompressed, err := ioutil.ReadAll(decompressor) out, err := ioutil.ReadAll(r)
if err != nil { if err != nil {
t.Errorf("reading decompressor: %s", err) t.Errorf("read: %s", err)
return err return err
} }
decompressor.Close() r.Close()
if bytes.Compare(input, decompressed) != 0 { if !bytes.Equal(input, out) {
t.Errorf("decompress(compress(data)) != data: level=%d input=%s", level, name) t.Errorf("decompress(compress(data)) != data: level=%d input=%s", level, name)
} }
testSync(t, level, input, name)
return nil return nil
} }

View File

@ -47,7 +47,7 @@ func (e *ReadError) String() string {
// A WriteError reports an error encountered while writing output. // A WriteError reports an error encountered while writing output.
type WriteError struct { type WriteError struct {
Offset int64 // byte offset where error occurred Offset int64 // byte offset where error occurred
Error os.Error // error returned by underlying Read Error os.Error // error returned by underlying Write
} }
func (e *WriteError) String() string { func (e *WriteError) String() string {
@ -217,6 +217,7 @@ type decompressor struct {
// Output history, buffer. // Output history, buffer.
hist [maxHist]byte hist [maxHist]byte
hp int // current output position in buffer hp int // current output position in buffer
hw int // have written hist[0:hw] already
hfull bool // buffer has filled at least once hfull bool // buffer has filled at least once
// Temporary buffer (avoids repeated allocation). // Temporary buffer (avoids repeated allocation).
@ -497,6 +498,11 @@ func (f *decompressor) dataBlock() os.Error {
return CorruptInputError(f.roffset) return CorruptInputError(f.roffset)
} }
if n == 0 {
// 0-length block means sync
return f.flush()
}
// Read len bytes into history, // Read len bytes into history,
// writing as history fills. // writing as history fills.
for n > 0 { for n > 0 {
@ -560,19 +566,23 @@ func (f *decompressor) huffSym(h *huffmanDecoder) (int, os.Error) {
// Flush any buffered output to the underlying writer. // Flush any buffered output to the underlying writer.
func (f *decompressor) flush() os.Error { func (f *decompressor) flush() os.Error {
if f.hp == 0 { if f.hw == f.hp {
return nil return nil
} }
n, err := f.w.Write(f.hist[0:f.hp]) n, err := f.w.Write(f.hist[f.hw:f.hp])
if n != f.hp && err == nil { if n != f.hp-f.hw && err == nil {
err = io.ErrShortWrite err = io.ErrShortWrite
} }
if err != nil { if err != nil {
return &WriteError{f.woffset, err} return &WriteError{f.woffset, err}
} }
f.woffset += int64(f.hp) f.woffset += int64(f.hp - f.hw)
f.hp = 0 f.hw = f.hp
f.hfull = true if f.hp == len(f.hist) {
f.hp = 0
f.hw = 0
f.hfull = true
}
return nil return nil
} }
@ -583,9 +593,9 @@ func makeReader(r io.Reader) Reader {
return bufio.NewReader(r) return bufio.NewReader(r)
} }
// Inflate reads DEFLATE-compressed data from r and writes // decompress reads DEFLATE-compressed data from r and writes
// the uncompressed data to w. // the uncompressed data to w.
func (f *decompressor) decompressor(r io.Reader, w io.Writer) os.Error { func (f *decompressor) decompress(r io.Reader, w io.Writer) os.Error {
f.r = makeReader(r) f.r = makeReader(r)
f.w = w f.w = w
f.woffset = 0 f.woffset = 0
@ -605,6 +615,6 @@ func (f *decompressor) decompressor(r io.Reader, w io.Writer) os.Error {
func NewReader(r io.Reader) io.ReadCloser { func NewReader(r io.Reader) io.ReadCloser {
var f decompressor var f decompressor
pr, pw := io.Pipe() pr, pw := io.Pipe()
go func() { pw.CloseWithError(f.decompressor(r, pw)) }() go func() { pw.CloseWithError(f.decompress(r, pw)) }()
return pr return pr
} }

View File

@ -127,59 +127,59 @@ func TestIntInsertDeleteClear(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: A) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: A) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: A) wrong len() %d (expected %d)", a, len(a), i)
} }
a.Insert(0, int2IntValue(val(i))) a.Insert(0, int2IntValue(val(i)))
if elem2IntValue(a.Last()) != int2IntValue(val(0)) { if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
t.Error("T%: B", a) t.Errorf("%T: B", a)
} }
} }
for i := n - 1; i >= 0; i-- { for i := n - 1; i >= 0; i-- {
if elem2IntValue(a.Last()) != int2IntValue(val(0)) { if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
t.Error("T%: C", a) t.Errorf("%T: C", a)
} }
if elem2IntValue(a.At(0)) != int2IntValue(val(i)) { if elem2IntValue(a.At(0)) != int2IntValue(val(i)) {
t.Error("T%: D", a) t.Errorf("%T: D", a)
} }
if elem2IntValue(a[0]) != int2IntValue(val(i)) { if elem2IntValue(a[0]) != int2IntValue(val(i)) {
t.Error("T%: D2", a) t.Errorf("%T: D2", a)
} }
a.Delete(0) a.Delete(0)
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: E) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: E) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: E) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: E) wrong len() %d (expected %d)", a, len(a), i)
} }
} }
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: F) wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: F) wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: F) wrong len() %d (expected 0)", a, len(a))
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
a.Push(int2IntValue(val(i))) a.Push(int2IntValue(val(i)))
if a.Len() != i+1 { if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1) t.Errorf("%T: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
} }
if len(a) != i+1 { if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1) t.Errorf("%T: G) wrong len() %d (expected %d)", a, len(a), i+1)
} }
if elem2IntValue(a.Last()) != int2IntValue(val(i)) { if elem2IntValue(a.Last()) != int2IntValue(val(i)) {
t.Error("T%: H", a) t.Errorf("%T: H", a)
} }
} }
a.Resize(0, 0) a.Resize(0, 0)
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: I wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: I wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: I wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: I wrong len() %d (expected 0)", a, len(a))
} }
const m = 5 const m = 5
@ -189,21 +189,21 @@ func TestIntInsertDeleteClear(t *testing.T) {
x := val(i) x := val(i)
a.Push(int2IntValue(x)) a.Push(int2IntValue(x))
if elem2IntValue(a.Pop()) != int2IntValue(x) { if elem2IntValue(a.Pop()) != int2IntValue(x) {
t.Error("T%: J", a) t.Errorf("%T: J", a)
} }
if a.Len() != j+1 { if a.Len() != j+1 {
t.Errorf("T%: K) wrong Len() %d (expected %d)", a, a.Len(), j+1) t.Errorf("%T: K) wrong Len() %d (expected %d)", a, a.Len(), j+1)
} }
if len(a) != j+1 { if len(a) != j+1 {
t.Errorf("T%: K) wrong len() %d (expected %d)", a, len(a), j+1) t.Errorf("%T: K) wrong len() %d (expected %d)", a, len(a), j+1)
} }
} }
} }
if a.Len() != m { if a.Len() != m {
t.Errorf("T%: L) wrong Len() %d (expected %d)", a, a.Len(), m) t.Errorf("%T: L) wrong Len() %d (expected %d)", a, a.Len(), m)
} }
if len(a) != m { if len(a) != m {
t.Errorf("T%: L) wrong len() %d (expected %d)", a, len(a), m) t.Errorf("%T: L) wrong len() %d (expected %d)", a, len(a), m)
} }
} }
@ -211,14 +211,14 @@ func TestIntInsertDeleteClear(t *testing.T) {
func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) { func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) {
for k := i; k < j; k++ { for k := i; k < j; k++ {
if elem2IntValue(x.At(k)) != int2IntValue(elt) { if elem2IntValue(x.At(k)) != int2IntValue(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt)) t.Errorf("%T: M) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt))
} }
} }
s := x.Slice(i, j) s := x.Slice(i, j)
for k, n := 0, j-i; k < n; k++ { for k, n := 0, j-i; k < n; k++ {
if elem2IntValue(s.At(k)) != int2IntValue(elt) { if elem2IntValue(s.At(k)) != int2IntValue(elt) {
t.Errorf("T%: N) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt)) t.Errorf("%T: N) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt))
} }
} }
} }
@ -227,10 +227,10 @@ func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) {
func verify_patternInt(t *testing.T, x *IntVector, a, b, c int) { func verify_patternInt(t *testing.T, x *IntVector, a, b, c int) {
n := a + b + c n := a + b + c
if x.Len() != n { if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n) t.Errorf("%T: O) wrong Len() %d (expected %d)", x, x.Len(), n)
} }
if len(*x) != n { if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n) t.Errorf("%T: O) wrong len() %d (expected %d)", x, len(*x), n)
} }
verify_sliceInt(t, x, 0, 0, a) verify_sliceInt(t, x, 0, 0, a)
verify_sliceInt(t, x, 1, a, a+b) verify_sliceInt(t, x, 1, a, a+b)

View File

@ -20,7 +20,7 @@ func s(n uint64) string {
lens := len(str) lens := len(str)
a := make([]string, (lens+2)/3) a := make([]string, (lens+2)/3)
start := lens start := lens
for i, _ := range a { for i := range a {
start -= 3 start -= 3
if start < 0 { if start < 0 {
start = 0 start = 0
@ -46,7 +46,7 @@ func TestVectorNums(t *testing.T) {
v.Resize(0, 0) v.Resize(0, 0)
runtime.GC() runtime.GC()
n := m.Alloc - m0.Alloc n := m.Alloc - m0.Alloc
t.Logf("%T.Push(%#v), n = %s: Alloc/n = %.2f\n", v, c, s(memTestN), float(n)/memTestN) t.Logf("%T.Push(%#v), n = %s: Alloc/n = %.2f\n", v, c, s(memTestN), float64(n)/memTestN)
} }
@ -64,7 +64,7 @@ func TestIntVectorNums(t *testing.T) {
v.Resize(0, 0) v.Resize(0, 0)
runtime.GC() runtime.GC()
n := m.Alloc - m0.Alloc n := m.Alloc - m0.Alloc
t.Logf("%T.Push(%#v), n = %s: Alloc/n = %.2f\n", v, c, s(memTestN), float(n)/memTestN) t.Logf("%T.Push(%#v), n = %s: Alloc/n = %.2f\n", v, c, s(memTestN), float64(n)/memTestN)
} }
@ -82,7 +82,7 @@ func TestStringVectorNums(t *testing.T) {
v.Resize(0, 0) v.Resize(0, 0)
runtime.GC() runtime.GC()
n := m.Alloc - m0.Alloc n := m.Alloc - m0.Alloc
t.Logf("%T.Push(%#v), n = %s: Alloc/n = %.2f\n", v, c, s(memTestN), float(n)/memTestN) t.Logf("%T.Push(%#v), n = %s: Alloc/n = %.2f\n", v, c, s(memTestN), float64(n)/memTestN)
} }

View File

@ -127,59 +127,59 @@ func TestStrInsertDeleteClear(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: A) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: A) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: A) wrong len() %d (expected %d)", a, len(a), i)
} }
a.Insert(0, int2StrValue(val(i))) a.Insert(0, int2StrValue(val(i)))
if elem2StrValue(a.Last()) != int2StrValue(val(0)) { if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
t.Error("T%: B", a) t.Errorf("%T: B", a)
} }
} }
for i := n - 1; i >= 0; i-- { for i := n - 1; i >= 0; i-- {
if elem2StrValue(a.Last()) != int2StrValue(val(0)) { if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
t.Error("T%: C", a) t.Errorf("%T: C", a)
} }
if elem2StrValue(a.At(0)) != int2StrValue(val(i)) { if elem2StrValue(a.At(0)) != int2StrValue(val(i)) {
t.Error("T%: D", a) t.Errorf("%T: D", a)
} }
if elem2StrValue(a[0]) != int2StrValue(val(i)) { if elem2StrValue(a[0]) != int2StrValue(val(i)) {
t.Error("T%: D2", a) t.Errorf("%T: D2", a)
} }
a.Delete(0) a.Delete(0)
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: E) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: E) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: E) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: E) wrong len() %d (expected %d)", a, len(a), i)
} }
} }
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: F) wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: F) wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: F) wrong len() %d (expected 0)", a, len(a))
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
a.Push(int2StrValue(val(i))) a.Push(int2StrValue(val(i)))
if a.Len() != i+1 { if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1) t.Errorf("%T: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
} }
if len(a) != i+1 { if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1) t.Errorf("%T: G) wrong len() %d (expected %d)", a, len(a), i+1)
} }
if elem2StrValue(a.Last()) != int2StrValue(val(i)) { if elem2StrValue(a.Last()) != int2StrValue(val(i)) {
t.Error("T%: H", a) t.Errorf("%T: H", a)
} }
} }
a.Resize(0, 0) a.Resize(0, 0)
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: I wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: I wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: I wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: I wrong len() %d (expected 0)", a, len(a))
} }
const m = 5 const m = 5
@ -189,21 +189,21 @@ func TestStrInsertDeleteClear(t *testing.T) {
x := val(i) x := val(i)
a.Push(int2StrValue(x)) a.Push(int2StrValue(x))
if elem2StrValue(a.Pop()) != int2StrValue(x) { if elem2StrValue(a.Pop()) != int2StrValue(x) {
t.Error("T%: J", a) t.Errorf("%T: J", a)
} }
if a.Len() != j+1 { if a.Len() != j+1 {
t.Errorf("T%: K) wrong Len() %d (expected %d)", a, a.Len(), j+1) t.Errorf("%T: K) wrong Len() %d (expected %d)", a, a.Len(), j+1)
} }
if len(a) != j+1 { if len(a) != j+1 {
t.Errorf("T%: K) wrong len() %d (expected %d)", a, len(a), j+1) t.Errorf("%T: K) wrong len() %d (expected %d)", a, len(a), j+1)
} }
} }
} }
if a.Len() != m { if a.Len() != m {
t.Errorf("T%: L) wrong Len() %d (expected %d)", a, a.Len(), m) t.Errorf("%T: L) wrong Len() %d (expected %d)", a, a.Len(), m)
} }
if len(a) != m { if len(a) != m {
t.Errorf("T%: L) wrong len() %d (expected %d)", a, len(a), m) t.Errorf("%T: L) wrong len() %d (expected %d)", a, len(a), m)
} }
} }
@ -211,14 +211,14 @@ func TestStrInsertDeleteClear(t *testing.T) {
func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) { func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) {
for k := i; k < j; k++ { for k := i; k < j; k++ {
if elem2StrValue(x.At(k)) != int2StrValue(elt) { if elem2StrValue(x.At(k)) != int2StrValue(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt)) t.Errorf("%T: M) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt))
} }
} }
s := x.Slice(i, j) s := x.Slice(i, j)
for k, n := 0, j-i; k < n; k++ { for k, n := 0, j-i; k < n; k++ {
if elem2StrValue(s.At(k)) != int2StrValue(elt) { if elem2StrValue(s.At(k)) != int2StrValue(elt) {
t.Errorf("T%: N) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt)) t.Errorf("%T: N) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt))
} }
} }
} }
@ -227,10 +227,10 @@ func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) {
func verify_patternStr(t *testing.T, x *StringVector, a, b, c int) { func verify_patternStr(t *testing.T, x *StringVector, a, b, c int) {
n := a + b + c n := a + b + c
if x.Len() != n { if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n) t.Errorf("%T: O) wrong Len() %d (expected %d)", x, x.Len(), n)
} }
if len(*x) != n { if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n) t.Errorf("%T: O) wrong len() %d (expected %d)", x, len(*x), n)
} }
verify_sliceStr(t, x, 0, 0, a) verify_sliceStr(t, x, 0, 0, a)
verify_sliceStr(t, x, 1, a, a+b) verify_sliceStr(t, x, 1, a, a+b)

View File

@ -127,59 +127,59 @@ func TestInsertDeleteClear(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: A) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: A) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: A) wrong len() %d (expected %d)", a, len(a), i)
} }
a.Insert(0, int2Value(val(i))) a.Insert(0, int2Value(val(i)))
if elem2Value(a.Last()) != int2Value(val(0)) { if elem2Value(a.Last()) != int2Value(val(0)) {
t.Error("T%: B", a) t.Errorf("%T: B", a)
} }
} }
for i := n - 1; i >= 0; i-- { for i := n - 1; i >= 0; i-- {
if elem2Value(a.Last()) != int2Value(val(0)) { if elem2Value(a.Last()) != int2Value(val(0)) {
t.Error("T%: C", a) t.Errorf("%T: C", a)
} }
if elem2Value(a.At(0)) != int2Value(val(i)) { if elem2Value(a.At(0)) != int2Value(val(i)) {
t.Error("T%: D", a) t.Errorf("%T: D", a)
} }
if elem2Value(a[0]) != int2Value(val(i)) { if elem2Value(a[0]) != int2Value(val(i)) {
t.Error("T%: D2", a) t.Errorf("%T: D2", a)
} }
a.Delete(0) a.Delete(0)
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: E) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: E) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: E) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: E) wrong len() %d (expected %d)", a, len(a), i)
} }
} }
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: F) wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: F) wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: F) wrong len() %d (expected 0)", a, len(a))
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
a.Push(int2Value(val(i))) a.Push(int2Value(val(i)))
if a.Len() != i+1 { if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1) t.Errorf("%T: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
} }
if len(a) != i+1 { if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1) t.Errorf("%T: G) wrong len() %d (expected %d)", a, len(a), i+1)
} }
if elem2Value(a.Last()) != int2Value(val(i)) { if elem2Value(a.Last()) != int2Value(val(i)) {
t.Error("T%: H", a) t.Errorf("%T: H", a)
} }
} }
a.Resize(0, 0) a.Resize(0, 0)
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: I wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: I wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: I wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: I wrong len() %d (expected 0)", a, len(a))
} }
const m = 5 const m = 5
@ -189,21 +189,21 @@ func TestInsertDeleteClear(t *testing.T) {
x := val(i) x := val(i)
a.Push(int2Value(x)) a.Push(int2Value(x))
if elem2Value(a.Pop()) != int2Value(x) { if elem2Value(a.Pop()) != int2Value(x) {
t.Error("T%: J", a) t.Errorf("%T: J", a)
} }
if a.Len() != j+1 { if a.Len() != j+1 {
t.Errorf("T%: K) wrong Len() %d (expected %d)", a, a.Len(), j+1) t.Errorf("%T: K) wrong Len() %d (expected %d)", a, a.Len(), j+1)
} }
if len(a) != j+1 { if len(a) != j+1 {
t.Errorf("T%: K) wrong len() %d (expected %d)", a, len(a), j+1) t.Errorf("%T: K) wrong len() %d (expected %d)", a, len(a), j+1)
} }
} }
} }
if a.Len() != m { if a.Len() != m {
t.Errorf("T%: L) wrong Len() %d (expected %d)", a, a.Len(), m) t.Errorf("%T: L) wrong Len() %d (expected %d)", a, a.Len(), m)
} }
if len(a) != m { if len(a) != m {
t.Errorf("T%: L) wrong len() %d (expected %d)", a, len(a), m) t.Errorf("%T: L) wrong len() %d (expected %d)", a, len(a), m)
} }
} }
@ -211,14 +211,14 @@ func TestInsertDeleteClear(t *testing.T) {
func verify_slice(t *testing.T, x *Vector, elt, i, j int) { func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
for k := i; k < j; k++ { for k := i; k < j; k++ {
if elem2Value(x.At(k)) != int2Value(elt) { if elem2Value(x.At(k)) != int2Value(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt)) t.Errorf("%T: M) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt))
} }
} }
s := x.Slice(i, j) s := x.Slice(i, j)
for k, n := 0, j-i; k < n; k++ { for k, n := 0, j-i; k < n; k++ {
if elem2Value(s.At(k)) != int2Value(elt) { if elem2Value(s.At(k)) != int2Value(elt) {
t.Errorf("T%: N) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt)) t.Errorf("%T: N) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt))
} }
} }
} }
@ -227,10 +227,10 @@ func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
func verify_pattern(t *testing.T, x *Vector, a, b, c int) { func verify_pattern(t *testing.T, x *Vector, a, b, c int) {
n := a + b + c n := a + b + c
if x.Len() != n { if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n) t.Errorf("%T: O) wrong Len() %d (expected %d)", x, x.Len(), n)
} }
if len(*x) != n { if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n) t.Errorf("%T: O) wrong len() %d (expected %d)", x, len(*x), n)
} }
verify_slice(t, x, 0, 0, a) verify_slice(t, x, 0, 0, a)
verify_slice(t, x, 1, a, a+b) verify_slice(t, x, 1, a, a+b)

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// The block package is deprecated, use cipher instead.
// The block package implements standard block cipher modes // The block package implements standard block cipher modes
// that can be wrapped around low-level block cipher implementations. // that can be wrapped around low-level block cipher implementations.
// See http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html // See http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html

View File

@ -0,0 +1,78 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Cipher block chaining (CBC) mode.
// CBC provides confidentiality by xoring (chaining) each plaintext block
// with the previous ciphertext block before applying the block cipher.
// See NIST SP 800-38A, pp 10-11
package cipher
type cbc struct {
b Block
blockSize int
iv []byte
tmp []byte
}
func newCBC(b Block, iv []byte) *cbc {
return &cbc{
b: b,
blockSize: b.BlockSize(),
iv: dup(iv),
tmp: make([]byte, b.BlockSize()),
}
}
type cbcEncrypter cbc
// NewCBCEncrypter returns a BlockMode which encrypts in cipher block chaining
// mode, using the given Block. The length of iv must be the same as the
// Block's block size.
func NewCBCEncrypter(b Block, iv []byte) BlockMode {
return (*cbcEncrypter)(newCBC(b, iv))
}
func (x *cbcEncrypter) BlockSize() int { return x.blockSize }
func (x *cbcEncrypter) CryptBlocks(dst, src []byte) {
for len(src) > 0 {
for i := 0; i < x.blockSize; i++ {
x.iv[i] ^= src[i]
}
x.b.Encrypt(x.iv, x.iv)
for i := 0; i < x.blockSize; i++ {
dst[i] = x.iv[i]
}
src = src[x.blockSize:]
dst = dst[x.blockSize:]
}
}
type cbcDecrypter cbc
// NewCBCDecrypter returns a BlockMode which decrypts in cipher block chaining
// mode, using the given Block. The length of iv must be the same as the
// Block's block size as must match the iv used to encrypt the data.
func NewCBCDecrypter(b Block, iv []byte) BlockMode {
return (*cbcDecrypter)(newCBC(b, iv))
}
func (x *cbcDecrypter) BlockSize() int { return x.blockSize }
func (x *cbcDecrypter) CryptBlocks(dst, src []byte) {
for len(src) > 0 {
x.b.Decrypt(x.tmp, src[:x.blockSize])
for i := 0; i < x.blockSize; i++ {
x.tmp[i] ^= x.iv[i]
x.iv[i] = src[i]
dst[i] = x.tmp[i]
}
src = src[x.blockSize:]
dst = dst[x.blockSize:]
}
}

View File

@ -8,24 +8,21 @@
// Special Publication 800-38A, ``Recommendation for Block Cipher // Special Publication 800-38A, ``Recommendation for Block Cipher
// Modes of Operation,'' 2001 Edition, pp. 24-29. // Modes of Operation,'' 2001 Edition, pp. 24-29.
package block package cipher
import ( import (
"bytes" "bytes"
"crypto/aes" "crypto/aes"
"io"
"testing" "testing"
) )
type cbcTest struct { var cbcAESTests = []struct {
name string name string
key []byte key []byte
iv []byte iv []byte
in []byte in []byte
out []byte out []byte
} }{
var cbcAESTests = []cbcTest{
// NIST SP 800-38A pp 27-29 // NIST SP 800-38A pp 27-29
{ {
"CBC-AES128", "CBC-AES128",
@ -75,28 +72,18 @@ func TestCBC_AES(t *testing.T) {
continue continue
} }
var crypt bytes.Buffer encrypter := NewCBCEncrypter(c, tt.iv)
w := NewCBCEncrypter(c, tt.iv, &crypt) d := make([]byte, len(tt.in))
var r io.Reader = bytes.NewBuffer(tt.in) encrypter.CryptBlocks(d, tt.in)
n, err := io.Copy(w, r) if !bytes.Equal(tt.out, d) {
if n != int64(len(tt.in)) || err != nil {
t.Errorf("%s: CBCEncrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in))
} else if d := crypt.Bytes(); !same(tt.out, d) {
t.Errorf("%s: CBCEncrypter\nhave %x\nwant %x", test, d, tt.out) t.Errorf("%s: CBCEncrypter\nhave %x\nwant %x", test, d, tt.out)
} }
var plain bytes.Buffer decrypter := NewCBCDecrypter(c, tt.iv)
r = NewCBCDecrypter(c, tt.iv, bytes.NewBuffer(tt.out)) p := make([]byte, len(d))
w = &plain decrypter.CryptBlocks(p, d)
n, err = io.Copy(w, r) if !bytes.Equal(tt.in, p) {
if n != int64(len(tt.out)) || err != nil {
t.Errorf("%s: CBCDecrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out))
} else if d := plain.Bytes(); !same(tt.in, d) {
t.Errorf("%s: CBCDecrypter\nhave %x\nwant %x", test, d, tt.in) t.Errorf("%s: CBCDecrypter\nhave %x\nwant %x", test, d, tt.in)
} }
if t.Failed() {
break
}
} }
} }

View File

@ -0,0 +1,64 @@
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// CFB (Cipher Feedback) Mode.
package cipher
type cfb struct {
b Block
out []byte
outUsed int
decrypt bool
}
// NewCFBEncrypter returns a Stream which encrypts with cipher feedback mode,
// using the given Block. The iv must be the same length as the Block's block
// size.
func NewCFBEncrypter(block Block, iv []byte) Stream {
return newCFB(block, iv, false)
}
// NewCFBDecrypter returns a Stream which decrypts with cipher feedback mode,
// using the given Block. The iv must be the same length as the Block's block
// size.
func NewCFBDecrypter(block Block, iv []byte) Stream {
return newCFB(block, iv, true)
}
func newCFB(block Block, iv []byte, decrypt bool) Stream {
blockSize := block.BlockSize()
if len(iv) != blockSize {
return nil
}
x := &cfb{
b: block,
out: make([]byte, blockSize),
outUsed: 0,
decrypt: decrypt,
}
block.Encrypt(x.out, iv)
return x
}
func (x *cfb) XORKeyStream(dst, src []byte) {
for i := 0; i < len(src); i++ {
if x.outUsed == len(x.out) {
x.b.Encrypt(x.out, x.out)
x.outUsed = 0
}
if x.decrypt {
t := src[i]
dst[i] = src[i] ^ x.out[x.outUsed]
x.out[x.outUsed] = t
} else {
x.out[x.outUsed] ^= src[i]
dst[i] = x.out[x.outUsed]
}
x.outUsed++
}
}

View File

@ -0,0 +1,35 @@
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cipher
import (
"bytes"
"crypto/aes"
"crypto/rand"
"testing"
)
func TestCFB(t *testing.T) {
block, err := aes.NewCipher(commonKey128)
if err != nil {
t.Error(err)
return
}
plaintext := []byte("this is the plaintext")
iv := make([]byte, block.BlockSize())
rand.Reader.Read(iv)
cfb := NewCFBEncrypter(block, iv)
ciphertext := make([]byte, len(plaintext))
cfb.XORKeyStream(ciphertext, plaintext)
cfbdec := NewCFBDecrypter(block, iv)
plaintextCopy := make([]byte, len(plaintext))
cfbdec.XORKeyStream(plaintextCopy, ciphertext)
if !bytes.Equal(plaintextCopy, plaintext) {
t.Errorf("got: %x, want: %x", plaintextCopy, plaintext)
}
}

View File

@ -0,0 +1,63 @@
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The cipher package implements standard block cipher modes
// that can be wrapped around low-level block cipher implementations.
// See http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html
// and NIST Special Publication 800-38A.
package cipher
// A Block represents an implementation of block cipher
// using a given key. It provides the capability to encrypt
// or decrypt individual blocks. The mode implementations
// extend that capability to streams of blocks.
type Block interface {
// BlockSize returns the cipher's block size.
BlockSize() int
// Encrypt encrypts the first block in src into dst.
// Dst and src may point at the same memory.
Encrypt(dst, src []byte)
// Decrypt decrypts the first block in src into dst.
// Dst and src may point at the same memory.
Decrypt(dst, src []byte)
}
// A Stream represents a stream cipher.
type Stream interface {
// XORKeyStream XORs each byte in the given slice with a byte from the
// cipher's key stream. Dst and src may point to the same memory.
XORKeyStream(dst, src []byte)
}
// A BlockMode represents a block cipher running in a block-based mode (CBC,
// ECB etc).
type BlockMode interface {
// BlockSize returns the mode's block size.
BlockSize() int
// CryptBlocks encrypts or decrypts a number of blocks. The length of
// src must be a multiple of the block size. Dst and src may point to
// the same memory.
CryptBlocks(dst, src []byte)
}
// Utility routines
func shift1(dst, src []byte) byte {
var b byte
for i := len(src) - 1; i >= 0; i-- {
bb := src[i] >> 7
dst[i] = src[i]<<1 | b
b = bb
}
return b
}
func dup(p []byte) []byte {
q := make([]byte, len(p))
copy(q, p)
return q
}

Some files were not shown because too many files have changed in this diff Show More