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

4382 Commits

Author SHA1 Message Date
Albert Strasheim
51057bda3f net: fix "unexpected socket family" error from WriteToUDP.
R=rsc, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5128048
2011-10-12 13:36:45 -04:00
Russ Cox
8219cc9af8 runtime: fix memory leak in parallel garbage collector
The work buffer management used by the garbage
collector during parallel collections leaks buffers.
This CL tests for and fixes the leak.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/5254059
2011-10-12 13:23:34 -04:00
Dmitriy Vyukov
af1232fe38 runtime: faster strings
Use FlagNoPointers and do not zeroize memory when allocate strings.
test/garbage/parser.out        old         new
run #1                     32.923s     32.065s
run #2                     33.047s     31.931s
run #3                     32.702s     31.841s
run #4                     32.718s     31.838s
run #5                     32.702s     31.868s

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5259041
2011-10-12 17:40:02 +03:00
Luuk van Dijk
77fac21e82 runtime: append([]byte, string...)
Fixes #2274

R=rsc, gri, dsymonds, bradfitz, lvd
CC=golang-dev
https://golang.org/cl/5149045
2011-10-12 15:59:23 +02:00
Robert Griesemer
a0d335c31d go/scanner: remove AllowIllegalChars mode
This mode was needed before for clients of
the go/scanner that were parsing non-Go code.
All those clients have been moved to scanner
or have been deleted from the library.

R=r
CC=golang-dev
https://golang.org/cl/5232051
2011-10-11 22:28:56 -07:00
Robert Griesemer
187c3536a8 exp/datafmt: delete per Go 1 plan
R=r, bradfitz
CC=golang-dev
https://golang.org/cl/5249055
2011-10-11 17:52:37 -07:00
Robert Griesemer
e58a77809d ebnf, ebnflint: move under exp
pkg/ebnf -> pkg/exp/ebnf
cmd/ebnflint -> pkg/exp/ebnflint

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5188042
2011-10-11 17:43:10 -07:00
Brad Fitzpatrick
9b8cdad8aa exp/spdy: move http/spdy to exp/spdy
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5238051
2011-10-11 16:45:01 -07:00
Rob Pike
f4cb96b438 container/vector: delete
Slices are better:
http://code.google.com/p/go-wiki/wiki/SliceTricks

R=golang-dev, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/5248060
2011-10-11 16:41:48 -07:00
Alex Brainman
059c68bf0c net: implement ip protocol name to number resolver for windows
Fixes #2215.
Fixes #2216.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/5248055
2011-10-12 10:29:22 +11:00
Rob Pike
d69b820e01 try: delete
A fun experiment but not carrying its weight.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5246054
2011-10-11 16:17:21 -07:00
Dave Cheney
9691312e53 syscall: add #ifdefs to fix the manual corrections in ztypes_linux_arm.go
Fixes #1998.

ztypes_linux_arm.go has been regenerated on an arm5 debian sid host and
includes a few new constants.

R=golang-dev, mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/5240047
2011-10-11 15:47:00 -04:00
Louis Kruger
690d59fa3e crypto/tls: add 3DES ciphersuites
The following ciphersuites are added:
TLS_RSA_WITH_3DES_EDE_CBC_SHA
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
This change helps conform to the TLS1.1 standard because
the first ciphersuite is "mandatory" in RFC4346

R=golang-dev, agl, rsc
CC=golang-dev
https://golang.org/cl/5164042
2011-10-11 13:07:32 -04:00
Hector Chu
8584445289 runtime: fix crash when returning from syscall during gc
gp->m can go from non-nil to nil when it re-enters schedule().

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/5245042
2011-10-11 12:57:16 -04:00
Chris Farmiloe
4b749567b8 net: fix socket leak in case of Dial failure
Socket descriptors are not closed when fd.connect() fails during generic socket creation.
After a connection failure [ECONNREFUSED] descriptors are left in SYN_SENT state indefinitely (unless they get an explicit RST). Repeated failed connections will eventually cause your program to hit the user/system max-open-files limit.

Fixes #2349.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5229047
2011-10-11 12:53:16 -04:00
Brad Fitzpatrick
1444a08098 fmt: fix doc typo
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5252050
2011-10-11 08:49:09 -07:00
Andrew Gerrand
8440fdd904 godoc: support multiple examples
gotest: document examples
go/doc: tidy comment

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5235055
2011-10-11 11:11:47 +11:00
Rob Pike
c832ecf03e gob: avoid one copy for every message written.
Plus the need for a second in-memory buffer.
Plays a bit fast and loose with the contents of a byte buffer,
but saves a potentially huge allocation. The gotest
run is about 10% faster overall after this change.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/5236043
2011-10-10 12:38:49 -07:00
Nigel Tao
be8b4d943f html: add a Render function.
R=mikesamuel, andybalholm
CC=golang-dev
https://golang.org/cl/5218041
2011-10-10 14:44:37 +11:00
Brad Fitzpatrick
e63fcd613f http: cancel test timers; don't t.Fatalf in other goroutines
R=rsc
CC=golang-dev
https://golang.org/cl/5228041
2011-10-09 17:57:31 -07:00
Luuk van Dijk
b536adbfba gc: changes to export format in preparation for inlining.
string literals used as package qualifiers are now prefixed with '@'
which obviates the need for the extra ':' before tags.

R=rsc, gri, lvd
CC=golang-dev
https://golang.org/cl/5129057
2011-10-08 19:37:06 +02:00
Adam Langley
bffadd6bd7 crypto/tls: forgot this file in the last change.
R=bradfitz
CC=golang-dev
https://golang.org/cl/5244042
2011-10-08 10:11:38 -04:00
Adam Langley
7e48cb5ffe crypto/tls: add server side SNI support.
With this in place, a TLS server is capable of selecting the correct
certificate based on the client's ServerNameIndication extension.

The need to call Config.BuildNameToCertificate is unfortunate, but
adding a sync.Once to the Config structure made it uncopyable and I
felt that was too high a price to pay. Parsing the leaf certificates
in each handshake was too inefficient to consider.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5151048
2011-10-08 10:06:53 -04:00
Joel Sing
060ffabd18 runtime: improve locking on openbsd
Implement a locking model based on the current linux model - a
tri-state mutex with active spinning, passive spinning and sleeping.

R=golang-dev, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/4974043
2011-10-09 00:56:13 +11:00
Rob Pike
c09af50213 testing: fix time reported for failing tests.
t.ns was hanging after recent changes.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/5237044
2011-10-07 14:15:16 -07:00
Robert Griesemer
39b6fb7a19 go/token: remove obsolete comment (cleanup)
R=r
CC=golang-dev
https://golang.org/cl/5235042
2011-10-07 08:54:02 -07:00
Mikio Hara
b5260364b1 net: add File method to IPConn
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5237041
2011-10-07 22:53:12 +09:00
Brad Fitzpatrick
2b95cfbac3 utf8: add Valid and ValidString
R=r, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/5234041
2011-10-06 22:47:24 -07:00
Nigel Tao
af2070598f image: delete obsolete color.go
I accidentally left it off of https://golang.org/cl/5132048/.

R=r
CC=golang-dev
https://golang.org/cl/5202042
2011-10-07 13:33:34 +11:00
Robert Griesemer
5782ea9646 go/token: document deserialization property
FileSet deserialization (Read) uses its own instance of a gob decoder.
If the FileSet data may be followed by other data on the reader, Read
may consume too much data that is lost unless the reader implements
ReadByte.

Also: Minor internal refactoring for symmetry.

R=r
CC=golang-dev
https://golang.org/cl/5233041
2011-10-06 17:37:59 -07:00
Robert Griesemer
3e46699958 go/ast: don't remove function bodies when filtering exports
This is a semantic but no API change. It is a cleaner
implementation of pure filtering. Applications that
need function bodies stripped can easily do this them-
selves.

R=rsc
CC=golang-dev
https://golang.org/cl/5206046
2011-10-06 16:07:56 -07:00
Rob Pike
b3dd32776b template: fix comments with different delimiters.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5208042
2011-10-06 15:21:56 -07:00
Rob Pike
dcf5318990 template: add method Delims to allow alternate action delimiters.
R=golang-dev, rsc, dsymonds
CC=golang-dev
https://golang.org/cl/5209045
2011-10-06 13:30:50 -07:00
Andrew Gerrand
af1ae438b9 go/doc, godoc, gotest: support for reading example documentation
This CL introduces the go.Example type and go.Examples functions that
are used to represent and extract code samples from Go source.

They should be of the form:

// Output of this function.
func ExampleFoo() {
        fmt.Println("Output of this function.")
}

It also modifies godoc to read example code from _test.go files,
and include them in the HTML output with JavaScript-driven toggles.

It also implements testing of example functions with gotest.
The stdout/stderr is compared against the output comment on the
function.

This CL includes examples for the sort.Ints function and the
sort.SortInts type. After patching this CL in and re-building go/doc
and godoc, try
        godoc -http=localhost:6060
and visit http://localhost:6060/pkg/sort/

R=gri, r, rsc
CC=golang-dev
https://golang.org/cl/5137041
2011-10-06 11:56:17 -07:00
Brad Fitzpatrick
155e21cc7f exec: add Command.ExtraFiles
Allows passing extra fds to the child process.

Fixes #2329

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/5162050
2011-10-06 11:00:02 -07:00
Miki Tebeka
f80d8fbcf0 testing: Add support for running tests in parallel (t.Parallel API).
See discussion at https://groups.google.com/d/topic/golang-dev/RAKiqi44GEU/discussion

R=golang-dev, bradfitz, dvyukov, rogpeppe, r, r, borman
CC=golang-dev
https://golang.org/cl/5071044
2011-10-06 09:58:36 -07:00
Dmitriy Vyukov
c14b2689f0 runtime: faster finalizers
Linux/amd64, 2 x Intel Xeon E5620, 8 HT cores, 2.40GHz
benchmark                    old ns/op    new ns/op    delta
BenchmarkFinalizer              420.00       261.00  -37.86%
BenchmarkFinalizer-2            985.00       201.00  -79.59%
BenchmarkFinalizer-4           1077.00       244.00  -77.34%
BenchmarkFinalizer-8           1155.00       180.00  -84.42%
BenchmarkFinalizer-16          1182.00       184.00  -84.43%

BenchmarkFinalizerRun          2128.00      1378.00  -35.24%
BenchmarkFinalizerRun-2        1655.00      1418.00  -14.32%
BenchmarkFinalizerRun-4        1634.00      1522.00   -6.85%
BenchmarkFinalizerRun-8        2213.00      1581.00  -28.56%
BenchmarkFinalizerRun-16       2424.00      1599.00  -34.03%

Darwin/amd64, Intel L9600, 2 cores, 2.13GHz
benchmark                    old ns/op    new ns/op    delta
BenchmarkChanCreation          1451.00       926.00  -36.18%
BenchmarkChanCreation-2        3124.00      1412.00  -54.80%
BenchmarkChanCreation-4        6121.00      2628.00  -57.07%

BenchmarkFinalizer              684.00       420.00  -38.60%
BenchmarkFinalizer-2          11195.00       398.00  -96.44%
BenchmarkFinalizer-4          15862.00       654.00  -95.88%

BenchmarkFinalizerRun          2025.00      1397.00  -31.01%
BenchmarkFinalizerRun-2        3920.00      1447.00  -63.09%
BenchmarkFinalizerRun-4        9471.00      1545.00  -83.69%

R=golang-dev, cw, rsc
CC=golang-dev
https://golang.org/cl/4963057
2011-10-06 18:42:51 +03:00
Russ Cox
ad35cea762 runtime: fix malloc sampling bug
The malloc sample trigger was not being set in a
new m, so the first allocation in each new m - the
goroutine structure - was being sampled with
probability 1 instead of probability sizeof(G)/rate,
an oversampling of about 5000x for the default
rate of 1 MB.  This bug made pprof graphs show
far more G allocations than there actually were.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5224041
2011-10-06 11:30:48 -04:00
Dmitriy Vyukov
5695915833 runtime: fix spurious deadlock reporting
Fixes #2337.
Unfortunate sequence of events is:
1. maxcpu=2, mcpu=1, grunning=1
2. starttheworld creates an extra M:
   maxcpu=2, mcpu=2, grunning=1
4. the goroutine calls runtime.GOMAXPROCS(1)
   maxcpu=1, mcpu=2, grunning=1
5. since it sees mcpu>maxcpu, it calls gosched()
6. schedule() deschedules the goroutine:
   maxcpu=1, mcpu=1, grunning=0
7. schedule() call getnextandunlock() which
   fails to pick up the goroutine again,
   because canaddcpu() fails, because mcpu==maxcpu
8. then it sees that grunning==0,
   reports deadlock and terminates

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5191044
2011-10-06 18:10:14 +03:00
Mikio Hara
504963e6a4 build: clear execute bit from source files
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5201042
2011-10-06 18:33:13 +09:00
Wei Guangjing
e7042418c5 cgo: support for mingw-w64 4.5.1 and newer
R=rsc, jp, hectorchu
CC=golang-dev
https://golang.org/cl/4962051
2011-10-06 07:22:48 +01:00
Marcel van Lohuizen
9a8da9d499 exp/norm: LastBoundary is used in preparation for an append operation. It seems
therefore unlikely that there is a good use for its string version
LastBoundaryInString. Yet, the implemenation of this method would complicate
things a bit as it would require the introduction for another interface and
some duplication of code. Removing it seems a better choice.

R=r
CC=golang-dev
https://golang.org/cl/5182044
2011-10-05 14:36:02 -07:00
Robert Griesemer
f7467e85e1 encoding/binary: added benchmarks
binary.BenchmarkPutUvarint32 20000000	 85.6 ns/op
binary.BenchmarkPutUvarint64 10000000	299   ns/op

R=rsc
CC=golang-dev
https://golang.org/cl/5148049
2011-10-05 13:04:43 -07:00
Fumitoshi Ukai
9a0a30ec53 websocket: add hybi-13 support
Major changes between hybi-08 and hybi-13
- hybi-08 uses Sec-WebSocket-Origin, but hybi-13 uses Origin
- hybi-13 introduces new close status codes.

hybi-17 spec (editorial changes of hybi-13) mentions
- if a server doesn't support the requested version, it MUST respond
  with Sec-WebSocket-Version headers containing all available versions.
- client MUST close the connection upon receiving a masked frame
- server MUST close the connection upon receiving a non-masked frame
note that hybi-17 still uses "Sec-WebSocket-Version: 13"

see http://code.google.com/p/pywebsocket/wiki/WebSocketProtocolSpec
for changes between spec drafts.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5147043
2011-10-05 10:50:29 -07:00
Marcel van Lohuizen
5844fc1b21 exp/norm: introduced input interface to implement string versions
of methods.

R=r, mpvl
CC=golang-dev
https://golang.org/cl/5166045
2011-10-05 10:44:11 -07:00
Robert Griesemer
0da66a2e90 ebnf: use scanner instead of go/scanner
R=rsc, r
CC=golang-dev
https://golang.org/cl/5192043
2011-10-05 10:34:01 -07:00
Joel Sing
b2f1eba324 runtime: set runtime ncpu on openbsd
Set the runtime ncpu based on the hw.ncpu sysctl.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5191043
2011-10-05 13:16:43 -04:00
Rob Pike
457dfd7546 gob: when possible, allow sequential decoders on the same input stream.
This can work only if there is no type info required to initialize the decoder,
but it's easy and gains a few percent in the basic benchmarks by avoiding
bufio when it's a bytes.Buffer - a testing-only scenario, I admit.
Add a comment about what Decode expects from the input.

R=rsc
CC=golang-dev
https://golang.org/cl/5165048
2011-10-05 09:47:09 -07:00
Joel Sing
a5f064a3e1 gc: limit helper threads based on ncpu
When ncpu < 2, work.nproc is always 1 which results in infinite helper
threads being created if gomaxprocs > 1 and MaxGcproc > 1. Avoid this
by using the same limits as imposed helpgc().

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/5176044
2011-10-05 12:08:28 -04:00
Anthony Martin
528ccdc513 runtime: fix Plan 9 build
This change adds the osyield and usleep
functions and code to read the number of
processors from /dev/sysstat.

I also changed SysAlloc to return nil
when brk fails (it was returning -1).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5177049
2011-10-05 12:07:44 -04:00
Paul Borman
0b534bc9c3 pkg/syscall: add Mkfifo for linux platforms
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5131055
2011-10-04 13:58:31 -07:00
Brad Fitzpatrick
c31f987bd6 websocket: better error message in a test
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5185045
2011-10-04 13:46:03 -07:00
Paul Borman
93b8438e59 time: make month/day name comparisons case insenstive
Fixes #2324.

R=r, r
CC=golang-dev
https://golang.org/cl/5180044
2011-10-04 12:52:30 -07:00
Gustavo Niemeyer
da99a5bca4 path/filepath: added Rel as the complement of Abs
R=golang-dev, rsc, gustavo, r, borman
CC=golang-dev
https://golang.org/cl/4981049
2011-10-04 11:27:06 -03:00
Nigel Tao
a2846e65dc image: spin off a new color package out of the image package.
The spin-off renames some types. The new names are simply better:
image.Color              -> color.Color
image.ColorModel         -> color.Model
image.ColorModelFunc     -> color.ModelFunc
image.PalettedColorModel -> color.Palette
image.RGBAColor          -> color.RGBA
image.RGBAColorModel     -> color.RGBAModel
image.RGBA64Color        -> color.RGBA64
image.RGBA64ColorModel   -> color.RGBA64Model
(similarly for NRGBAColor, GrayColorModel, etc)

The image.ColorImage type stays in the image package, but is renamed:
image.ColorImage -> image.Uniform

The image.Image implementations (image.RGBA, image.RGBA64, image.NRGBA,
image.Alpha, etc) do not change their name, and gain a nice symmetry:
an image.RGBA is an image of color.RGBA, etc.

The image.Black, image.Opaque uniform images remain unchanged (although
their type is renamed from image.ColorImage to image.Uniform). The
corresponding color types (color.Black, color.Opaque, etc) are new.

Nothing in the image/ycbcr is renamed yet. The ycbcr.YCbCrColor and
ycbcr.YCbCrImage types will eventually migrate to color.YCbCr and
image.YCbCr, but that will be a separate CL.

R=r, bsiegert
CC=golang-dev
https://golang.org/cl/5132048
2011-10-04 11:09:03 +11:00
Brad Fitzpatrick
bba7396fbd strings: implement a faster byte->string Replacer
This implements a replacer for when all old strings are single
bytes, but new values are not.

BenchmarkHTMLEscapeNew   1000000   1090 ns/op
BenchmarkHTMLEscapeOld   1000000   2049 ns/op

R=rsc
CC=golang-dev
https://golang.org/cl/5176043
2011-10-03 15:19:04 -07:00
Brad Fitzpatrick
f75ff01f44 strings: implement a faster byte->byte Replacer
When all old & new string values are single bytes,
byteReplacer is now used, instead of the generic
algorithm.

BenchmarkGenericMatch       10000  102519 ns/op
BenchmarkByteByteMatch    1000000    2178 ns/op

fast path, when nothing matches:
BenchmarkByteByteNoMatch  1000000    1109 ns/op

comparisons to multiple Replace calls:
BenchmarkByteByteReplaces  100000   16164 ns/op

comparison to strings.Map:
BenchmarkByteByteMap       500000    5454 ns/op

R=rsc
CC=golang-dev
https://golang.org/cl/5175050
2011-10-03 13:12:01 -07:00
Hector Chu
85916146ea runtime: fix usleep on linux/386 and re-enable parallel gc
R=golang-dev, jsing, alex.brainman, cw, rsc
CC=golang-dev
https://golang.org/cl/5166047
2011-10-03 19:08:59 +01:00
Joel Sing
d573ad2671 runtime: implement runtime usleep for openbsd
R=golang-dev, mikioh.mikioh, hectorchu
CC=golang-dev
https://golang.org/cl/5173043
2011-10-01 11:58:36 -07:00
Russ Cox
e7e5c5adb3 runtime: fix map memory leak
The map implementation was using the C idiom of using
a pointer just past the end of its table as a limit pointer.
Unfortunately, the garbage collector sees that pointer as
pointing at the block adjacent to the map table, pinning
in memory a block that would otherwise be freed.

Fix by making limit pointer point at last valid entry, not
just past it.

Reviewed by Mike Burrows.

R=golang-dev, bradfitz, lvd, r
CC=golang-dev
https://golang.org/cl/5158045
2011-10-01 13:00:53 -04:00
Mikio Hara
71517e7b4a syscall: update multicast socket options for darwin, freebsd, linux, openbsd
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/5137042
2011-10-01 18:45:06 +09:00
David Symonds
723f73caec freebsd: Add stubs for runtime·osyield and runtime·usleep.
These don't do anything useful; they are just here to fix the build.

R=golang-dev
TBR=r
CC=golang-dev
https://golang.org/cl/5154048
2011-09-30 16:39:10 -07:00
David Symonds
39493be294 io: rename Copyn to CopyN.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5157045
2011-09-30 13:13:39 -07:00
Russ Cox
f18e4e44a3 runtime: disable parallel gc
Breaks on Linux/386 during parallel sync tests.

TBR=r
CC=golang-dev
https://golang.org/cl/5168044
2011-09-30 14:59:46 -04:00
Hector Chu
38d3f58528 runtime: fix windows build
Add osyield and usleep as required by recent GC changes.

R=golang-dev, r, dsymonds, rsc, r
CC=golang-dev
https://golang.org/cl/5156042
2011-09-30 11:33:13 -07:00
Robert Griesemer
a7a7cc5a55 index/suffixarray: 4.5x faster index serialization (to memory)
Benchmark results (best of 3 runs):

old: suffixarray.BenchmarkSaveRestore	       1	1931909000 ns/op	  28.21 MB/s
new: suffixarray.BenchmarkSaveRestore	       5	 429721800 ns/op	 117.14 MB/s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5161043
2011-09-30 11:31:28 -07:00
Rob Pike
40c26fff14 runtime: fix darwin build
Add place holder for runtime.osyield.

R=golang-dev
CC=golang-dev
https://golang.org/cl/5149049
2011-09-30 10:52:36 -07:00
Russ Cox
d324f2143b runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.

On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 	 1 cpu, no atomics
32.27u 0.58s 32.86r 	 1 cpu, atomic instructions
33.04u 0.83s 27.47r 	 2 cpu

On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 	 1 cpu, no atomics
34.87u 1.12s 29.60r 	 2 cpu
36.00u 1.87s 28.43r 	 3 cpu
36.46u 2.34s 27.10r 	 4 cpu
38.28u 3.85s 26.92r 	 5 cpu
37.72u 5.25s 26.73r	 6 cpu
39.63u 7.11s 26.95r	 7 cpu
39.67u 8.10s 26.68r	 8 cpu

On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 	 1 cpu, no atomics
43.98u 2.95s 38.69r 	 2 cpu

On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 	 1 cpu, no atomics
57.15u 4.72s 51.54r 	 2 cpu

The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.

R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 09:40:01 -04:00
Mike Samuel
b0cddb98b9 exp/template/html: avoid redundant escaping directives.
This is a possible optimization.  I'm not sure the complexity is worth it.
The new benchmark in escape_test is 46us without and 35us with the optimization.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5168041
2011-09-29 21:31:41 -07:00
Nigel Tao
585294db73 doc: link to image/draw blog post.
R=adg
TBR=adg
CC=golang-dev
https://golang.org/cl/5154046
2011-09-30 13:11:20 +10:00
Mike Samuel
530719c06f exp/template/html: simplify URL filtering
This removes a few cases from escapeAction and clarifies the
responsibilities of urlFilter which no longer does any
escaping or normalization.  It is now solely a filter.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5162043
2011-09-29 18:09:11 -07:00
Brad Fitzpatrick
357f2cb1a3 exp/sql{,/driver}: new database packages
R=gustavo, rsc, borman, dave, kevlar, nigeltao, dvyukov, kardianos, fw, r, r, david.crawshaw
CC=golang-dev
https://golang.org/cl/4973055
2011-09-29 16:12:21 -07:00
Brad Fitzpatrick
51b09190ac io/ioutil: add a comment on why devNull is a ReaderFrom
... protects this optimization from future well-meaning
Gophers looking to delete unused code. :)

R=gri
CC=golang-dev
https://golang.org/cl/5165041
2011-09-29 15:35:01 -07:00
Luuk van Dijk
8a4ef5d1eb runtime: gdb support, fix pretty printing of channels.
The type to cast the elements to was stolen from a field
that's no longer there.

R=rsc
CC=golang-dev
https://golang.org/cl/5143050
2011-09-29 12:07:38 -07:00
Rob Pike
12ad9b4315 fmt: replace channel cache with slice.
Simpler concept, and it turns a queue into a stack.
Speeds up benchmarks noticeably.

Before:
fmt_test.BenchmarkSprintfEmpty	10000000	       282 ns/op
fmt_test.BenchmarkSprintfString	 2000000	       910 ns/op
fmt_test.BenchmarkSprintfInt	 5000000	       723 ns/op
fmt_test.BenchmarkSprintfIntInt	 1000000	      1071 ns/op
fmt_test.BenchmarkSprintfPrefixedInt	 1000000	      1108 ns/op
fmt_test.BenchmarkScanInts	    1000	   2239510 ns/op
fmt_test.BenchmarkScanRecursiveInt	    1000	   2365432 ns/op

After:
fmt_test.BenchmarkSprintfEmpty	10000000	       232 ns/op
fmt_test.BenchmarkSprintfString	 2000000	       837 ns/op
fmt_test.BenchmarkSprintfInt	 5000000	       590 ns/op
fmt_test.BenchmarkSprintfIntInt	 2000000	       910 ns/op
fmt_test.BenchmarkSprintfPrefixedInt	 2000000	       996 ns/op
fmt_test.BenchmarkScanInts	    1000	   2210715 ns/op
fmt_test.BenchmarkScanRecursiveInt	    1000	   2367800 ns/op

R=rsc, r
CC=golang-dev
https://golang.org/cl/5151044
2011-09-29 11:23:06 -07:00
Rob Pike
1a13f9b810 math: remove the leading F from Fabs etc.
The letter is a holdover from C and unnecessary in Go.
Gofix module included.
Fixes #2306.

R=golang-dev, gri, dsymonds
CC=golang-dev
https://golang.org/cl/5158043
2011-09-29 09:54:20 -07:00
Robert Griesemer
61cc8728fb encoding/binary: PutX functions require buffer of sufficient size.
R=rsc
CC=golang-dev
https://golang.org/cl/5163041
2011-09-29 09:40:59 -07:00
Robert Griesemer
f30719dc89 encoding/binary: support for varint encoding
R=rsc, r, nigeltao, r, dsymonds
CC=golang-dev
https://golang.org/cl/5146048
2011-09-28 22:36:52 -07:00
Mike Samuel
f17e3d2288 exp/template/html: handle custom attrs and HTML5 embedded elements.
HTML5 allows embedded SVG and MathML.
Code searches show SVG is used for graphing.

This changes transition to deal with constructs like
   <svg xmlns:xlink="http://www.w3.org/1999/xlink">
It changes attr and clients to call a single function that combines
the name lookup and "on" prefix check to determine an attribute
value type given an attribute name.

That function uses heuristics to recognize that
     xlink:href and svg:href
have URL content, and that data-url is likely contains URL content,
since "javascript:" injection is such a problem.

I did a code search over a closure templates codebase to determine
patterns of custom attribute usage.  I did something like

$ find . -name \*.soy | \
    xargs egrep perl -ne 'while (s/\b((data-|\w+:)\w+)\s*=//) { print "$1\n"; }' | \
    sort | uniq

to produce the list at the bottom.

Filtering that by egrep -i 'src|url|uri' produces

data-docConsumptionUri
data-docIconUrl
data-launchUrl
data-lazySrc
data-pageUrl
data-shareurl
data-suggestServerUrl
data-tweetUrl
g:secondaryurls
g:url

which seem to match all the ones that are likely URL content.
There are some short words that match that heuristic, but I still think it decent since
any custom attribute that has a numeric or enumerated keyword value will be unaffected by
the URL assumption.
Counterexamples from /usr/share/dict:
during, hourly, maturity, nourish, purloin, security, surly

Custom attributes present in existing closure templates codebase:
buzz:aid
data-a
data-action
data-actor
data-allowEqualityOps
data-analyticsId
data-bid
data-c
data-cartId
data-categoryId
data-cid
data-command
data-count
data-country
data-creativeId
data-cssToken
data-dest
data-docAttribution
data-docConsumptionUri
data-docCurrencyCode
data-docIconUrl
data-docId
data-docPrice
data-docPriceMicros
data-docTitle
data-docType
data-docid
data-email
data-entityid
data-errorindex
data-f
data-feature
data-fgid
data-filter
data-fireEvent
data-followable
data-followed
data-hashChange
data-height
data-hover
data-href
data-id
data-index
data-invitable
data-isFree
data-isPurchased
data-jid
data-jumpid
data-launchUrl
data-lazySrc
data-listType
data-maxVisiblePages
data-name
data-nid
data-nodeid
data-numItems
data-numPerPage
data-offerType
data-oid
data-opUsesEquality
data-overflowclass
data-packageName
data-pageId
data-pageUrl
data-pos
data-priceBrief
data-profileIds
data-query
data-rating
data-ref
data-rentalGrantPeriodDays
data-rentalactivePeriodHours
data-reviewId
data-role
data-score
data-shareurl
data-showGeLe
data-showLineInclude
data-size
data-sortval
data-suggestServerType
data-suggestServerUrl
data-suggestionIndex
data-tabBarId
data-tabBarIndex
data-tags
data-target
data-textColor
data-theme
data-title
data-toggletarget
data-tooltip
data-trailerId
data-transactionId
data-transition
data-ts
data-tweetContent
data-tweetUrl
data-type
data-useAjax
data-value
data-width
data-x
dm:index
dm:type
g:aspects
g:decorateusingsecondary
g:em
g:entity
g:groups
g:id
g:istoplevel
g:li
g:numresults
g:oid
g:parentId
g:pl
g:pt
g:rating_override
g:secondaryurls
g:sortby
g:startindex
g:target
g:type
g:url
g:value
ga:barsize
ga:css
ga:expandAfterCharsExceed
ga:initialNumRows
ga:nocancelicon
ga:numRowsToExpandTo
ga:type
ga:unlockwhenrated
gw:address
gw:businessname
gw:comment
gw:phone
gw:source
ng:controller
xlink:href
xml:lang
xmlns:atom
xmlns:dc
xmlns:jstd
xmlns:ng
xmlns:og
xmlns:webstore
xmlns:xlink

R=nigeltao
CC=golang-dev
https://golang.org/cl/5119041
2011-09-28 14:07:48 -07:00
Mike Samuel
582bb30466 exp/template/html: don't normalize '<' in doctypes.
The normalization that prevents element name and comment injection in
  <{{.}}
by converting it to
  &lt;{{.}}
breaks
  <!DOCTYPE html>

Instead of splitting states to have a start of document state and a text
state, I whitelist <!DOCTYPE.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5131051
2011-09-28 13:32:56 -07:00
Brad Fitzpatrick
7b0f3caa26 strings: add Replacer, NewReplacer
This is just a new API to do many replacements at once.

While the point of this API is to be faster than doing replacements one
at a time, the implementation in this CL has the optimizations removed
and may actually be slower.

Future CLs will bring back & add optimizations.

R=r, rsc, rogpeppe
CC=golang-dev
https://golang.org/cl/5081042
2011-09-28 09:34:26 -07:00
Brad Fitzpatrick
58a5f1e84f http: don't send a 400 Bad Request after a client shutdown
Fixes #2312

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5143049
2011-09-28 09:27:11 -07:00
Russ Cox
32d1e46058 json: use strings.EqualFold instead of strings.ToLower.
R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/5127043
2011-09-28 12:00:45 -04:00
Russ Cox
8f699a3fb9 regexp: speedups
MatchEasy0_1K        500000        4207 ns/op   243.35 MB/s
MatchEasy0_1K_Old    500000        4625 ns/op   221.40 MB/s
MatchEasy0_1M           500     3948932 ns/op   265.53 MB/s
MatchEasy0_1M_Old       500     3943926 ns/op   265.87 MB/s
MatchEasy0_32K        10000      122974 ns/op   266.46 MB/s
MatchEasy0_32K_Old    10000      123270 ns/op   265.82 MB/s
MatchEasy0_32M           10   127265400 ns/op   263.66 MB/s
MatchEasy0_32M_Old       10   127123500 ns/op   263.95 MB/s
MatchEasy1_1K        500000        5637 ns/op   181.63 MB/s
MatchEasy1_1K_Old     10000      100690 ns/op    10.17 MB/s
MatchEasy1_1M           200     7683150 ns/op   136.48 MB/s
MatchEasy1_1M_Old        10   145774000 ns/op     7.19 MB/s
MatchEasy1_32K        10000      239887 ns/op   136.60 MB/s
MatchEasy1_32K_Old      500     4508182 ns/op     7.27 MB/s
MatchEasy1_32M           10   247103500 ns/op   135.79 MB/s
MatchEasy1_32M_Old        1  4660191000 ns/op     7.20 MB/s
MatchMedium_1K        10000      160567 ns/op     6.38 MB/s
MatchMedium_1K_Old    10000      158367 ns/op     6.47 MB/s
MatchMedium_1M           10   162928000 ns/op     6.44 MB/s
MatchMedium_1M_Old       10   159699200 ns/op     6.57 MB/s
MatchMedium_32K         500     5090758 ns/op     6.44 MB/s
MatchMedium_32K_Old     500     5005800 ns/op     6.55 MB/s
MatchMedium_32M           1  5233973000 ns/op     6.41 MB/s
MatchMedium_32M_Old       1  5109676000 ns/op     6.57 MB/s
MatchHard_1K          10000      249087 ns/op     4.11 MB/s
MatchHard_1K_Old       5000      364569 ns/op     2.81 MB/s
MatchHard_1M              5   256050000 ns/op     4.10 MB/s
MatchHard_1M_Old          5   372446400 ns/op     2.82 MB/s
MatchHard_32K           200     7944525 ns/op     4.12 MB/s
MatchHard_32K_Old       100    11609380 ns/op     2.82 MB/s
MatchHard_32M             1  8144503000 ns/op     4.12 MB/s
MatchHard_32M_Old         1 11885434000 ns/op     2.82 MB/s

R=r, bradfitz
CC=golang-dev
https://golang.org/cl/5134049
2011-09-28 12:00:31 -04:00
Brad Fitzpatrick
394842e2a5 net: add shutdown: TCPConn.CloseWrite and CloseRead
R=golang-dev, rsc, iant
CC=golang-dev
https://golang.org/cl/5136052
2011-09-28 08:12:38 -07:00
Mike Samuel
260991ad5f exp/template/html: do not escape the RHS of assignments
In

  {{$x := . | foo}}
  {{$x}}

the first action is a variable assignment that contributes
nothing to the output while the first is a use that needs
to be escaped.

This CL fixes escapeAction to distinguish assignments from
interpolations and to only modify interpolations.

R=nigeltao, r
CC=golang-dev
https://golang.org/cl/5143048
2011-09-27 22:08:14 -07:00
Robert Griesemer
71557713b0 index/suffixarray: revert change from int -> int32
CL 5040041 (https://golang.org/cl/5040041)
changed the use of []int to []int32 internally so
that encoding/binary could be used. This is no
longer needed (gobs can encode ints), and using
[]int is more in sync w/ the semantics of the data
structure (the index elements are indices which are
ints). Changing it back.

R=r
CC=golang-dev
https://golang.org/cl/5141049
2011-09-27 16:21:28 -07:00
Mike Samuel
0287647b13 exp/template/html: add doc comments for undocumented Err... constants.
Does some TODOs and changes the term "div" in an error message
to "division" to avoid confusion with "<div>".

R=nigeltao, r
CC=golang-dev
https://golang.org/cl/5141047
2011-09-27 13:22:01 -07:00
Rob Pike
f3050dbbb5 exp/ssh: update tag usage to new convention.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5136047
2011-09-27 10:22:42 -07:00
Rob Pike
d4507d44a6 archive/zip: fix Fatal call
Error found by govet.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5142048
2011-09-27 09:33:26 -07:00
Russ Cox
7b1c1811a5 crypto/elliptic: use %x consistently in error print
Fixes #2308.

R=agl, gri
CC=golang-dev
https://golang.org/cl/5121052
2011-09-27 09:40:01 -04:00
Ian Lance Taylor
45301ba8c0 runtime: check for nil value pointer in select syncsend case
Fixes #2309.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5128053
2011-09-26 20:46:37 -07:00
Robert Griesemer
9c643bb3fa exp/norm: fix benchmark bug
- don't use range over string to copy string bytes
- some code simplification

R=mpvl
CC=golang-dev
https://golang.org/cl/5144044
2011-09-26 18:23:21 -07:00
Russ Cox
aeaa817140 websocket: remove use of container/vector
R=golang-dev, r
CC=golang-dev, ukai
https://golang.org/cl/5140046
2011-09-26 19:52:34 -04:00
Russ Cox
c68ae9d467 bytes: add EqualFold
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5123047
2011-09-26 19:35:32 -04:00
Rob Pike
4c462e6fd7 gob: protect against invalid message length
Fixes #2301.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5134048
2011-09-26 15:58:01 -07:00
Russ Cox
6c230fbc67 regexp: move to old/regexp, replace with exp/regexp
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5127042
2011-09-26 18:33:13 -04:00
Russ Cox
a8a18f6566 strings: add EqualFold
Case-insensitive strcmp without using ToLower.
(Using ToLower is not always correct, and it allocates.)

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5143044
2011-09-26 18:32:51 -04:00
Russ Cox
ba444d8422 strconv: faster Unquote in common case
Also reject literal newline in " and ' quoted strings.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5139045
2011-09-26 13:59:12 -04:00
Russ Cox
92703ff605 unicode: fix make tables
R=r
CC=golang-dev
https://golang.org/cl/5131044
2011-09-26 13:10:16 -04:00
Dave Cheney
aa2a31e6c4 exp/ssh: move common code to common.go
R=agl
CC=golang-dev
https://golang.org/cl/5132041
2011-09-26 10:25:13 -04:00
Mike Samuel
10bf744772 exp/template/html: make sure marshalled JSON can be parsed as JS.
This makes sure that all JS newlines are encoded in JSON.

It also moots a TODO about possibly escaping supplemental codepoints.
I served:

Content-Type: text/javascript;charset=UTF-8

var s = "%s";
document.write("<p>", s, "</p><ol>");
for (var i = 0; i < s.length; i++) {
  document.write("<li>", s.charCodeAt(i).toString(16), "</li>");
}
document.write("</l>");

where %s was replaced with bytes "\xf0\x9d\x84\x9e" to test
straight UTF-8 instead of encoding surrogates separately.

Recent Firefox, Chrome, and Safari all decoded it properly.
I have yet to try it on IE or older versions.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5129042
2011-09-26 02:10:43 -07:00
Mike Samuel
3771415100 exp/template/html: fix infinite loop in escapeText on bad input
The template
    "<a="
caused an infinite loop in escape text.

The change to tTag fixes that and the change to escape.go causes
escapeText to panic on any infinite loop that does not involve
a state cycle.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5115041
2011-09-26 00:56:49 -07:00
Mike Samuel
66cdd02038 exp/template/html: error out on ambiguous unquoted attributes
HTML parsers may differ on whether
<input id= onchange=f(             ends in id's or onchange's value,
<a class=`foo                      ends inside a value,
<input style=font:'Arial'          needs open-quote fixup.

Per
http://www.w3.org/TR/html5/tokenization.html#attribute-value-unquoted-state
this treats the error cases in 8.2.4.40 Attribute value (unquoted) state
as fatal errors.

\> U+0022 QUOTATION MARK (")
\> U+0027 APOSTROPHE (')
\> U+003C LESS-THAN SIGN (<)
\> U+003D EQUALS SIGN (=)
\> U+0060 GRAVE ACCENT (`)
        Parse error. Treat it as per the "anything else" entry below.

and emits ErrBadHTML.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5085050
2011-09-26 00:42:38 -07:00
Mike Samuel
b3d8e6d7f4 exp/template/html: remove TODO comments that have been done or mooted
R=nigeltao
CC=golang-dev
https://golang.org/cl/5128041
2011-09-26 00:10:21 -07:00
Gustavo Niemeyer
ecda69e667 archive/zip: read and write unix file modes
R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/5124044
2011-09-25 20:48:03 -03:00
David G. Andersen
d53afb8d83 rpc: fix typo in documentation client example
The example incorrectly dereferenced an integer variable

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5129041
2011-09-25 14:19:08 +10:00
Jaroslavas Počepko
10b23e7fc9 syscall: mksyscall_windows.pl to produce packages other than syscall (for example pkg/exp/wingui/zwinapi.go)
R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4964074
2011-09-24 10:38:39 +10:00
Brad Fitzpatrick
cf6d0175d9 http: add Location method to Response
Fixes #2300

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5117041
2011-09-23 10:57:31 -07:00
Mike Samuel
967d68c00a exp/template/html: tighten rules on dynamic attr names.
R=nigeltao
CC=golang-dev
https://golang.org/cl/5076049
2011-09-23 09:25:10 -07:00
Eric Eisner
481e619c50 suffixarray: add benchmarks for construction
R=gri, jeff
CC=golang-dev
https://golang.org/cl/5040048
2011-09-23 09:18:10 -07:00
Mikio Hara
17410d75d0 syscall: add GetsockoptByte, SetsockoptByte for openbsd
R=golang-dev, fullung, dave, rsc
CC=golang-dev
https://golang.org/cl/5081044
2011-09-23 23:39:19 +09:00
Mikio Hara
4e2f2c7704 syscall: add IPv4 ancillary data for linux
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5039042
2011-09-23 23:38:52 +09:00
Mikio Hara
33a15eb6c0 net: make use of AF_UNSPEC instead of individual address family
R=fullung, rsc
CC=golang-dev
https://golang.org/cl/5034044
2011-09-23 23:37:42 +09:00
Luuk van Dijk
46ed89b7a3 runtime: gdb support: gracefully handle not being able to find types
The Dwarf info has the full typenames, the go *struct runtime.commonType
has the short name.  A more permanent fix would link the two together
but this way the user gets useable stack traces for now.

R=rsc
CC=golang-dev
https://golang.org/cl/5097046
2011-09-23 10:28:02 +02:00
Alex Brainman
7249fa773a syscall: mark stdin, stdout and stderr as non-inheritable by child process
Fixes #2250.

R=golang-dev, hectorchu
CC=golang-dev, vincent.vanackere
https://golang.org/cl/5086050
2011-09-23 18:16:13 +10:00
Fumitoshi Ukai
e4790b5fa4 websocket: add mutex to make websocket full-duplex
One benefit of websocket is that it is full-duplex so that it could
send and receive at the same time.
This CL makes websocket goroutine safe, so user could use websocket
both on goroutine for read and on goroutine for write.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5058043
2011-09-22 21:49:24 -04:00
Andrew Gerrand
76d82dbc4c doc: link to image blog post
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5086048
2011-09-23 07:22:28 +10:00
Mike Samuel
35819729b8 exp/template/html: elide comments in template source.
When templates are stored in external files, developers often embed
comments to explain&|disable code.

  <!-- Oblique reference to project code name here -->
  {{if .C}}...{{else}}<!-- commented out default -->{{end}}

This unnecessarily increases the size of shipped HTML and can leak
information.

This change elides all comments of the following types:
1. <!-- ... --> comments found in source.
2. /*...*/ and // comments found in <script> elements.
3. /*...*/ and // comments found in <style> elements.

It does not elide /*...*/ or // comments found in HTML attributes:
4. <button onclick="/*...*/">
5. <div style="/*...*/">

I can find no examples of comments in attributes in Closure Templates
code and doing so would require keeping track of character positions
post decode in

  <button onclick="/&#42;...*/">

To prevent token joining, /*comments*/ are JS and CSS comments are
replaced with a whitespace char.
HTML comments are not, but to prevent token joining we could try to
detect cases like
   <<!---->b>
   </<!---->b>
which has a well defined meaning in HTML but will cause a validator
to barf.  This is difficult, and this is a very minor case.
I have punted for now, but if we need to address this case, the best
way would be to normalize '<' in stateText to '&lt;' consistently.

The whitespace to replace a JS /*comment*/ with depends on whether
there is an embedded line terminator since
    break/*
    */foo
    ...
is equivalent to
    break;
    foo
    ...
while
    break/**/foo
    ...
is equivalent to
    break foo;
    ...

Comment eliding can interfere with IE conditional comments.
http://en.wikipedia.org/wiki/Conditional_comment

<!--[if IE 6]>
<p>You are using Internet Explorer 6.</p>
<![endif]-->

/*@cc_on
  document.write("You are using IE4 or higher");
@*/

I have not encountered these in production template code, and
the typed content change in CL 4962067 provides an escape-hatch
if conditional comments are needed.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4999042
2011-09-21 21:38:40 -07:00
Mike Samuel
1f577d26d7 exp/template/html: simplify transition functions
This simplifies transition functions to make it easier to reliably
elide comments in a later CL.

Before:
- transition functions are responsible for detecting special end tags.
After:
- the code to detect special end tags is done in one place.

We were relying on end tags being skipped which meant we were
not noticing comments inside script/style elements that contain no
substitutions.
This change means we will notice all such comments where necessary,
but stripTags will notice none since it does not need to.  This speeds
up stripTags.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5074041
2011-09-21 19:04:41 -07:00
Robert Griesemer
3e02fff007 gob: slightly simpler decodeUint
R=r
CC=golang-dev
https://golang.org/cl/5089048
2011-09-21 14:47:00 -07:00
Robert Griesemer
91a48115bb gob: slightly simpler code for encodeUint
R=r
CC=golang-dev
https://golang.org/cl/5077047
2011-09-21 14:18:48 -07:00
Gustavo Niemeyer
d16ceca5c5 bytes: fix Replace so it actually copies
The documentation for bytes.Replace says it copies
the slice but it won't necessarily copy them.  Since
the data is mutable, breaking the contract is an issue.

We either have to fix this by making the copy at all
times, as suggested in this CL, or we should change the
documentation and perhaps make better use of the fact
it's fine to mutate the slice in place otherwise.

R=golang-dev, bradfitz, adg, rsc
CC=golang-dev
https://golang.org/cl/5081043
2011-09-21 12:36:17 -03:00
Brad Fitzpatrick
96f968df9c http: add a (disabled) test for TLS handshake timeouts
It's currently broken and disabled, pending a fix
for Issue 2281.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5092045
2011-09-21 08:30:47 -07:00
Mike Samuel
1262f6bde7 exp/template/html: fix bug, '<' normalization for text nodes that change context
R=nigeltao
CC=golang-dev
https://golang.org/cl/5080042
2011-09-20 22:55:14 -07:00
Robert Griesemer
5ee7ef90cd suffixarray: improved serialization code
Use gobs to serialize indexes instead of encoding/binary.

Even with gobs, serialize data in slices instead of
applying gob to the entire data structure at once,
to reduce the amount of extra buffer memory needed
inside gob.

7x faster Write/Read for new BenchmarkSaveRestore
compared to old code; possibly because encoding/binary
is more expensive for int32 slice elements (interface
call to get little/big endian encoding), while gob's
encoding is fixed (unconfirmed).

new (using gobs):
suffixarray.BenchmarkSaveRestore	       1	2153604000 ns/op

old (using encoding/binary):
suffixarray.BenchmarkSaveRestore	       1	15118322000 ns/op

The actual serialized data is slightly larger then using
the old code for very large indices because full 32bit indices
require 5bytes using gobs instead of 4bytes (encoding/binary)
in serialized form.

R=r
CC=golang-dev
https://golang.org/cl/5087041
2011-09-20 14:36:19 -07:00
Rob Pike
86e65bac5c reflect: add comment about the doubled semantics of Value.String.
R=rsc
CC=golang-dev
https://golang.org/cl/5091044
2011-09-20 13:26:57 -07:00
Brad Fitzpatrick
76e705310a httptest: add NewUnstartedServer
This allows testing TLS with different http.Server
options (timeouts, limits).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5094043
2011-09-20 13:02:10 -07:00
Rob Pike
9ddc2b5688 gob: fix allocation for singletons.
Code was double-allocating in some cases.
Fixes #2267.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5093042
2011-09-20 11:28:00 -07:00
Dave Cheney
fd3978552b exp/ssh: refactor halfConnection to transport
This CL generalises the pair of halfConnection members that the
        serverConn holds into a single transport struct that is shared by
        both Server and Client, see also CL 5037047.

        This CL is a replacement for 5040046 which I closed by accident.

R=agl, bradfitz
CC=golang-dev
https://golang.org/cl/5075042
2011-09-20 12:21:50 -04:00
Mike Samuel
3a013f1175 exp/template/html: change transition functions to return indices
Formulaic changes to transition functions in preparation for CL 5074041.
This should be completely semantics preserving.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5091041
2011-09-19 20:52:14 -07:00
Brad Fitzpatrick
3c3a86ccc7 http: fix TLS handshake blocking server accept loop
Fixes #2263

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5076042
2011-09-19 19:56:51 -07:00
Mike Samuel
8bc5ef6cd7 exp/template/html: allow commenting out of actions
Instead of erroring on actions inside comments, use existing escaping
pipeline to quash the output of actions inside comments.

If a template maintainer uses a comment to disable template code:

  {{if .}}Hello, {{.}}!{{end}}

->

  <!--{{if true}}Hello, {{.}}!{{end}}-->

will result in

  <!--Hello, !-->

regardless of the value of {{.}}.

In a later CL, comment elision will result in the entire commented-out
section being dropped from the template output.

Any side-effects in pipelines, such as panics, will still be realized.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5078041
2011-09-19 19:52:31 -07:00
Mike Samuel
533b372280 exp/template/html: define isComment helper
Non semantics-changing refactoring in preparation for comment elision.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5071043
2011-09-19 17:27:49 -07:00
Rob Pike
bf595ba1c2 gob: don't allocate a slice if there's room to decode already
Fixes #2275.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5082041
2011-09-19 16:55:08 -07:00
Dave Grijalva
80700eb817 http: always include Content-Length header, even for 0
fixes #2221

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4952052
2011-09-19 11:41:09 -07:00
Dmitriy Vyukov
ab596cae9e sync/atomic: replace MFENCE with LOCK XADD
MFENCE was introduced only on the Pentium4 (SSE2),
while XADD was introduced on the 486.
Fixes #2268.

R=golang-dev, rsc
CC=fshahriar, golang-dev
https://golang.org/cl/5056045
2011-09-19 11:09:00 -07:00
Eric Eisner
6f18233373 suffixarray: generate less garbage during construction
Minorly improves runtime by about 2-3%

R=gri, jeff
CC=golang-dev
https://golang.org/cl/5052045
2011-09-19 11:03:43 -07:00
Brad Fitzpatrick
6b6cb725e9 http: prevent DumpRequest from adding implicit headers
Fixes #2272

R=rsc
CC=golang-dev
https://golang.org/cl/5043051
2011-09-19 10:22:53 -07:00
Russ Cox
24257a1ea2 json: clearer Unmarshal doc
R=r
CC=golang-dev
https://golang.org/cl/5056049
2011-09-19 13:19:07 -04:00
Brad Fitzpatrick
48ff4a849c http: check explicit wrong Request.ContentLength values
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5070041
2011-09-19 09:01:32 -07:00
Russ Cox
fc5889d4ff json: skip nil in UnmarshalJSON and (for symmetry) MarshalJSON
R=dsymonds, r
CC=golang-dev
https://golang.org/cl/5050049
2011-09-19 11:50:41 -04:00
Andrey Mirtchovski
003bfa0e26 net: use /etc/hosts first when looking up IP addresses using native Go's dns resolver
Previously /etc/hosts would be ignored altogether, this change returns matching results
from that file without talking to a DNS server.

R=rsc
CC=golang-dev
https://golang.org/cl/5061042
2011-09-19 11:50:31 -04:00
Marcel van Lohuizen
46468357a2 exp/norm: Adopt regexp to exp/regexp semantics.
R=rsc
CC=golang-dev
https://golang.org/cl/5046041
2011-09-19 17:30:19 +02:00
Dave Cheney
03178bb4ad exp/ssh: fix constant in package documentation
R=agl
CC=golang-dev
https://golang.org/cl/5030054
2011-09-19 10:32:11 -04:00
Jeff Hodges
d072a70823 crypto/bcrypt: new package
A port of Provos and Mazières's adapative hashing algorithm. See http://www.usenix.org/events/usenix99/provos/provos_html/node1.html

R=bradfitz, agl, rsc, dchest
CC=golang-dev
https://golang.org/cl/4964078
2011-09-19 10:29:02 -04:00
Jeff Hodges
5d5d7f1229 crypto/blowfish: exposing the blowfish key schedule
Mostly useful for the coming crypto/bcrypt package

R=bradfitz, agl, rsc, agl
CC=golang-dev
https://golang.org/cl/5013043
2011-09-19 10:21:34 -04:00
Mike Samuel
b4e1ca25b1 exp/template/html: allow quotes on either side of conditionals and dynamic HTML names
This addresses several use cases:

(1) <h{{.HeaderLevel}}> used to build hierarchical documents.
(2) <input on{{.EventType}}=...> used in widgets.
(3) <div {{" dir=ltr"}}> used to embed bidi-hints.

It also makes sure that we treat the two templates below the same:

<img src={{if .Avatar}}"{{.Avatar}}"{{else}}"anonymous.png"{{end}}>
<img src="{{if .Avatar}}{{.Avatar}}{{else}}anonymous.png{{end}}">

This splits up tTag into a number of sub-states and adds testcases.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5043042
2011-09-18 19:10:15 -07:00
Mike Samuel
52a46bb773 exp/template/html: normalize '<' in text and RCDATA nodes.
The template

  <{{.}}

would violate the structure preservation property if allowed and not
normalized, because when {{.}} emitted "", the "<" would be part of
a text node, but if {{.}} emitted "a", the "<" would not be part of
a text node.

This change rewrites '<' in text nodes and RCDATA text nodes to
'&lt;' allowing template authors to write the common, and arguably more
readable:

    Your price: {{.P1}} < list price {{.P2}}

while preserving the structure preservation property.

It also lays the groundwork for comment elision, rewriting

    Foo <!-- comment with secret project details --> Bar

to

    Foo  Bar

R=nigeltao
CC=golang-dev
https://golang.org/cl/5043043
2011-09-18 12:04:40 -07:00
Mike Samuel
e213a0c0fc exp/template/html: recognize whitespace at start of URLs.
HTML5 uses "Valid URL potentially surrounded by spaces" for
attrs: http://www.w3.org/TR/html5/index.html#attributes-1

    <a href=" {{.}}">

should be escaped to filter out "javascript:..." as data.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5027045
2011-09-18 11:55:14 -07:00
Adam Langley
605e57d8fe exp/ssh: new package.
The typical UNIX method for controlling long running process is to
send the process signals. Since this doesn't get you very far, various
ad-hoc, remote-control protocols have been used over time by programs
like Apache and BIND.

Implementing an SSH server means that Go code will have a standard,
secure way to do this in the future.

R=bradfitz, borman, dave, gustavo, dsymonds, r, adg, rsc, rogpeppe, lvd, kevlar, raul.san
CC=golang-dev
https://golang.org/cl/4962064
2011-09-17 15:57:24 -04:00
Mike Rosset
b71a805cd5 archive/tar: document Header fields and Type flags
Documentation more along the lines of os.FileInfo
Fixes #2180.

R=golang-dev, dsymonds
CC=golang-dev, mike.rosset
https://golang.org/cl/4958055
2011-09-17 11:43:06 -07:00
Hector Chu
6bc0346e28 runtime: increase stack system space on windows/amd64
gotest src/pkg/exp/template/html was crashing because the exception handler overflowed the goroutine stack.

R=alex.brainman, golang-dev
CC=golang-dev
https://golang.org/cl/5031049
2011-09-17 20:39:29 +10:00
Hector Chu
a506c96ab2 runtime/pprof: enable test on windows
R=alex.brainman
CC=golang-dev
https://golang.org/cl/5047045
2011-09-17 18:00:32 +10:00
Hector Chu
9fd26872cb runtime: implement pprof support for windows
Credit to jp for proof of concept.

R=alex.brainman, jp, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/4960057
2011-09-17 17:57:59 +10:00
Michael Shields
44f12eb5ad filepath: fix Glob to return no error on nonmatching patterns
filepath.Glob is documented to return nil if no files match
and an error only if the pattern is invalid.  This change
fixes it to work as documented and adds a regression test.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5040045
2011-09-16 20:30:54 -07:00
Robert Griesemer
ae4f1c4c3a reflect: fix comment
R=r
CC=golang-dev
https://golang.org/cl/5039045
2011-09-16 15:07:13 -07:00
Yasuhiro Matsumoto
048ec75801 http/cgi: clean up environment.
clean up duplicate environment for CGI.
overriding former by latter.
On windows, When there are duplicated environments like following,

SCRIPT_FILENAME=c:/progra~1/php/php-cgi.exe
SCRIPT_FILENAME=/foo.php

CreateProcess use first entry.

If make cgi.Handle like following,

        cgih = cgi.Handler{
                Path: "c:/strawberry/perl/bin/perl.exe",
                Dir:  "c:/path/to/webroot",
                Root: "c:/path/to/webroot",
                Args: []string{"foo.php"},
                Env:  []string{"SCRIPT_FILENAME=foo.php"},
        }

http/cgi should behave "SCRIPT_FILENAME is foo.php".
But currently, http/cgi is set duplicate environment entries.
So, browser show binary dump of "php-cgi.exe" that is specified indented
SCRIPT_FILENAME in first entry.
This change clean up duplicates, and use latters.

R=golang-dev, bradfitz, bradfitz
CC=golang-dev
https://golang.org/cl/5010044
2011-09-16 10:36:54 -07:00
Marcel van Lohuizen
a083fd524a exp/norm: reverting to using strings.Repeat, as it doesn't look like exp/regexp
is going to support returning multiple matches for a single repeated group.

R=r, rsc, mpvl
CC=golang-dev
https://golang.org/cl/5014045
2011-09-16 11:28:53 +02:00
Marcel van Lohuizen
1913fdab98 exp/norm: changed trie to produce smaller tables.
Trie now uses sparse block when this makes sense.

R=r, r
CC=golang-dev
https://golang.org/cl/5010043
2011-09-16 11:27:05 +02:00
Mike Samuel
a399040226 exp/template/html: type fixed point computation in template
I found a simple test case that does require doing the fixed point TODO
in computeOutCtx.

I found a way though to do this and simplify away the escapeRange
hackiness that was added in https://golang.org/cl/5012044/

R=nigeltao
CC=golang-dev
https://golang.org/cl/5015052
2011-09-16 00:34:26 -07:00
Alex Brainman
310e5fe60c net: reuse channels during io
R=golang-dev, bsiegert, rsc, hectorchu
CC=golang-dev
https://golang.org/cl/5016043
2011-09-16 13:40:02 +10:00
Mike Samuel
96f9e8837e exp/template/html: moved error docs out of package docs onto error codes
This replaces the errStr & errLine members of context with a single err
*Error, and introduces a number of const error codes, one per
escape-time failure mode, that can be separately documented.

The changes to the error documentation moved from doc.go to error.go
are cosmetic.

R=r, nigeltao
CC=golang-dev
https://golang.org/cl/5026041
2011-09-15 19:05:33 -07:00
Robert Griesemer
bd80b1198b index/suffixarray: support for serialization
R=r
CC=golang-dev
https://golang.org/cl/5040041
2011-09-15 16:21:21 -07:00
Brad Fitzpatrick
f5181ae9d7 textproto: parse RFC 959 multiline responses correctly
Fixes #2218

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5037041
2011-09-15 14:29:59 -07:00
Brad Fitzpatrick
e30b9fd87e http: MaxBytesReader doc cleanups
Comments from rsc after 4921049 was submitted.

R=rsc
CC=golang-dev
https://golang.org/cl/5034042
2011-09-15 14:26:22 -07:00
Brad Fitzpatrick
758b62bf6a http: document that Response.Body is non-nil
Fixes #2208

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5011051
2011-09-15 14:09:53 -07:00
Russ Cox
1505cae05d flag: make zero FlagSet useful
This makes it possible to use a FlagSet as a
field in a larger struct.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5036041
2011-09-15 17:04:51 -04:00
Russ Cox
2715956f13 build: add build comments to core packages
The go/build package already recognizes
system-specific file names like

        mycode_darwin.go
        mycode_darwin_386.go
        mycode_386.s

However, it is also common to write files that
apply to multiple architectures, so a recent CL added
to go/build the ability to process comments
listing a set of conditions for building.  For example:

        // +build darwin freebsd openbsd/386

says that this file should be compiled only on
OS X, FreeBSD, or 32-bit x86 OpenBSD systems.

These conventions are not yet documented
(hence this long CL description).

This CL adds build comments to the multi-system
files in the core library, a step toward making it
possible to use go/build to build them.

With this change go/build can handle crypto/rand,
exec, net, path/filepath, os/user, and time.

os and syscall need additional adjustments.

R=golang-dev, r, gri, r, gustavo
CC=golang-dev
https://golang.org/cl/5011046
2011-09-15 16:48:57 -04:00
Russ Cox
ef32eaceef go/build: change //build to // +build
New rules as discussed on CL 5011046.
Also apply to C and assembly files, not just Go files.

R=r, rogpeppe
CC=golang-dev
https://golang.org/cl/5015051
2011-09-15 16:48:21 -04:00
Brad Fitzpatrick
b955e26564 http/cgi: add openbsd environment configuration
R=iant, iant
CC=golang-dev
https://golang.org/cl/5016051
2011-09-15 12:41:00 -07:00
Brad Fitzpatrick
7233dcde99 http: fix WriteProxy documentation
Fixes #2258

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5016048
2011-09-15 10:28:55 -07:00
Russ Cox
6430f46e4b go/build: fix build (revert test changes)
R=adg
TBR=adg
CC=golang-dev
https://golang.org/cl/5024046
2011-09-15 12:34:34 -04:00
Russ Cox
17bebd3caa go/build: handle cgo, //build comments
R=adg
CC=golang-dev
https://golang.org/cl/5018044
2011-09-15 12:11:41 -04:00
Mike Samuel
ce008f8c37 exp/template/html: pre-sanitized content
Not all content is plain text.  Sometimes content comes from a trusted
source, such as another template invocation, an HTML tag whitelister,
etc.

Template authors can deal with over-escaping in two ways.

1) They can encapsulate known-safe content via
   type HTML, type CSS, type URL, and friends in content.go.
2) If they know that the for a particular action never needs escaping
   then they can add |noescape to the pipeline.
   {{.KnownSafeContent | noescape}}
   which will prevent any escaping directives from being added.

This CL defines string type aliases: HTML, CSS, JS, URI, ...
It then modifies stringify to unpack the content type.
Finally it modifies the escaping functions to use the content type and
decline to escape content that does not require it.

There are minor changes to escapeAction and helpers to treat as
equivalent explicit escaping directives such as "html" and "urlquery"
and the escaping directives defined in the contextual autoescape module
and to recognize the special "noescape" directive.

The html escaping functions are rearranged.  Instead of having one
escaping function used in each {{.}} in

    {{.}} : <textarea title="{{.}}">{{.}}</textarea>

a slightly different escaping function is used for each.
When {{.}} binds to a pre-sanitized string of HTML

    `one < <i>two</i> &amp; two < "3"`

we produces something like

     one < <i>two</i> &amp; two < "3" :
     <textarea title="one &lt; two &amp; two &lt; &#34;3&#34;">
       one &lt; &lt;i&gt;two&lt;/i&gt; &amp; two &lt; "3"
     </textarea>

Although escaping is not required in <textarea> normally, if the
substring </textarea> is injected, then it breaks, so we normalize
special characters in RCDATA and do the same to preserve attribute
boundaries.  We also strip tags since developers never intend
typed HTML injected in an attribute to contain tags escaped, but
do occasionally confuse pre-escaped HTML with HTML from a
tag-whitelister.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/4962067
2011-09-15 08:51:55 -07:00
Robert Griesemer
957fd575fc go/token: support to serialize file sets
R=rsc
CC=golang-dev
https://golang.org/cl/5024042
2011-09-14 20:45:45 -07:00
Mike Samuel
3eb41fbeb6 exp/template/html: render templates unusable when escaping fails
This moots a caveat in the proposed package documentation by
rendering useless any template that could not be escaped.

From https://golang.org/cl/4969078/
> If EscapeSet returns an error, do not Execute the set; it is not
> safe against injection.
r: [but isn't the returned set nil? i guess you don't overwrite the
r: original if there's a problem, but i think you're in your rights to
r: do so]

R=r
CC=golang-dev
https://golang.org/cl/5020043
2011-09-14 20:40:50 -07:00
Hector Chu
5c30325983 runtime: eliminate handle churn when churning channels on Windows
The Windows implementation of the net package churns through a couple of channels for every read/write operation.  This translates into a lot of time spent in the kernel creating and deleting event objects.

R=rsc, dvyukov, alex.brainman, jp
CC=golang-dev
https://golang.org/cl/4997044
2011-09-14 20:23:21 -04:00
Ian Lance Taylor
e076c502dd debug/elf: permit another case of SHT_NOBITS section overlap in test
Lets test pass when using gccgo.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5018046
2011-09-14 15:33:37 -07:00
David Symonds
3be088e354 json: if a field's tag is "-", never encode it.
R=adg, r, edsrzf, rsc, r
CC=golang-dev
https://golang.org/cl/4962052
2011-09-15 08:09:43 +10:00
Mike Samuel
23fab11c47 exp/template/html: flesh out package documentation.
R=nigeltao, r
CC=golang-dev
https://golang.org/cl/4969078
2011-09-14 14:21:20 -07:00
Rob Pike
b47bbecf7a src: fix a couple of govet-discovered errors.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5021042
2011-09-14 13:29:31 -07:00
Adam Langley
a775fbf8a4 crypto/tls: support SSLv3
It would be nice not to have to support this since all the clients
that we care about support TLSv1 by now. However, due to buggy
implementations of SSLv3 on the Internet which can't do version
negotiation correctly, browsers will sometimes switch to SSLv3. Since
there's no good way for a browser tell a network problem from a buggy
server, this downgrade can occur even if the server in question is
actually working correctly.

So we need to support SSLv3 for robustness :(

Fixes #1703.

R=bradfitz
CC=golang-dev
https://golang.org/cl/5018045
2011-09-14 15:32:19 -04:00
Mike Samuel
514c9243f2 exp/template/html: check that modified nodes are not shared by templates
R=nigeltao
CC=golang-dev
https://golang.org/cl/5012044
2011-09-14 11:52:03 -07:00
Rob Pike
7edfcede13 path/filepath: document that Walk sorts its output
R=golang-dev, cw
CC=golang-dev
https://golang.org/cl/5004045
2011-09-14 11:18:43 -07:00
Robert Griesemer
1007a11924 go/printer: use panic/defer instead of goroutine
for handling errors

Fixes #2249.

R=rsc
CC=golang-dev
https://golang.org/cl/4952071
2011-09-14 08:49:21 -07:00
Russ Cox
e81d72100a websocket: rename websocket.WebSocketAddr to *websocket.Addr.
R=ukai
CC=golang-dev
https://golang.org/cl/4999043
2011-09-14 11:29:11 -04:00
Russ Cox
33d00fae30 runtime: track HeapIdle
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4995045
2011-09-14 11:29:01 -04:00
Mikio Hara
fa767ff231 image/jpeg: fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/5020045
2011-09-14 11:14:03 -04:00
Nigel Tao
1a35450a10 image/draw: unbreak build for image.NewXxx change.
TBR=rsc
CC=golang-dev
https://golang.org/cl/5016044
2011-09-14 22:09:46 +10:00
Nigel Tao
aa75bee7a5 image: change the NewXxx functions to take a Rectangle instead of
taking (w, h int).

R=rsc, bsiegert, r
CC=golang-dev
https://golang.org/cl/4964073
2011-09-14 21:39:49 +10:00
Alex Brainman
7406379fff runtime: syscall to return both AX and DX for windows/386
Fixes #2181.

R=golang-dev, jp
CC=golang-dev
https://golang.org/cl/5000042
2011-09-14 16:19:45 +10:00
Mike Samuel
2b3b5cf4de template: add doc.go to Makefile
The template package is the only one that has a doc.go not mentioned
in its Makefile.

This doesn't seem to bother godoc, but seems like a bug to me.

$ for d in $(find pkg -name doc.go); do echo $d; grep doc.go $(dirname $d)/Makefile; done
pkg/fmt/doc.go
        doc.go\
pkg/go/doc/doc.go
        doc.go\
pkg/gob/doc.go
        doc.go\
pkg/html/doc.go
        doc.go\
pkg/old/template/doc.go
        doc.go\
pkg/sync/atomic/doc.go
        doc.go\
pkg/template/doc.go

R=r
CC=golang-dev
https://golang.org/cl/5003047
2011-09-13 18:50:02 -07:00
Mike Samuel
15d47ce219 exp/template/html: move transition functions to a separate file
This CL moves code but makes no changes otherwise.

R=nigeltao, r
CC=golang-dev
https://golang.org/cl/5012045
2011-09-13 17:53:55 -07:00
Rob Pike
4e3b725cf0 path/filepath: new signature for Walk
This one uses a closure than an interface, and is much simpler to use.
It also enables a called function to return an error and (possibly)
halt processing.

Fixes #2237.

R=golang-dev, gri, rsc, r, cw, n13m3y3r
CC=golang-dev
https://golang.org/cl/5014043
2011-09-13 17:47:59 -07:00
Mike Samuel
4c6454aecf exp/template/html: escape {{template}} calls and sets of templates
This adds support for {{template "callee"}} calls.
It recognizes that calls can appear in many contexts.

{{if .ImageURL}}
    <img src="{{.ImageURL}}" alt="{{template "description"}}">
{{else}}
    <p>{{template "description"}}</p>
{{end}}

calls a template in two different contexts, first in an HTML attribute
context, and second in an HTML text context.

Those two contexts aren't very different, but when linking text
to search terms, the escaping context can be materially different:

<a href="/search?q={{template "tags"}}">{{template "tags"}}</a>

This adds API:
EscapeSet(*template.Set, names ...string) os.Error

takes a set of templates and the names of those which might be called
in the default context as starting points.

It changes the escape* functions to be methods of an object which
maintains a conceptual mapping of
(template names*input context) -> output context.

The actual mapping uses as key a mangled name which combines the
template name with the input context.

The mangled name when the input context is the default context is the
same as the unmangled name.

When a template is called in multiple contexts, we clone the template.

{{define "tagLink"}}
  <a href="/search?q={{template "tags"}}">{{template "tags"}}</a>
{{end}}
{{define "tags"}}
  {{range .Tags}}{{.}},{{end}}
{{end}}

given []string{ "foo", "O'Reilly", "bar" } produces

  <a href="/search?q=foo,O%27Reilly,bar">foo,O&#39;Reilly,bar</a>

This involves rewriting the above to something like

{{define "tagLink"}}
  <a href="/search?q={{template "tags$1"}}">{{template "tags"}}</a>
{{end}}
{{define "tags"}}
  {{range .Tags}}{{. | html}},{{end}}
{{end}}
{{define "tags$1"}}
  {{range .Tags}}{{. | urlquery}},{{end}}
{{end}}

clone.go provides a mechanism for cloning template "tags" to produce
"tags$1".

changes to escape.go implement the new API and context propagation
around the call graph.

context.go includes minor changes to support name mangling and
context_test.go tests those.

js.go contains a bug-fix.

R=nigeltao, r
CC=golang-dev
https://golang.org/cl/4969072
2011-09-13 16:57:39 -07:00
Ian Lance Taylor
9377b28833 http: Alphabetize imports.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5002043
2011-09-13 09:38:26 -07:00
Ian Lance Taylor
096f3a293e os: Fix comment in generated signal_unix.go file.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5013042
2011-09-13 09:38:08 -07:00
Marcel van Lohuizen
efea5d0fb9 exp/norm: Added regression test tool for the standard Unicode test set.
R=r
CC=golang-dev
https://golang.org/cl/4973064
2011-09-13 12:51:48 +02:00
Nigel Tao
40d85fb097 net: add a LookupTXT function.
This CL only supports Unix, not Plan 9 or Windows.

R=rsc
CC=golang-dev
https://golang.org/cl/4996048
2011-09-13 13:05:33 +10:00
Alex Brainman
cd269b0c2b time: another attempt to fix windows build
R=bradfitz
CC=golang-dev
https://golang.org/cl/4967067
2011-09-13 12:42:24 +10:00
Brad Fitzpatrick
29d5d9a5bb time: fix Windows build after ceeedb519c4a
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4983060
2011-09-12 17:18:25 -07:00
Mike Samuel
0432a23c68 exp/template/html: tolerate '/' ambiguity in JS when it doesn't matter.
Often, division/regexp ambiguity doesn't matter in JS because the next
token is not a slash.

For example, in

  <script>var global{{if .InitVal}} = {{.InitVal}}{{end}}</script>

When there is an initial value, the {{if}} ends with jsCtxDivOp
since a '/' following {{.InitVal}} would be a division operator.
When there is none, the empty {{else}} branch ends with jsCtxRegexp
since a '/' would start a regular expression.  A '/' could result
in a valid program if it were on a new line to allow semicolon
insertion to terminate the VarDeclaration.

There is no '/' though, so we can ignore the ambiguity.

There are cases where a missing semi can result in ambiguity that
we should report.

  <script>
  {{if .X}}var x = {{.X}}{{end}}
  /...{{.Y}}
  </script>

where ... could be /foo/.test(bar) or /divisor.  Disambiguating in
this case is hard and is required to sanitize {{.Y}}.

Note, that in the case where there is a '/' in the script tail but it
is not followed by any interpolation, we already don't care.  So we
are already tolerant of

<script>{{if .X}}var x = {{.X}}{{end}}/a-bunch-of-text</script>

because tJS checks for </script> before looking in /a-bunch-of-text.

This CL
- Adds a jsCtx value: jsCtxUnknown
- Changes joinContext to join contexts that only differ by jsCtx.
- Changes tJS to return an error when a '/' is seen in jsCtxUnknown.
- Adds tests for both the happy and sad cases.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4956077
2011-09-12 16:37:03 -07:00
Mike Samuel
80a5ddbdb1 exp/template/html: fix bug /*/ is not a full JS block comment.
Similar tests for CSS already catch this problem in tCSS.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4967065
2011-09-12 16:01:30 -07:00
Russ Cox
3b189d8f9c crypto/tls: handle non-TLS more robustly
Fixes #2253.

R=agl
CC=golang-dev
https://golang.org/cl/4960066
2011-09-12 16:52:49 -04:00
Robert Griesemer
7944bbf2d2 godoc, suffixarray: switch to exp/regexp
R=rsc
CC=golang-dev
https://golang.org/cl/4983058
2011-09-12 12:20:48 -07:00
Gustavo Niemeyer
817da66576 path/filepath: fix Visitor doc
The path is not in fact relative to the root, but
joined to it.

R=golang-dev, adg, rsc, gustavo
CC=golang-dev
https://golang.org/cl/4977059
2011-09-12 16:18:48 -03:00
Rob Pike
7d43b84282 time: make Weekday a method.
Weekday is redundant information for a Time structure.
When parsing a time with a weekday specified, it can create an
incorrect Time value.
When parsing a time without a weekday specified, people
expect the weekday to be set.
Fix all three problems by computing the weekday on demand.

This is hard to gofix, since we must change the type of the node.
Since uses are rare and existing code will be caught by the compiler,
there is no gofix module here.

Fixes #2245.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4974077
2011-09-12 11:47:55 -07:00
Russ Cox
9c6265d339 exp/regexp/syntax: fix invalid input parser crash
Reported by Kyle Lemons.

R=r
CC=golang-dev
https://golang.org/cl/4992045
2011-09-12 14:03:53 -04:00
Tarmigan Casebolt
73fd9e7d93 websocket: Fix infinite recursion in WebSockAddr String()
String() is already inherited from the embedded *url.URL

R=ukai, adg, rsc
CC=golang-dev
https://golang.org/cl/4992049
2011-09-12 13:48:56 -04:00
Marcel van Lohuizen
3e42de29c9 exp/norm: fixed typo. Bug exposed by gomake testtables. Changes did not affect other tests
as this part of Hangul is handled algorithmically.

R=r
CC=golang-dev
https://golang.org/cl/4951074
2011-09-12 10:21:35 +02:00
Nigel Tao
b2b3187f5e exp/template/html: fix JS regexp escape of an empty string.
R=dsymonds
CC=golang-dev, mikesamuel
https://golang.org/cl/4972063
2011-09-12 11:57:34 +10:00
Nigel Tao
a5d0b7ee3e image/png: don't use a goroutine to decode. This was preventing
decoding during an init function.

Fixes #2224.

R=rsc
CC=golang-dev
https://golang.org/cl/4964070
2011-09-10 09:51:13 +10:00
Andrew Gerrand
3bc2d0f20b doc: link to notable blog posts
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4996041
2011-09-10 09:35:25 +10:00
Yasuhiro Matsumoto
3301e5a4f5 path/filepath: make UNC file names work
Fixes #2201

R=golang-dev, r, rsc, alex.brainman, robert.hencke, jp
CC=golang-dev
https://golang.org/cl/4950051
2011-09-09 17:38:29 +10:00
Mike Samuel
1f13423d3e exp/template/html: Grammar rules for HTML comments and special tags.
Augments type context and adds grammatical rules to handle special HTML constructs:
    <!-- comments -->
    <script>raw text</script>
    <textarea>no tags here</textarea>

This CL does not elide comment content.  I recommend we do that but
have not done it in this CL.

I used a codesearch tool over a codebase in another template language.

Based on the below I think we should definitely recognize
  <script>, <style>, <textarea>, and <title>
as each of these appears frequently enough that there are few
template using apps that do not use most of them.

Of the other special tags,
  <xmp>, <noscript>
are used but infrequently, and
  <noframe> and friend, <listing>
do not appear at all.

We could support <xmp> even though it is obsolete in HTML5
because we already have the machinery, but I suggest we do not
support noscript since it is a normal tag in some browser
configurations.

I suggest recognizing and eliding <!-- comments -->
(but not escaping text spans) as they are widely used to
embed comments in template source.  Not eliding them increases
the size of content sent over the network, and risks leaking
code and project internal details.
The template language I tested elides them so there are
no instance of IE conditional compilation directives in the
codebase but that could be a source of confusion.

The codesearch does the equivalent of
$ find . -name \*.file-extension \
  | perl -ne 'print "\L$1\n" while s@<([a-z][a-z0-9])@@i' \
  | sort | uniq -c | sort

The 5 uses of <plaintext> seem to be in tricky code and can be ignored.
The 2 uses of <xmp> appear in the same tricky code and can be ignored.
I also ignored end tags to avoid biasing against unary
elements and threw out some nonsense names since since the
long tail is dominated by uses of < as a comparison operator
in the template languages expression language.

I have added asterisks next to abnormal elements.

  26765 div
   7432 span
   7414 td
   4233 a
   3730 tr
   3238 input
   2102 br
   1756 li
   1755 img
   1674 table
   1388 p
   1311 th
   1064 option
    992 b
    891 label
    714 script *
    519 ul
    446 tbody
    412 button
    381 form
    377 h2
    358 select
    353 strong
    318 h3
    314 body
    303 html
    266 link
    262 textarea *
    261 head
    258 meta
    225 title *
    189 h1
    176 col
    156 style *
    151 hr
    119 iframe
    103 h4
    101 pre
    100 dt
     98 thead
     90 dd
     83 map
     80 i
     69 object
     66 ol
     65 em
     60 param
     60 font
     57 fieldset
     51 string
     51 field
     51 center
     44 bidi
     37 kbd
     35 legend
     30 nobr
     29 dl
     28 var
     26 small
     21 cite
     21 base
     20 embed
     19 colgroup
     12 u
     12 canvas
     10 sup
     10 rect
     10 optgroup
     10 noscript *
      9 wbr
      9 blockquote
      8 tfoot
      8 code
      8 caption
      8 abbr
      7 msg
      6 tt
      6 text
      6 h5
      5 svg
      5 plaintext *
      5 article
      4 shortquote
      4 number
      4 menu
      4 ins
      3 progress
      3 header
      3 content
      3 bool
      3 audio
      3 attribute
      3 acronym
      2 xmp *
      2 overwrite
      2 objects
      2 nobreak
      2 metadata
      2 description
      2 datasource
      2 category
      2 action

R=nigeltao
CC=golang-dev
https://golang.org/cl/4964045
2011-09-09 00:07:40 -07:00
Jaroslavas Počepko
75dd952d16 os: forgotten file of submitted CL 4984051
R=alex.brainman
CC=golang-dev
https://golang.org/cl/4983053
2011-09-09 09:39:23 +10:00
Mike Samuel
4670d9e634 exp/template/html: autoescape actions in HTML style attributes.
This does not wire up <style> elements as that is pending support
for raw text content in CL https://golang.org/cl/4964045/

This CL allows actions to appear in contexts like

selectors:        {{.Tag}}{{.Class}}{{.Id}}
property names:   border-{{.BidiLeadingEdge}}
property values:  color: {{.Color}}
strings:          font-family: "{{font-name}}"
URL strings:      background: "/foo?image={{.ImgQuery}}"
URL literals:     background: url("{{.Image}}")

but disallows actions inside CSS comments and disallows
embedding of JS in CSS entirely.

It is based on the CSS3 lexical grammar with affordances for
common browser extensions including line comments.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4968058
2011-09-09 07:18:20 +10:00
Russ Cox
66b3fabf17 exp/regexp: add MustCompilePOSIX
R=r
CC=golang-dev
https://golang.org/cl/4962060
2011-09-08 15:00:49 -04:00
Russ Cox
21e671dee6 exp/regexp: add CompilePOSIX, more tests
R=r
CC=golang-dev
https://golang.org/cl/4967060
2011-09-08 14:49:51 -04:00
Russ Cox
177dca77e1 exp/regexp/syntax: import all RE2 parse tests + fix bugs
R=r
CC=golang-dev
https://golang.org/cl/4952061
2011-09-08 14:18:02 -04:00
Mikio Hara
940932056e syscall: add route flags for linux
R=golang-dev
CC=golang-dev
https://golang.org/cl/4956069
2011-09-08 13:59:34 -04:00
Russ Cox
7df4322114 exp/regexp: leftmost-longest matching
Not exposed in the API yet, but passes tests.

R=r
CC=golang-dev
https://golang.org/cl/4967059
2011-09-08 10:09:25 -04:00
Dmitriy Vyukov
cf0d8c0941 sync/atomic: add 64-bit Load and Store
R=rsc
CC=golang-dev
https://golang.org/cl/4977054
2011-09-08 11:58:48 +04:00
Jaroslavas Počepko
571d3f50d3 os: os.RemoveAll has to check for 2 error codes on Windows. ENOENT is not enough.
os.Lstat can return ENOTDIR as well.

R=golang-dev, r, alex.brainman
CC=golang-dev, rsc
https://golang.org/cl/4984051
2011-09-08 17:27:41 +10:00
Paul Lalonde
bb8bbb2908 Windows: net, syscall: implement SetsockoptIPMReq(), move to winsock v2.2 for multicast support.
I don't know the protocol regarding the zsyscall files which appear to
be hand-generated, so I've re-done them and added them to the change.

R=rsc, alex.brainman, nigeltao
CC=golang-dev
https://golang.org/cl/4975060
2011-09-08 16:32:40 +10:00
Alex Brainman
794489ecf3 sync/atomic: do not run TestStoreLoadSeq for too long (fix windows builder)
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4962057
2011-09-08 13:31:40 +10:00
Robert Griesemer
49bcc88f79 undo CL 4964067 / 661cb84cc6f0
API change. Needs further reflection.

««« original CL description
path/filepath: Simplify Walk interface

The last argument of filepath.Walk was removed, and the Visitor
interface now contains an Error method that is called on errors.

Fixes #2237.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/4964067

»»»

R=r
CC=golang-dev
https://golang.org/cl/4974065
2011-09-07 15:19:53 -07:00
Gustavo Niemeyer
e5c20dc270 path/filepath: Simplify Walk interface
The last argument of filepath.Walk was removed, and the Visitor
interface now contains an Error method that is called on errors.

Fixes #2237.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/4964067
2011-09-07 14:49:48 -07:00
Russ Cox
ef01ebf403 net: sync CIDRMask code, doc
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4961069
2011-09-07 15:50:07 -04:00
Russ Cox
08ae1a5a23 exp/regexp: bug fixes and RE2 tests
Also add exp/regexp to build (forgot before).

At this point I am very confident in exp/regexp's
behavior.  It should be usable as a drop-in
replacement for regexp now.

Later CLs could introduce a CompilePOSIX
to get at traditional POSIX ``extended regular expressions''
as in egrep and also an re.MatchLongest method to
change the matching mode to leftmost longest
instead of leftmost first.  On the other hand, I expect
very few people to use either.

R=r, r, gustavo
CC=golang-dev
https://golang.org/cl/4990041
2011-09-07 15:48:06 -04:00
Mikio Hara
a2c2c87439 net: ParseCIDR returns IPNet instead of IPMask
Note that this CL will break your existing code which uses
ParseCIDR.

This CL changes ParseCIDR("172.16.253.121/28") to return
the IP address "172.16.253.121", the network implied by the
network number "172.16.253.112" and mask "255.255.255.240".

R=rsc, borman
CC=golang-dev
https://golang.org/cl/4749043
2011-09-07 14:01:12 -04:00
Ziad Hatahet
21e49cbb2d sort: use heapsort to bail out quicksort
See http://research.swtch.com/2008/01/killing-quicksort.html for more
info.
Fixes #467.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4591051
2011-09-07 13:54:33 -04:00
Dmitriy Vyukov
1fc676332f sync/atomic: add Store functions
R=rsc
CC=golang-dev
https://golang.org/cl/4950060
2011-09-07 21:50:51 +04:00
Russ Cox
299f524d90 image/png: check zlib checksum during Decode
R=nigeltao
CC=golang-dev
https://golang.org/cl/4987041
2011-09-07 13:23:16 -04:00
Robert Griesemer
61650b21d6 cleanup: gofmt -s -w src misc
R=r
CC=golang-dev
https://golang.org/cl/4984052
2011-09-06 16:04:55 -07:00
Rob Pike
62b10ad0ba template: slightly simplify the test for assignability of arguments
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4951066
2011-09-06 15:59:21 -07:00
Rob Pike
d45e808c91 template: indirect or dereference function arguments if necessary to match the type of the formal.
Fixes #2235

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4967056
2011-09-06 15:34:38 -07:00
Robert Griesemer
0783dd9027 go/parser: accept corner cases of signature syntax
- func f(int,) is a legal signature
- func f(...int,) is a legal signature

Defer checking for correct use of "..." with last
paremeter type to type checker instead of parser.

R=rsc
CC=golang-dev
https://golang.org/cl/4973059
2011-09-06 11:48:05 -07:00
Robert Griesemer
c10679009a gofmt: indent multi-line signatures
There may be more fine-tuning down the line,
but this CL fixes the most pressing issue at
hand.

Also: gofmt -w src misc

Fixes #1524.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4975053
2011-09-06 11:27:36 -07:00
Russ Cox
686181edfe url: handle ; in ParseQuery
Most web frameworks allow ; as a synonym for &,
following a recommendation in some versions of
the HTML specification.  Do the same.

Remove overuse of Split.

Move ParseQuery tests from package http to package url.

Fixes #2210.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4973062
2011-09-06 12:24:24 -04:00
Alex Brainman
37f390aa20 os: use GetFileAttributesEx to implement Stat on windows
Fixes #2129.

R=rsc
CC=golang-dev
https://golang.org/cl/4934049
2011-09-06 09:59:08 +10:00
Marcel van Lohuizen
d5e24b6975 exp/norm: performance improvements of quickSpan
- fixed performance bug that could lead to O(n^2) behavior
- performance improvement for ASCII case

R=r, r
CC=golang-dev
https://golang.org/cl/4956060
2011-09-05 19:09:20 +02:00
Joel Sing
c7f6f9f318 runtime: fix openbsd 386 raisesigpipe
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4950064
2011-09-05 13:05:57 -04:00
Mikio Hara
73d27dd5ba syscall: update routing message attributes handling, fix typo
R=fullung, golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4986041
2011-09-05 08:11:51 -04:00
Mike Rosset
8ddd66145e build: clear execute bit from Go files
R=golang-dev, rsc
CC=golang-dev, mike.rosset
https://golang.org/cl/4950062
2011-09-05 07:48:42 -04:00
Christopher Wedgwood
6cf61bb5b9 runtime: add test for multiple concurrent channel consumers
There was a time (in the past) when this wasn't robust.

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/4965058
2011-09-05 07:40:50 -04:00
Robert Hencke
1f523e2579 websocket: fix incorrect prints found by govet
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4963059
2011-09-05 10:56:39 +10:00
Hector Chu
9b011500c0 runtime: implement exception handling on windows/amd64
Fixes #2194.

R=rsc, alex.brainman, vcc.163, jp
CC=golang-dev
https://golang.org/cl/4977044
2011-09-03 18:27:16 +10:00
Nigel Tao
2b6d3b498c exp/template/html: string replacement refactoring.
R=mikesamuel
CC=golang-dev
https://golang.org/cl/4968063
2011-09-03 10:30:05 +10:00