1
0
mirror of https://github.com/golang/go synced 2024-10-03 13:31:21 -06:00
Commit Graph

1136 Commits

Author SHA1 Message Date
Rob Pike
d9283b27a2 clean up handling of numeric time zones
allow formatting of ruby-style times.

Fixes #518.

R=rsc
CC=golang-dev
https://golang.org/cl/186119
2010-01-14 11:57:38 +11:00
Russ Cox
6ae763a727 vector: drop rule for bench, now in Make.pkg
R=gri
CC=golang-dev
https://golang.org/cl/186139
2010-01-13 13:29:49 -08:00
Russ Cox
f85abf01bc runtime: reset DF flag after running external code on 386
R=r
CC=golang-dev
https://golang.org/cl/186108
2010-01-13 09:08:39 -08:00
Rob Pike
63d639295c don't worry about the number of spaces when parsing.
allow an underscore to stand for a space or digit if the following number is >=10.

R=rsc
CC=golang-dev
https://golang.org/cl/186115
2010-01-13 14:39:30 +11:00
Rob Pike
24dafbaa37 to improve the chances for compatibility, open a window of unused ids
and specify a lowest id granted to users.

R=rsc
CC=golang-dev
https://golang.org/cl/186081
2010-01-13 12:06:43 +11:00
Robert Griesemer
abda9e6f89 Light-weight scanner for general use.
Emphasis on minimal interface and fast scanning.
Recognizes all Go literals by default. Easily
configurable to recognize different whitespace
characters and tokens.

Provides detailed position information for each
token.

R=rsc, r
CC=golang-dev
https://golang.org/cl/181160
2010-01-12 17:04:45 -08:00
Adam Langley
cbd3b2e8d5 Add 'bench' target to makefiles.
R=rsc, agl, r
CC=golang-dev
https://golang.org/cl/188043
2010-01-12 15:43:20 -08:00
Russ Cox
711088106e runtime: fix bug in preemption checks; was causing "lock count" panics
R=r
CC=golang-dev
https://golang.org/cl/186078
2010-01-12 10:03:02 -08:00
Charles L. Dorian
46206c52e3 math: special cases for Ceil, Exp, Floor, Log, Log10
Added special case tests to all_test.go. Added tests to Floor,
in-lined tests in Exp and Log.

R=rsc
CC=golang-dev
https://golang.org/cl/184081
2010-01-11 21:28:02 -08:00
Adam Langley
e7cceb85e4 asn1: fix marshaling of structures with >1 elements.
Fixes #515.

R=rsc
CC=golang-dev
https://golang.org/cl/184079
2010-01-11 18:54:13 -08:00
Adam Langley
72b97e46a3 asn1: fix parsing of elements after a string in a structure.
Fixes #516.

R=rsc
CC=golang-dev, golang-dev
https://golang.org/cl/184080
2010-01-11 18:53:58 -08:00
Charles L. Dorian
3c7534104a math: special cases for Fmod
Added special case tests to all_test.go for Fmod. Fixed Fmod [hung
for Fmod(+/-Inf, <finite>)]. Also added test for Ceil in all_test.go.

R=rsc
CC=golang-dev
https://golang.org/cl/186076
2010-01-11 16:20:51 -08:00
Robert Griesemer
5dee91001b Remove -oldprinter flag from gofmt; all code is
now printed using the semicolon-free style.

Removed NoSemis flag and mechanism dealing with
optional semicolons from go/printer.

Updated all go/printer output files using the
semi-colon free style.

Changes have no formatting impact on checked in
go code under src and misc.

R=rsc, r
CC=golang-dev
https://golang.org/cl/184068
2010-01-11 12:58:13 -08:00
Rob Pike
00e2cda624 Clean up and make consistent the comments in the math package.
R=rsc
CC=golang-dev
https://golang.org/cl/186042
2010-01-12 07:38:31 +11:00
Russ Cox
093146b920 math: fix pow10 comment, test portable Sqrt
R=r
CC= golang-dev, Charlie Dorian, golang-dev
https://golang.org/cl/184058
2010-01-11 11:25:37 -08:00
David Symonds
0ed728c48a Replicate signal names from syscall in os/signal.
R=rsc
CC=golang-dev
https://golang.org/cl/183142
2010-01-11 11:23:46 -08:00
Robert Griesemer
93d81fb747 Partial work-around for gofmt bug.
Addresses some cases and respects position of
closing parenthesis; but doesn't work yet in
all cases. Heuristic; will need to be replaced
by a real solution eventually. Does not cause
existing code to be reformatted.

R=r
CC=golang-dev, rsc
https://golang.org/cl/186043
2010-01-11 10:38:06 -08:00
Charles L. Dorian
5336cd8f91 math: Sqrt using 386 FPU.
Note: sqrt_decl.go already in src/pkg/math/.

R=rsc
CC=golang-dev
https://golang.org/cl/183155
2010-01-10 15:41:07 -08:00
Russ Cox
5328df6534 runtime: check for preemption due to garbage collection
in various already expensive routines.

helps keep cpu utilization up when GOMAXPROCS > 1,
but not a full solution.

http://groups.google.com/group/golang-nuts/t/7a9535c4136d3e2

R=r
CC=golang-dev
https://golang.org/cl/184043
2010-01-09 09:47:45 -08:00
Charles L. Dorian
fd1db67e87 math: special cases for Atan, Asin and Acos
Added tests for NaN and out-of-range values.
Combined asin.go and atan.go into atan.go.

R=rsc
CC=golang-dev
https://golang.org/cl/180065
2010-01-08 14:12:10 -08:00
Rob Pike
f3e7ddc2fb Rewrite tokenizer to clean up and fix a bug with spaces before delimited block.
Fixes #501.

R=rsc
CC=golang-dev
https://golang.org/cl/181183
2010-01-08 17:49:55 +11:00
Russ Cox
fe56e2cc35 http: most of a URL shouldn't use URL-escaping
Fixes #502.

R=r, hoisie
CC=golang-dev
https://golang.org/cl/181179
2010-01-07 18:10:29 -08:00
Rob Pike
448aa49cfe Add a parser to the time package, the inverse of time.Format
R=rsc
CC=golang-dev
https://golang.org/cl/183141
2010-01-08 12:59:20 +11:00
Robert Griesemer
35403e4cf2 added some missing periods
R=rsc
CC=golang-dev
https://golang.org/cl/181171
2010-01-07 09:27:24 -08:00
Rob Pike
676f9dfa06 make Format about twice as fast by removing allocations, using a bytes.Buffer
add a benchmark

R=rsc
CC=golang-dev
https://golang.org/cl/181164
2010-01-07 14:36:54 +11:00
Russ Cox
74a9fc18f6 runtime: close TODO now that 8c bug is fixed
R=r
CC=golang-dev
https://golang.org/cl/183138
2010-01-06 19:24:11 -08:00
Rob Pike
fce5d60b38 add a standard interface that wraps ReadByte, io.ReadByter
R=rsc
CC=golang-dev
https://golang.org/cl/181163
2010-01-07 13:29:43 +11:00
Russ Cox
616394b177 deps.bash: handle space between .go and \ in GOFILES=
R=r
CC=golang-dev
https://golang.org/cl/181157
2010-01-06 17:59:15 -08:00
Hector Chu
6bfe5f55f4 Ported runtime to Windows.
R=rsc
CC=golang-dev
https://golang.org/cl/176066
2010-01-06 17:58:55 -08:00
Russ Cox
5c07e0c17c time: fix Makefile so deps.bash is happy (fixes build)
TBR=r
https://golang.org/cl/183133
2010-01-06 16:35:28 -08:00
Russ Cox
968d6a6d5a http: avoid header duplication - take struct fields out of Header map
R=r
CC=golang-dev, petar-m
https://golang.org/cl/183132
2010-01-06 15:45:30 -08:00
Rob Pike
e05b381e79 New time formatter, time.Format(formatString)
The model is that formatString is a a representation of a standard time,
and that Format converts the time to that representation.
Standard representaitons are defined for ANSIC, RFC850, RFC1123, and ISO8601.
There's also a humane Kitchen fomat: 3:04PM.

R=rsc, benolive, cw
CC=golang-dev
https://golang.org/cl/181130
2010-01-07 10:32:48 +11:00
Devon H. O'Dell
2eb9171dfb Fix missing explicit GOBIN in src/pkg/Makefile. Clean up creation of
QUOTED_GOBIN. Re-take of 181077; fixes copy-pasta that broke build.

Fixes #468

R=rsc
CC=golang-dev
https://golang.org/cl/183125
2010-01-06 07:47:56 -08:00
Ivan Krasin
597e57f4d5 Add http.CanonicalPath and tests for it. Remove BUG(rsc) from url.go.
R=rsc, imkrasin
CC=golang-dev
https://golang.org/cl/179126
2010-01-06 07:47:40 -08:00
Ivan Krasin
e324e4099f Propagate error to the caller in json.Marshal. Fixes issue 445.
R=rsc, imkrasin
CC=golang-dev
https://golang.org/cl/179125
2010-01-06 07:25:17 -08:00
Russ Cox
32594bd43d rollback of https://golang.org/cl/181077
(broke build)

TBR=dho
https://golang.org/cl/181139
2010-01-05 16:54:27 -08:00
Evan Shaw
1c819cb194 xml: Fix comment so that example code compiles
R=rsc
CC=golang-dev
https://golang.org/cl/181138
2010-01-05 16:50:52 -08:00
Russ Cox
cfbee34a27 big: fix ProbablyPrime bug, comments
(changes adopted from alc, agl)

R=agl1, agl
CC=golang-dev
https://golang.org/cl/181137
2010-01-05 16:49:05 -08:00
Devon H. O'Dell
e032ab9dc8 Fix missing explicit GOBIN in src/pkg/Makefile. Clean up creation of QUOTED_GOBIN
Fixes #468

R=rsc
CC=golang-dev
https://golang.org/cl/181077
2010-01-05 16:22:40 -08:00
Devon H. O'Dell
10cdec9262 syscall: add nanosleep on FreeBSD
Fixes #461

R=rsc
CC=golang-dev
https://golang.org/cl/181059
2010-01-05 09:21:15 -08:00
Roger Peppe
0281b71580 net: make Dial correctly return nil on error.
R=rsc
CC=golang-dev
https://golang.org/cl/181135
2010-01-05 09:20:02 -08:00
Robert Griesemer
50442290bb Simplified parser interface.
R=rsc, r
CC=golang-dev, rog
https://golang.org/cl/183116
2010-01-04 17:26:01 -08:00
Rob Pike
a0ee18bdd5 Check for errors when writing fields of a struct.
R=rsc
CC=golang-dev, jack.palevich
https://golang.org/cl/183109
2010-01-05 11:33:06 +11:00
Roger Peppe
f221067fe8 Allow a nil Ident to print without crashing.
Allow Walk of []Decl

R=gri
CC=golang-dev, rsc
https://golang.org/cl/183112
2010-01-04 10:34:37 -08:00
Yongjian Xu
ca0def6659 Remove redundant size check in resize. Let callers worry about that and resize should just do "resize".
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/181111
2010-01-02 11:09:22 +11:00
Rob Pike
5a44338159 trivial bug: []byte is special but [3]byte is not.
modify a test to verify the fix.

R=rsc
CC=golang-dev
https://golang.org/cl/183090
2009-12-31 12:47:20 +11:00
Rob Pike
a58b69e1d0 improve some type switches now that multiple types per case are supported.
R=rsc
CC=golang-dev
https://golang.org/cl/181089
2009-12-30 08:33:48 +11:00
Robert Griesemer
e01459f567 Apply symmetric changes to sha1 and sha256 as to md4 and md5.
R=agl, agl1
CC=golang-dev
https://golang.org/cl/183083
2009-12-29 11:41:44 -08:00
Nigel Tao
5042a4e9f9 PNG decoder now handles transparent paletted images.
Fixes #439.

R=r
CC=golang-dev
https://golang.org/cl/181087
2009-12-29 15:23:55 +11:00
Nigel Tao
50d3447a36 JPEG decoder now handles RST (restart) markers.
R=r
CC=golang-dev
https://golang.org/cl/181075
2009-12-29 15:20:53 +11:00
Rob Pike
e7601e2980 add a debugging printer to the gob package.
used only for debugging, debug.go is not normally part of the package source.

also add a dump program to call it.

R=rsc
CC=golang-dev
https://golang.org/cl/183075
2009-12-29 14:03:33 +11:00
Rob Pike
1f5511560e remove all references to gobType() from the decoder.
Fixes #470.

R=rsc
CC=golang-dev
https://golang.org/cl/183074
2009-12-29 14:03:12 +11:00
Robert Griesemer
f0fcb2d59f Symmetric changes to md4.go as for md5.go.
Use uint index variables in some cases instead
of int to enable strength reduction; this makes
it possible for the compiler to reduce % into
masks.

Old code: 6g -S md4.go md4block.go | grep "md4block.go:44"
0471 (md4block.go:44) MOVL    AX,BX
0472 (md4block.go:44) MOVL    AX,BP
0473 (md4block.go:44) MOVL    AX,R8
0474 (md4block.go:44) SARL    $31,R8
0475 (md4block.go:44) SHRL    $30,R8
0476 (md4block.go:44) ADDL    R8,BP
0477 (md4block.go:44) SARL    $2,BP
0478 (md4block.go:44) IMULL   $4,BP
0479 (md4block.go:44) SUBL    BP,BX
0480 (md4block.go:44) MOVLQSX BX,BX
0481 (md4block.go:44) LEAQ    shift1+0(SB),BP
0482 (md4block.go:44) CMPL    BX,8(BP)
0483 (md4block.go:44) JCS     ,485
0484 (md4block.go:44) CALL    ,runtime.throwindex+0(SB)
0485 (md4block.go:44) MOVQ    (BP),BP
0486 (md4block.go:44) MOVL    (BP)(BX*4),DI

New code: 6g -S md4.go md4block.go | grep "md4block.go:44"
0471 (md4block.go:44) MOVL    AX,BX
0472 (md4block.go:44) ANDL    $3,BX
0473 (md4block.go:44) MOVLQZX BX,BX
0474 (md4block.go:44) LEAQ    shift1+0(SB),BP
0475 (md4block.go:44) CMPL    BX,8(BP)
0476 (md4block.go:44) JCS     ,478
0477 (md4block.go:44) CALL    ,runtime.throwindex+0(SB)
0478 (md4block.go:44) MOVQ    (BP),BP
0479 (md4block.go:44) MOVL    (BP)(BX*4),DI

R=agl, agl1
CC=golang-dev
https://golang.org/cl/181086
2009-12-28 17:20:33 -08:00
Robert Griesemer
9d07d37f31 A couple of tighter loops.
(I was looking at this code accidentally because of some gofmt
issues and thought that one could write this more effectively.
You may have deliberately chosen not to use ranges here to make
the index range clearer. Just let me know.)

R=agl, agl1
CC=golang-dev
https://golang.org/cl/181084
2009-12-28 15:48:58 -08:00
Rob Pike
33311a7945 fix dumb bug: must write out default values inside arrays and slices
Fixes #459.

R=rsc, imkrasin, sonia
CC=golang-dev
https://golang.org/cl/181073
2009-12-29 07:41:53 +11:00
Robert Griesemer
b6adb3272f simplify some code that is using vectors
R=agl, agl1
CC=golang-dev
https://golang.org/cl/181080
2009-12-28 12:27:43 -08:00
Adam Langley
3c6bf09539 crypto/tls: make Listener a pointer.
Listener contains private members and 6g now enforces that private
members cannot be assigned outside of their package.

R=rsc
CC=golang-dev
https://golang.org/cl/183073
2009-12-28 11:40:01 -08:00
Devon H. O'Dell
1245e93b2c Update documentation around time.Sleep to specify its precision, and suggest
a possible interface for more granular sleep times.

Fixes issue #260.

R=rsc, r
CC=golang-dev
https://golang.org/cl/181058
2009-12-25 08:24:00 +11:00
Ian Lance Taylor
2be4897800 Use t.Errorf for formatted error output.
R=dsymonds1
CC=golang-dev
https://golang.org/cl/183049
2009-12-23 22:08:49 -08:00
Peter Froehlich
e1033d07b4 Add query to find number of subexpressions.
This was convenient for me to have without being forced
to parse the regexp myself. I'd understand if it's not
really wanted, but I also think that some meta information
about compiled regexps would be fine.

R=r, rsc
CC=golang-dev
https://golang.org/cl/183044
2009-12-24 08:43:35 +11:00
Robert Griesemer
b266f39b85 remove nums.sh
R=rsc
CC=golang-dev
https://golang.org/cl/181049
2009-12-23 13:15:00 -08:00
Rob Pike
96da3e96c3 implement .repeats for maps.
Fixes #309.

R=rsc
CC=golang-dev
https://golang.org/cl/181044
2009-12-24 07:41:56 +11:00
Adam Langley
9ebb59634e crypto/tls: extensions and Next Protocol Negotiation
Add support for TLS extensions in general and Next Protocol
Negotiation in particular.

R=rsc
CC=golang-dev
https://golang.org/cl/181045
2009-12-23 11:13:09 -08:00
Peter Froehlich
3f25c8a2ef Fix comment for Chmod.
R=r, rsc
CC=golang-dev
https://golang.org/cl/183042
2009-12-23 08:49:38 -08:00
Robert Griesemer
a0862ea568 Cleanup: remove Exp ending in identifiers
as it is not needed anymore (only one impl.
of vector package).

Makefile, vector_test.go, and nogen_test.go
were modified manually (find/replace), the
other files (intvector_test.go, strinvector_test.go
are generated).

Runs all tests.

R=r
https://golang.org/cl/182041
2009-12-22 18:45:36 -08:00
Robert Griesemer
8c7d001602 Replace container/vector with exp/vector (faster).
Manual changes to the following files:
src/pkg/Makefile
src/pkg/exp/vector/Makefile (now: src/pkg/container/vector/Makefile)

R=rsc, r
CC=golang-dev
https://golang.org/cl/181041
2009-12-22 18:25:27 -08:00
Robert Griesemer
36d645f5fa add comment (warning about generated files)
R=r
CC=golang-dev
https://golang.org/cl/180108
2009-12-22 15:14:10 -08:00
Rob Pike
148ee9c009 fix up %p
- use an interface {Get()}
- implement Get for maps, slices
- for slices, retrieves the address of the end of the array, which will give the
	same value for every slice of the same array.

R=rsc
CC=golang-dev
https://golang.org/cl/179129
2009-12-23 07:34:17 +11:00
Russ Cox
d488c4b4ac json: fix doc comment
R=gri
CC=golang-dev
https://golang.org/cl/179128
2009-12-22 09:47:02 -08:00
Rob Pike
2e853ec88a Allow %p on reference types, for debugging.
(Also fix case sensitivity in test for PTR inside fmt_test.go)
Fixes #441.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/180112
2009-12-22 17:02:00 +11:00
Jan Mercl
b15fefd7d7 Experimental alternative implementation of the vector package
R=gri
CC=rsc
https://golang.org/cl/178048
2009-12-21 14:34:54 -08:00
Rob Pike
1f0e6a4c99 new comments for bytes.NewBuffer and NewBufferString.
corrects a common misunderstanding about NewBuffer.

R=rsc
CC=golang-dev
https://golang.org/cl/179106
2009-12-19 08:42:31 +11:00
Adam Langley
50d6c81d4a runtime: fix race condition
(Thanks to ken and rsc for pointing this out)

rsc:
	ken pointed out that there's a race in the new
	one-lock-per-channel code.  the issue is that
	if one goroutine has gone to sleep doing

	select {
	case <-c1:
	case <-c2:
	}

	and then two more goroutines try to send
	on c1 and c2 simultaneously, the way that
	the code makes sure only one wins is the
	selgen field manipulation in dequeue:

	       // if sgp is stale, ignore it
	       if(sgp->selgen != sgp->g->selgen) {
		       //prints("INVALID PSEUDOG POINTER\n");
		       freesg(c, sgp);
		       goto loop;
	       }

	       // invalidate any others
	       sgp->g->selgen++;

	but because the global lock is gone both
	goroutines will be fiddling with sgp->g->selgen
	at the same time.

This results in a 7% slowdown in the single threaded case for a
ping-pong microbenchmark.

Since the cas predominantly succeeds, adding a simple check first
didn't make any difference.

R=rsc
CC=golang-dev
https://golang.org/cl/180068
2009-12-18 12:25:53 -08:00
Robert Griesemer
057e7d9fae fix build, enable an exp/eval's assignment check
now that the parser doesn't do this test anymore

R=rsc
CC=golang-dev
https://golang.org/cl/179105
2009-12-18 11:21:11 -08:00
Robert Griesemer
5dc6c80843 report an error for illegal octal numbers instead of treating them as floats
added more test cases
some capitalization cleanups

R=rsc
CC=golang-dev
https://golang.org/cl/180085
2009-12-18 10:52:11 -08:00
Robert Griesemer
c5f41cc58c removed semantic check from parsers
R=rsc
CC=golang-dev
https://golang.org/cl/179099
2009-12-18 10:51:47 -08:00
Kai Backman
d85bb81878 first stub for softfloats, intercepts float instructions and skips
them in the stream.

R=rsc
https://golang.org/cl/174052
2009-12-17 16:08:42 -08:00
Ben Olive
d2a835fbf3 time: add ISO 8601 time format
Fixes #431.

R=r, rsc
CC=golang-dev
https://golang.org/cl/179079
2009-12-17 13:39:13 -08:00
Tor Andersson
a812332151 Updated the XGB python script to generate semicolon-free
source for xproto.go.

R=rsc
CC=golang-dev
https://golang.org/cl/180074
2009-12-17 12:19:40 -08:00
Russ Cox
08579c26dd runtime: if os/signal is not in use, crash on
most signals, so that ordinary programs
	can be killed, for example.

Fixes #434.

R=dsymonds1
CC=golang-dev, hoisie
https://golang.org/cl/180064
2009-12-16 20:20:50 -08:00
Nigel Tao
8bf58725b2 Basic image/jpeg decoder.
This is not a complete JPEG implementation (e.g. it does not handle
progressive JPEGs or restart markers), but I was able to take a photo
with my phone, and view the resultant JPEG in pure Go.

The decoder is simple, but slow. The Huffman decoder in particular
should be easily improvable, but optimization is left to future
changelists. Being able to inline functions in the inner loop should
also help performance.

The output is not pixel-for-pixel identical to libjpeg, although
identical behavior isn't necessarily a goal, since JPEG is a lossy
codec. There are at least two reasons for the discrepancy.

First, the inverse DCT algorithm used is the same as Plan9's
src/cmd/jpg, which has different rounding errors from libjpeg's
default IDCT implementation. Note that libjpeg actually has three
different IDCT implementations: one floating point, and two fixed
point. Out of those four, Plan9's seemed the simplest to understand,
partly because it has no #ifdef's or C macros.

Second, for 4:2:2 or 4:2:0 chroma sampling, this implementation does
nearest neighbor upsampling, compared to libjpeg's triangle filter
(e.g. see h2v1_fancy_upsample in jdsample.c).

The difference from the first reason is typically zero, but sometimes
1 (out of 256) in YCbCr space, or double that in RGB space. The
difference from the second reason can be as large as 8/256 in YCbCr
space, in regions of steep chroma gradients. Informal eyeballing
suggests that the net difference is typically imperceptible, though.

R=r
CC=golang-dev, rsc
https://golang.org/cl/164056
2009-12-17 10:32:17 +11:00
Robert Griesemer
b6bac1c0a5 Don't ignore flags controlling the amount of source code parsed
in parser's ParsePkgFile and ParsePackage functions.

R=rsc
CC=golang-dev, rog
https://golang.org/cl/180070
2009-12-16 14:12:24 -08:00
Rob Pike
42a2e95989 add the ability to invoke niladic single-valued methods in templates.
Fixes #389.

R=rsc
CC=golang-dev
https://golang.org/cl/180061
2009-12-16 03:10:50 -08:00
William Josephson
52114724b7 rand: Zipf distributed random variates.
R=rsc
https://golang.org/cl/176070
2009-12-15 21:10:37 -08:00
Andrey Mirtchovski
7f501c06f7 bytes, strings: add new function Fields
R=rsc, r, phf
CC=golang-dev
https://golang.org/cl/170046
2009-12-15 21:09:55 -08:00
Charles L. Dorian
d5bcf7bf41 math: special cases for Pow
R=rsc
CC=golang-dev
https://golang.org/cl/176064
2009-12-15 20:43:12 -08:00
David Symonds
b5866494ea os/signal: new package
Fixes #71.

R=rsc, r
https://golang.org/cl/162056
2009-12-15 18:21:29 -08:00
Robert Griesemer
a47a45ec77 Fix for scanner bug (introduced with most recent change).
Fixes #433.

R=rsc
CC=golang-dev
https://golang.org/cl/179072
2009-12-15 18:03:59 -08:00
Russ Cox
69bed164a7 syscall: RawSyscall must not call exitsyscall
Fixes #405.

R=r
CC=golang-dev, hoisie
https://golang.org/cl/180056
2009-12-15 17:37:47 -08:00
Russ Cox
f64bb56bae rand: add explicit Int31n to avoid 64-bit divide on 32-bit machines
use Int31n in Intn when possible.

Fixes #390.

(using 8g)
Intn1000      50000000         38 ns/op
Int31n1000    50000000         39 ns/op
Int63n1000    20000000        114 ns/op

R=r
CC=golang-dev, skybrian
https://golang.org/cl/180054
2009-12-15 17:21:34 -08:00
Russ Cox
1e9e7ec4b3 math: faster, easier to inline IsNaN, IsInf
R=r
CC=golang-dev
https://golang.org/cl/180046
2009-12-15 17:21:01 -08:00
Russ Cox
d16bc7a9f2 runtime: return zero value in x, ok = <-c when ok == false
Fixes #401.

R=ken2
https://golang.org/cl/180053
2009-12-15 16:59:23 -08:00
Ivan Krasin
8e2608eca8 Add basic http authentication support.
Fixes #407.

R=rsc, ajstarks
CC=ushakov
https://golang.org/cl/176076
2009-12-15 16:27:45 -08:00
Robert Griesemer
45ca9f7a9e 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

5th and last set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180050
2009-12-15 15:41:46 -08:00
Robert Griesemer
d65a5cce89 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

4th set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180049
2009-12-15 15:40:16 -08:00
Robert Griesemer
a3d1045fb7 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

3rd set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180048
2009-12-15 15:35:38 -08:00
Robert Griesemer
5a1d3323fe 1) Change default gofmt default settings for
parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       1st set of files.

R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
2009-12-15 15:33:31 -08:00
Robert Griesemer
1c72959999 1) Change default gofmt default settings for
parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       2nd set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/179067
2009-12-15 15:27:16 -08:00
Robert Griesemer
55ca7a2644 fix TODO: insert semicolons before any sequence of comments
that introduce the newline (important for correct placement
of comments with gofmt when parsing new syntax)

R=rsc
https://golang.org/cl/179055
2009-12-15 08:41:50 -08:00
Arvindh Rajesh Tamilmani
dec5bb7882 xml: handle unexpected EOF while parsing and fix a bug in name
mustgetc reports unexpected EOF as SyntaxError.  using
mustgetc seems to be a better approach than letting the
caller handle unexpected EOF every time.

name: the second if statement should explicitly return
ok==false.

R=rsc
https://golang.org/cl/174083
2009-12-14 19:28:36 -08:00
Russ Cox
19c18358ca runtime: in exitsyscall, avoid confusing garbage collector
R=r
CC=golang-dev
https://golang.org/cl/178046
2009-12-14 19:06:20 -08:00
Robert Griesemer
31de4d4c5d improved formatting of import declarations and
multi-line expressions with comments

Fixes #414.

R=rsc
https://golang.org/cl/179047
2009-12-14 17:35:12 -08:00
Andy Davis
2a52782f5c crypto/sha256: new package
R=rsc
CC=golang-dev
https://golang.org/cl/176062
2009-12-14 15:09:49 -08:00
Rob Pike
0d3f5a84b8 simpler fix for the negative rune problem, spotted seconds after submitting the previous fix.
R=rsc
https://golang.org/cl/178044
2009-12-15 09:31:24 +11:00
Rob Pike
a9e8befb49 generate replacement rune when asked to encode a negative rune value.
Fixes #425.

R=rsc
https://golang.org/cl/178043
2009-12-15 09:19:54 +11:00
Christopher Wedgwood
fe0eb17fad archive/tar: bug fixes.
1. If all data is exhausted using Read then a following Next will
   fail as if it saw EOF.  (Test case added.)
2. Seeking isn't always possible (i.e. sockets and pipes).  Fallback
   to read.  (Test case added.)
3. Fix to readHeader (cleaner fix pointed out by rsc).
   (TestReader modified.)
4. When Read has consumed all the data, don't try to read 0 bytes from reader.
   In cases where tr.nb is zero we attempt to read zero bytes and thus
   never see an EOF (this is most easily seen when the 'tar source' is
   something like bytes.Buffer{} as opposed to os.File).
5. If write is used to the point of ErrWriteTooLong, allow additional file entries.
6. Make close work as expected.  That is any further Write or
   WriteHeader attempts will result in ErrWriteAfterClose.
Fixes #419.

R=rsc, dsymonds1
https://golang.org/cl/162062
2009-12-14 11:35:02 -08:00
Rob Pike
d14c813377 When the buffer is empty, reset b.off to the beginning of the buffer
to avoid growing unnecessarily.

R=rsc
CC=golang-dev
https://golang.org/cl/176071
2009-12-14 13:13:01 +11:00
Christopher Wedgwood
58578905ba syscall: fix error return bug for 64-bit return on 32-bit platform
R=dho, rsc
CC=r
https://golang.org/cl/176058
2009-12-13 13:05:49 -08:00
Rob Pike
687777710b fix bug for large counts: used a one-byte buffer.
R=rsc
CC=golang-dev
https://golang.org/cl/174082
2009-12-13 07:27:43 +11:00
Robert Griesemer
222462ed4f Various cleanups:
- no need to replace comments for stand-alone blocks
- always print string concatenations with interspersed "+"
  (remove option)
- minor cleanups

R=rsc
https://golang.org/cl/174076
2009-12-11 16:42:14 -08:00
Robert Griesemer
97a08f7a81 parser changed to reflect new semicolon rules
R=rsc
https://golang.org/cl/175046
2009-12-11 15:31:24 -08:00
Robert Griesemer
b9b89f56ad fix printer test for new syntax
R=rsc
https://golang.org/cl/175048
2009-12-11 15:31:06 -08:00
Devon H. O'Dell
857d4cf1a9 Remove GOBIN in PATH dependency; don't assume cwd is $GOROOT/src
This change removes the necessity to have GOBIN in $PATH,
and also doesn't assume that the build is being run from
$GOROOT/src. This is a minimal set of necessary changes
to get Go to build happily from the FreeBSD ports
collection.

R=rsc
CC=golang-dev
https://golang.org/cl/171044
2009-12-11 15:14:09 -08:00
Maxim Ushakov
349095885e encoding/binary: Add support for slices of arrays of fixed-size values.
R=rsc
CC=krasin
https://golang.org/cl/167050
2009-12-11 13:04:03 -08:00
Yves Junqueira
7835b7994e syslog: new package
R=golang-dev, rsc
https://golang.org/cl/157168
2009-12-11 12:41:51 -08:00
Kei Son
128974adfd bytes, strings: allow -1 in Map to mean "drop this character".
xml: drop invalid characters in attribute names
    when constructing struct field names.

R=rsc
CC=r
https://golang.org/cl/157104
2009-12-11 10:37:48 -08:00
Robert Griesemer
bda2074193 New flags for gofmt:
- oldparser            parse old syntax (required semicolons)
- oldprinter           print old syntax (required semicolons)

By default, these flags are enabled for now.
Setting -oldparser=false has no effect until go/parser is changed
to accept the new syntax.

Enabled exp/parser in Makefile; update dependent exp/eval.

R=rsc
https://golang.org/cl/174051
2009-12-10 19:03:28 -08:00
Robert Griesemer
02d41ec7df rename exp/parser package to oldParser
to allow simultaneous import with the
current go/parser

R=rsc
https://golang.org/cl/174053
2009-12-10 18:27:48 -08:00
Robert Griesemer
57909b54e9 implement NoSemis and NoStringConcat mode for go/printer
R=rsc
https://golang.org/cl/174050
2009-12-10 15:45:57 -08:00
Robert Griesemer
a70caf4463 implemented InsertSemis mode for go/scanner
R=rsc
https://golang.org/cl/175047
2009-12-10 15:31:02 -08:00
Robert Griesemer
2b3813d0e2 - unmodified copy of existing go/parser, not yet hooked up
R=rsc
CC=r
https://golang.org/cl/175045
2009-12-10 14:26:25 -08:00
Kai Backman
d08d33f389 fix calling convention and make memmove restore the g and m
registers.

R=rsc
https://golang.org/cl/166049
2009-12-10 11:42:01 -08:00
Kai Backman
76f7803a2a added SHUT_RD, SHOT_WR and xSHUT_RDWR to fix net compilation error
R=rsc
https://golang.org/cl/165044
2009-12-10 11:40:11 -08:00
Robert Griesemer
2e4334eb3a minor manual format corrections
R=rsc
https://golang.org/cl/172042
2009-12-09 16:54:24 -08:00
Robert Griesemer
295ceb4526 remove uses of string concatenation from src and misc directory
R=rsc
https://golang.org/cl/172041
2009-12-09 16:54:07 -08:00
Roger Peppe
a8ed75d27c added benchmarks to rand_test.go;
removed superfluous field name in lockedSource.

R=r, rsc
https://golang.org/cl/170043
2009-12-09 14:23:43 -08:00
Rob Pike
51f2932082 syscalls can return negative i/o counts. fix bugs in ReadAt and WriteAt not to include
negative counts in return values.

R=rsc
CC=golang-dev
https://golang.org/cl/170044
2009-12-09 14:18:32 -08:00
Roger Peppe
916533119e Make the operations on the global rng thread safe.
R=r, rsc
CC=golang-dev
https://golang.org/cl/168041
2009-12-09 12:55:19 -08:00
Ross Light
8a5b76ce5c json package: Fixed handling of nil values
Fixes #400.

R=golang-dev, rsc
https://golang.org/cl/167058
2009-12-09 10:36:03 -08:00
Adrian O'Grady
6ebfd1eff2 Added XTEA block cipher package to src/pkg/crypto
This is an adaption of the code from http://en.wikipedia.org/wiki/XTEA. The package also implements the block.Cipher
interface so that it can be used with the various block modes.

R=rsc
https://golang.org/cl/157152
2009-12-09 00:06:20 -08:00
Russ Cox
0400a7f8b1 runtime: start new darwin/amd64 threads on correct stack,
then enable stack check.

R=r
https://golang.org/cl/165100
2009-12-08 23:34:45 -08:00
Russ Cox
132c42ff73 bufio: use copy - significant speedup for writers
R=r
https://golang.org/cl/167047
2009-12-08 18:19:48 -08:00
Devon H. O'Dell
5a4a08fab8 Fix stack on FreeBSD / add stack check across the board
FreeBSD was passing stk as the new thread's stack base, while
stk is the top of the stack in go. The added check should cause
a trap if this ever comes up in any new ports, or regresses
in current ones.

R=rsc
CC=golang-dev
https://golang.org/cl/167055
2009-12-08 18:19:30 -08:00
Devon H. O'Dell
cdce7325c8 When SA_SIGINFO is set, we should use __sa_sigaction on FreeBSD
R=rsc
CC=golang-dev
https://golang.org/cl/165097
2009-12-08 18:18:04 -08:00
Russ Cox
0d3301a557 runtime: don't touch pages of memory unnecessarily.
cuts working size for hello world from 6 MB to 1.2 MB.
still some work to be done, but diminishing returns.

R=r
https://golang.org/cl/165080
2009-12-07 15:52:14 -08:00
Russ Cox
33649bd278 runtime: introduce unsafe.New and unsafe.NewArray
to provide functionality previously hacked in to
    reflect and gob.

R=r
https://golang.org/cl/165076
2009-12-07 15:51:58 -08:00
Robert Griesemer
a4a8224152 use a bootstrap array to avoid allocation for short vectors
R=r
https://golang.org/cl/165078
2009-12-07 12:46:20 -08:00
Christopher Wedgwood
8c22dd24e0 Remove copyBytes completely in favor of copy.
R=r, rsc
https://golang.org/cl/165068
2009-12-07 11:31:56 -08:00
Rob Pike
20c1ec263a pick off special one-byte case in copy. worth 2x in benchmarks (38ns->16ns).
the one-item case could be generalized easily with no cost. worth considering.

R=rsc
CC=golang-dev, cw
https://golang.org/cl/167044
2009-12-07 11:28:02 -08:00
Roger Peppe
80e17d6797 the AST walker currently provides no way to find out how the
nodes in the tree are nested with respect to one another.
a simple change to the Visitor interface makes it possible
to do this (for example to maintain a current node-depth, or a
knowledge of the name of the current function).

Visit(nil) is called at the end of a node's children;
this make possible the channel-based interface below,
amongst other possibilities.

It is still just as simple to get the original behaviour - just
return the same Visitor from Visit.

Here are a couple of possible Visitor types.

// closure-based
type FVisitor func(n interface{}) FVisitor
func (f FVisitor) Visit(n interface{}) Visitor {
	return f(n);
}

// channel-based
type CVisitor chan Visit;
type Visit struct {
	node interface{};
	reply chan CVisitor;
};
func (v CVisitor) Visit(n interface{}) Visitor
{
	if n == nil {
		close(v);
	} else {
		reply := make(chan CVisitor);
		v <- Visit{n, reply};
		r := <-reply;
		if r == nil {
			return nil;
		}
		return r;
	}
	return nil;
}

R=gri
CC=rsc
https://golang.org/cl/166047
2009-12-07 10:33:45 -08:00
Rob Pike
f91cd44736 save a few ns by inlining (which mostly simplifies things anyway).
a couple of cleanups.
don't keep big buffers in the free list.

R=rsc
CC=golang-dev
https://golang.org/cl/166078
2009-12-06 15:01:07 -08:00
Rob Pike
353ef80f65 unexport Fmt. it's not needed outside this package any more
cleans up godoc's output for package fmt substantially.

R=rsc
CC=golang-dev
https://golang.org/cl/165070
2009-12-06 12:58:16 -08:00
Rob Pike
4c0e51cd43 Make printing faster by avoiding mallocs and some other advances.
Roughly 33% faster for simple cases, probably more for complex ones.

Before:

mallocs per Sprintf(""): 4
mallocs per Sprintf("xxx"): 6
mallocs per Sprintf("%x"): 10
mallocs per Sprintf("%x %x"): 12

Now:

mallocs per Sprintf(""): 2
mallocs per Sprintf("xxx"): 3
mallocs per Sprintf("%x"): 5
mallocs per Sprintf("%x %x"): 7

Speed improves because of avoiding mallocs and also by sharing a bytes.Buffer
between print.go and format.go rather than copying the data back after each
printed item.

Before:

fmt_test.BenchmarkSprintfEmpty	1000000	      1346 ns/op
fmt_test.BenchmarkSprintfString	500000	      3461 ns/op
fmt_test.BenchmarkSprintfInt	500000	      3671 ns/op

Now:

fmt_test.BenchmarkSprintfEmpty	 2000000	       995 ns/op
fmt_test.BenchmarkSprintfString	 1000000	      2745 ns/op
fmt_test.BenchmarkSprintfInt	 1000000	      2391 ns/op
fmt_test.BenchmarkSprintfIntInt	  500000	      3751 ns/op

I believe there is more to get but this is a good milestone.

R=rsc
CC=golang-dev, hong
https://golang.org/cl/166076
2009-12-06 12:03:52 -08:00
Russ Cox
ed6fd1bcbe runtime: disable pointer scan optimization
* broken by reflect, gob

TBR=r
https://golang.org/cl/166077
2009-12-06 08:18:58 -08:00
Ian Lance Taylor
44c1eb6bed Fix syscall.Statfs and syscall.Fstatfs for 386 GNU/Linux.
For 386 we use the [f]statfs64 system call, which takes three
parameters: the filename, the size of the statfs64 structure,
and a pointer to the structure itself.

R=rsc
https://golang.org/cl/166073
2009-12-04 21:58:32 -08:00
Russ Cox
864c757a1c gc/runtime: pass type structure to makeslice.
* inform garbage collector about memory with no pointers in it

1.9s	gcc reverse-complement.c

reverse-complement.go
4.5s / 3.5s	original, with/without bounds checks
3.5s / 3.3s	bounds check reduction
3.3s / 2.8s	smarter garbage collector
2.6s / 2.3s		assembler bytes.IndexByte
2.5s / 2.1s	even smarter garbage collector (this CL)

R=r
https://golang.org/cl/165064
2009-12-04 21:44:05 -08:00
Russ Cox
2807621d01 net: more fiddling with the udp test.
i don't know why the timeout needs
  to be so big.

R=r
https://golang.org/cl/165063
2009-12-04 18:34:45 -08:00
Ian Lance Taylor
9e0b68d1ee Add syscall.Rename for NaCl. Fixes NaCl build.
R=rsc
https://golang.org/cl/165062
2009-12-04 13:49:58 -08:00
Adam Langley
e79bcf8bfd runtime: shift the index for the sort by one.
Makes the code look cleaner, even if it's a little harder to figure
out from the sort invariants.

R=rsc
CC=golang-dev
https://golang.org/cl/165061
2009-12-04 13:31:18 -08:00
Ian Lance Taylor
0b5cc31693 Add os.Rename.
R=rsc
https://golang.org/cl/166058
2009-12-04 11:46:56 -08:00