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

7437 Commits

Author SHA1 Message Date
Russ Cox
ad7dea1e96 gc: handle complex CONVNOP
Fixes #2256.

R=ken2
CC=golang-dev
https://golang.org/cl/5044047
2011-09-19 11:50:53 -04:00
Dave Cheney
f554c90cef 8l: remove left over debugging
This line was triggering a null dereference warning
        under clang-3.0. The line was added in a46819aa9150
        but compared to it's sibling in 6l it appears to be
        leftover debugging.

R=rsc
CC=golang-dev
https://golang.org/cl/5049042
2011-09-19 11:50:45 -04: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
642d272c3c godoc: remove dependency of syscall
On app-engine, we cannot import syscall.
The respective constants are already defined
elsewhere for the same reason.

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/5036042
2011-09-15 16:47:01 -07:00
Robert Griesemer
66e44000d4 godoc: use new index/suffixarray serialization code
When saving/restoring the fulltext index, the entire
respective suffixarray is now saved/restored (as opposed
to the indexed data only, and the suffixarray recreated).
This saves significant start-up time for large indexes,
at the cost of significantly larger index files.

R=r
CC=golang-dev
https://golang.org/cl/5037043
2011-09-15 16:21:42 -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
bb0c8b3b66 godoc: use go/build to find files in a package
Fixes #1156.
Fixes #2172.

R=gri
CC=golang-dev
https://golang.org/cl/5015044
2011-09-15 16:49:06 -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
d76c4a52e7 godoc: support for complete index serialization
- now fulltext index information is saved/restored
- minor updates to appinit.go

R=rsc
CC=golang-dev
https://golang.org/cl/5024043
2011-09-14 20:46:03 -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
b039883946 gofmt: add else test
R=gri
CC=golang-dev
https://golang.org/cl/4978065
2011-09-14 11:29:18 -04: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
Russ Cox
9fc687392c gc: clean up if grammar
Fixes #2248.

R=ken2
CC=golang-dev
https://golang.org/cl/4978064
2011-09-12 15:52:29 -04:00
Russ Cox
48e9c771a1 gofmt: accept program fragments on standard input
This makes it possible to grab a block of code
in an editor and pipe it through gofmt, instead of
having to pipe in the entire file.

R=gri
CC=golang-dev
https://golang.org/cl/4973074
2011-09-12 15:41: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
Luuk van Dijk
ac1b9545e3 ld: grow dwarf includestack on demand.
Fixes #2241
while not breaking issue 1878 again.

R=rsc
CC=golang-dev
https://golang.org/cl/4988048
2011-09-09 15:08:57 +02: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
Robert Griesemer
041dc0a1c2 godoc: show packages matching a query at the top
Also: fix layout of textual search results and
fix a field reference in the respective template.

Fixes #1987.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4962061
2011-09-08 15:35:56 -07: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
1e480cd1ad gc: add -p flag to catch import cycles earlier
The linker would catch them if gc succeeded,
but too often the cycle manifests as making the
current package and the imported copy of itself
appear as different packages, which result in
type signature mismatches that confuse users.

As a crutch, add the -p flag to say 'if you see an
import of this package, give up early'.  Results in
messages like (during gotest in sort):

export_test.go:7: import "sort" while compiling that package (import cycle)
export_test.go:7: import "container/heap": package depends on "sort" (import cycle)

Fixes #2042.

R=ken
CC=bradfitz, dsymonds, golang-dev
https://golang.org/cl/4972057
2011-09-07 15:50:21 -04: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
Hector Chu
aed2c06dcb 5a, 5c, 6a, 6c, 8a, 8c: fix Windows file paths
Verified with objdump -W.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4974061
2011-09-07 15:49:56 -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
Lucio De Re
4ba677c6ea gc: silence Plan 9 warnings
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4975055
2011-09-07 13:55:48 -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
Hector Chu
7b2f214b6c gopprof: regexp fixes
Extract Windows filenames correctly.
Don't remove receivers from method names.

Fixes #2227.

R=rsc
CC=golang-dev
https://golang.org/cl/4969059
2011-09-07 13:53:29 -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
Luuk van Dijk
f2460a8c57 gc: treat DOTMETH like DOT in escape analysis.
Fixes #2225

R=rsc, nigeltao, dave
CC=bradfitz, golang-dev, mikioh.mikioh
https://golang.org/cl/4972056
2011-09-07 19:03:11 +02: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
Russ Cox
5ddf6255a1 gc: unify stack frame layout
allocparams + tempname + compactframe
all knew about how to place stack variables.

Now only compactframe, renamed to allocauto,
does the work.  Until the last minute, each PAUTO
variable is in its own space and has xoffset == 0.

This might break 5g.  I get failures in concurrent
code running under qemu and I can't tell whether
it's 5g's fault or qemu's.  We'll see what the real
ARM builders say.

R=ken2
CC=golang-dev
https://golang.org/cl/4973057
2011-09-06 10:24:21 -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
Russ Cox
919cb2ec7c gc: fix zero-length struct eval
Fixes #2232.

R=ken2
CC=golang-dev
https://golang.org/cl/4960054
2011-09-05 15:31:22 -04: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
Gustavo Niemeyer
c5670f1548 gofix: do not convert url in field names
There's some ambiguity in the U{url: url} case as it could be
both a map or a struct literal, but given context it's more
likely a struct, so U{url: url_} rather than U{url_: url_}.
At least that was the case for me.

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/4972052
2011-09-03 16:01:54 -03: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
Russ Cox
9854fd2a0e gc: introduce temp = nod+tempname
R=ken2
CC=golang-dev
https://golang.org/cl/4967052
2011-09-02 15:35:16 -04:00
Russ Cox
c45c0c0c1d gc: zero stack-allocated slice backing arrays
Fixes Han-Wen's termite bug.

R=lvd
CC=golang-dev
https://golang.org/cl/4977052
2011-09-02 15:11:28 -04:00
Robert Griesemer
cd6f319a76 godoc: minor tweaks for app-engine use
- read search index files in groutine to avoid
  start-up failure on app engine because reading
  the files takes too long
- permit usage of search index files and indexer
- minor cosmetic cleanups

R=dsymonds
CC=golang-dev
https://golang.org/cl/4952050
2011-09-02 10:07:29 -07:00
Marcel van Lohuizen
2517143957 exp/norm: added Reader and Writer and bug fixes to support these.
Needed to ensure that finding the last boundary does not result in O(n^2)-like behavior.
Now prevents lookbacks beyond 31 characters across the board (starter + 30 non-starters).
composition.go:
- maxCombiningCharacters now means exactly that.
- Bug fix.
- Small performance improvement/ made code consistent with other code.
forminfo.go:
- Bug fix: ccc needs to be 0 for inert runes.
normalize.go:
- A few bug fixes.
- Limit the amount of combining characters considered in FirstBoundary.
- Ditto for LastBoundary.
- Changed semantics of LastBoundary to not consider trailing illegal runes a boundary
  as long as adding bytes might still make them legal.
trie.go:
- As utf8.UTFMax is 4, we should treat UTF-8 encodings of size 5 or greater as illegal.
  This has no impact on the normalization process, but it prevents buffer overflows
  where we expect at most UTFMax bytes.

R=r
CC=golang-dev
https://golang.org/cl/4963041
2011-09-02 12:39:35 +02:00
Rob Pike
b349cd2b0a fmt/fmt_test.go: count mallocs in a few more cases.
Interesting that Fprintf can do zero mallocs.
(Sprintf must allocate the returned string.)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4977049
2011-09-02 11:47:15 +10:00
Rob Pike
2cf66c1d94 template: fix deadlock.
No need for lexInsideAction to loop.
Fixes #2217.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4963054
2011-09-02 11:00:46 +10:00
Mike Samuel
5edeef214d exp/template/html: non-semantics changing tweaks to js{,_test}.go
R=nigeltao
CC=golang-dev
https://golang.org/cl/4962049
2011-09-02 10:28:00 +10:00
Andrew Gerrand
3fa7226de7 goinstall: better usage message
Fixes #2185.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4967046
2011-09-02 10:07:47 +10:00
Dmitriy Vyukov
ea23ba3e2d sync/atomic: add LoadUintptr
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4985041
2011-09-01 15:17:25 -04:00
Russ Cox
60d47101aa gc: fix label recursion bugs
Was keeping a pointer to the labeled statement in n->right,
which meant that generic traversals of the tree visited it twice.
That combined with aggressive flattening of the block
structure when possible during parsing meant that
the kinds of label: code label: code label: code sequences
generated by yacc were giving the recursion 2ⁿ paths
through the program.

Fixes #2212.

R=lvd
CC=golang-dev
https://golang.org/cl/4960050
2011-09-01 13:44:46 -04:00
Dave Cheney
ae502c4e02 libmach: fix incorrect use of memset
Fixes #2213.

R=rsc
CC=golang-dev
https://golang.org/cl/4975047
2011-09-01 13:43:03 -04:00
Mike Rosset
420934348d sudo.bash: print error/exit if problem with /usr/local/bin
When installing profiling tools on Mac OS X print
message if there is a problem with /usr/local/bin

Fixes #2209.

R=golang-dev, r, adg
CC=golang-dev, mike.rosset
https://golang.org/cl/4950057
2011-09-01 17:24:32 +10:00
Mike Samuel
0253c688d0 exp/template/html: Implement grammar for JS.
This transitions into a JS state when entering any attribute whose
name starts with "on".

It does not yet enter a JS on entry into a <script> element as script
element handling is introduced in another CL.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4968052
2011-09-01 12:03:40 +10:00
Mikio Hara
7c203b8bc1 unsafe: update doc
changeset: 8812:3fb3e88d5aa8
gc: unsafe.Alignof, unsafe.Offsetof, unsafe.Sizeof now return uintptr

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4951051
2011-08-31 17:59:35 -04:00
Russ Cox
2cc4a54dec flag: add Parsed, restore Usage
R=r
CC=golang-dev
https://golang.org/cl/4973050
2011-08-31 17:38:41 -04:00
Robert Griesemer
3f1269ff1e godoc: more index size reduction
- KindRuns don't need to repeat SpotKind,
  it is stored in each Spot
- removed extra indirection from FileRuns
  to KindRuns
- slight reduction of written index size
  (~500KB)

R=rsc
CC=golang-dev
https://golang.org/cl/4969052
2011-08-31 14:01:58 -07:00
Dmitriy Vyukov
a31f317a99 rpc: add benchmark for async rpc calls
Also makes sync benchmark concurrent.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4911043
2011-08-31 13:07:25 -04:00
Mikio Hara
0c6581cc25 syscall: handle routing entry in ParseRoutingSockaddr on BSD variants
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4972053
2011-08-31 13:05:49 -04:00
Russ Cox
0c9ea63b3b cgo: explain how to free something
R=golang-dev, n13m3y3r, r
CC=golang-dev
https://golang.org/cl/4958053
2011-08-31 08:17:01 -04:00
Russ Cox
335da67e00 gc: make static initialization more static
Does as much as possible in data layout instead
of during the init function.

Handles var x = y; var y = z as a special case too,
because it is so prevalent in package unicode
(var Greek = _Greek; var _Greek = []...).

Introduces InitPlan description of initialized data
so that it can be traversed multiple times (for example,
in the copy handler).

Cuts package unicode's init function size by 8x.
All that remains there is map initialization, which
is on the chopping block too.

Fixes sinit.go test case.

Aggregate DATA instructions at end of object file.

Checkpoint.  More to come.

R=ken2
CC=golang-dev
https://golang.org/cl/4969051
2011-08-31 07:37:14 -04:00
Russ Cox
5f40c5b384 runtime: handle string + char literals in goc2c
My string literal was being rewritten from
"runtime.SysReserve(%p, %D) = error %d"
to
"runtime.SysReserve ( %p , %D ) = error %d"

R=iant
CC=golang-dev
https://golang.org/cl/4972051
2011-08-31 07:11:31 -04:00
Russ Cox
4304de6e0c runtime: make arm work on Ubuntu Natty qemu
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4963050
2011-08-31 07:02:46 -04:00
Gustavo Niemeyer
0cfa0fe242 cgo: note that CString result must be freed
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4968054
2011-08-31 06:44:55 -03:00
Jaroslavas Počepko
95429d82f1 exp/wingui: made compatible with windows/amd64
R=golang-dev, alex.brainman
CC=golang-dev, vcc.163
https://golang.org/cl/4974041
2011-08-31 15:39:50 +10:00
Brad Fitzpatrick
7349d21f8e http: add file protocol transport
Off by default (security risk), but users can
wire it up if desired.

Fixes #2113

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4959049
2011-08-30 21:47:41 -07:00
Robert Griesemer
40f0a0d759 godoc index: first step towards reducing index size
- canonicalize package descriptors
- remove duplicate storage of file paths
- reduces (current) written index file by approx 3.5MB
(from 28434237B to 24686643B, or 13%)

- next step: untangle DAG (when serializing, using
gob, the index dag explodes into an index tree)

R=dsymonds
CC=golang-dev
https://golang.org/cl/4983042
2011-08-30 18:47:15 -07:00
Jaroslavas Počepko
68a04dce93 image: add PalettedImage interface, and make image/png recognize it.
R=golang-dev, rsc, bradfitz, nigeltao
CC=golang-dev
https://golang.org/cl/4956046
2011-08-31 08:27:00 +10:00
Gustavo Niemeyer
e1cfb6f3a9 cgo: fix GoBytes
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4956051
2011-08-30 14:33:16 -03:00
Lucio De Re
4ca2172f38 gc: fix for Plan 9 build
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4977045
2011-08-30 09:40:46 -04:00
Russ Cox
4fb3c4f765 gc: fix div bug
R=ken2
CC=golang-dev
https://golang.org/cl/4950052
2011-08-30 08:47:28 -04:00
Jaroslavas Počepko
c586b5b96b runtime: windows/amd64 callbacks fixed and syscall fixed to allow using it in callbacks
Fixes #2178.
Patch2: Fixed allocating shadow space for stdcall (must be at least 32 bytes in any case)
Patch3: Made allocated chunk smaller.
Patch4: Typo
Patch5: suppress linktime warning "runtime.callbackasm: nosplit stack overflow"
Patch6: added testcase src/pkg/syscall/callback_windows_test.go
Patch7: weakly related files moved to https://golang.org/cl/4965050 https://golang.org/cl/4974041 https://golang.org/cl/4965051
Patch8: reflect changes https://golang.org/cl/4926042/
Patch9: reflect comments

R=golang-dev, alex.brainman, vcc.163
CC=golang-dev, hectorchu
https://golang.org/cl/4958042
2011-08-30 22:02:02 +10:00
Lucio De Re
2d489e67dc gc: fix for Plan 9 build
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4975044
2011-08-30 08:00:07 -04:00
Jaroslavas Počepko
ae891b5528 windows/386: clean stack after syscall (it is necessary after call cdecl functions and does not have an effect after stdcall)
Result of discussion here: http://groups.google.com/group/golang-nuts/browse_thread/thread/357c806cbb57ca62

R=golang-dev, bradfitz, alex.brainman, hectorchu, rsc
CC=golang-dev
https://golang.org/cl/4961045
2011-08-30 14:43:54 +10:00
Mike Samuel
22d5f9aae3 exp/template/html: Added handling for URL attributes.
1. adds a urlPart field to context
2. implements tURL to figure out the URL part
3. modifies joinContext to allow common context mismatches
   around branches to be ignored when not material as in
   <a href="/foo{{if .HasQuery}}?q={{.Query}}{{/if}}">
4. adds a pipeline function that filters dynamically inserted
   protocols to prevent code injection via URLs.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4957041
2011-08-30 11:42:30 +10:00
Robert Griesemer
d01ee38fb0 godoc: support for reading/writing (splitted) index files.
This CL implements a new godoc feature to save the search
index on disk. Use -write_index to create the search
index file named with -index_files. Use -index_files to
provide a glob pattern specifying index file(s) when
starting godoc; in this case the run-time indexer is not
run.

Known issues:
- saving/restoring full text index is not yet supported
- the list of flags and overall usage logic could use a
  cleanup

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/4974045
2011-08-29 17:22:20 -07:00
Robert Griesemer
6b90262870 godoc: fix bug in zip.go
The result of sort.Search is in the interval [0,n);
specifically, if no entry is found, the result is n
and not -1.

R=dsymonds
CC=golang-dev
https://golang.org/cl/4982041
2011-08-29 16:49:31 -07:00
Andrew Gerrand
58b05e2448 goinstall: select the tag that is closest to runtime.Version
release.r50 looks for newest tag <= go.r50
weekly.2010-10-10 looks for newest tag <= go.2010-10-10

Implements behavior for hg, git, and bzr.

R=dsymonds, rsc, n13m3y3r
CC=golang-dev
https://golang.org/cl/4873057
2011-08-30 09:37:22 +10:00
Brad Fitzpatrick
596bf61d6c json: add struct tag option to wrap literals in strings
Since JavaScript doesn't have [u]int64 types, some JSON APIs
encode such types as strings to avoid losing precision.

This adds a new struct tag option ",string" to cause
fields to be wrapped in JSON strings on encoding
and unwrapped from strings when decoding.

R=rsc, gustavo
CC=golang-dev
https://golang.org/cl/4918051
2011-08-29 12:46:32 -07:00
Mateusz Czapliński
eae0a48cf5 libmach: support reading symbols from Windows .exe for nm
Fixes #979.

R=rsc, alex.brainman
CC=golang-dev, vcc.163
https://golang.org/cl/4894051
2011-08-29 14:25:43 -04:00
Mike Rosset
af8b1271eb archive/tar: when writing tar Headers write hdr.Linkname
This should allow symlinks in tar files. Where previously
as far as I can see they were skipped completely.

R=golang-dev, dsymonds, rsc, bradfitz, bradfitz
CC=golang-dev, mike.rosset
https://golang.org/cl/4973044
2011-08-29 11:01:03 -07:00
Joel Sing
1075af0cce runtime: add openbsd 386 defs.h
Missed in previous change (4951043).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4967044
2011-08-29 11:07:19 -04:00
Russ Cox
3693cd2988 runtime: add runtime· prefix to showframe
R=ken2
CC=golang-dev
https://golang.org/cl/4978042
2011-08-29 10:55:21 -04:00
Mikio Hara
683df29f7c net: change the internal form of IPMask for IPv4
This CL changes the internal form of IPMask for IPv4
from 16-byte to 4-byte, also adds Size method to IPMask
struct and changes output string format of IPMask.String
method.

R=rsc
CC=golang-dev
https://golang.org/cl/4950046
2011-08-29 10:49:03 -04:00
Gustavo Niemeyer
1952eb5010 os: fix WNOHANG Waitmsg
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4962042
2011-08-29 10:45:37 -04:00
Joel Sing
9ef17990c2 runtime: add runtime support for openbsd 386
Add openbsd 386 runtime support, partially based on the existing
freebsd 386 runtime.

This requires change 4973043.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4951043
2011-08-29 10:42:16 -04:00
Yuval Pavel Zholkover
c20a338c2f runtime, syscall: use the vdso page on linux x86 for faster syscalls instead of int $0x80.
8l: fix handling CALL $(constant) code generated by 8a.
8a,8l: add indirect call instruction: CALL *data(SB).

R=rsc, iant
CC=golang-dev
https://golang.org/cl/4817054
2011-08-29 10:36:06 -04:00
Joel Sing
88e984faa5 syscall: add openbsd 386
Add openbsd 386 syscall support, partially based on the existing
freebsd 386 syscall implementation.

FTR zerrors_openbsd_386.go cannot currently be completely built on
openbsd/i386 due to what appears to be a gcc bug. The constants can be
successfully generated with -m32 on openbsd/amd64 and the error
table can then be generated on openbsd/i386.

R=rsc
CC=golang-dev
https://golang.org/cl/4969045
2011-08-29 10:04:28 -04:00
Joel Sing
8aa2591b13 runtime: openbsd thread tweaks
- Rename sys_sched_yield() to osyield() as this is now defined in asm.h.
- Only print kern.rtheads message if rfork_thread() failed with ENOTSUP.
- Remove unused variables.

R=rsc
CC=golang-dev
https://golang.org/cl/4973043
2011-08-29 09:35:13 -04:00
Fazlul Shahriar
45bd7b07e5 time: fix Plan 9 build
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4966045
2011-08-29 09:35:08 -04:00
Lucio De Re
b3cc4897be gc: fix build on Plan 9
gc/bits.c
. improved format with associated cast;
gc/closure.c
gc/dcl.c
gc/range.c
gc/reflect.c
gc/sinit.c
. dropped unnecessary assignments;
gc/gen.c
. dropped unnecessary assignment;
. added static qualifier to local function definition;
gc/go.h
. added varargck pragmas;
gc/lex.c
. used {} instead of ; in if statement to suppress warning;
. replaced exit(0) with exits(0);
. added compilation conditions for SIGBUS/SIGSEGV;
. dropped unnecessary assignment;
gc/mparith2.c
. dropped four unnecessary assignments/initialisations;
gc/obj.c
. added type cast to local pointer;
gc/pgen.c
. added cast and related print format;
gc/subr.c
. replaced exit(1) with exits("error");
. replaced unlink() with remove();
. renamed local cistrmp() as ucistrmp() to remove conflict with
  Plan 9 function by the same name;
gc/swt.c
. added braces instead of ; as empty statment;
gc/typecheck.c
. added static qualifier to local function definition;
. dropped unnecessary assignments;
gc/walk.c
. dropped unnecessary assignments;
. added static qualifier to local function definitions;

R=rsc
CC=golang-dev
https://golang.org/cl/4964046
2011-08-29 09:35:04 -04:00
Lucio De Re
219c9e9c46 6g: fix build on Plan 9
src/cmd/6g/cgen.c
src/cmd/6g/gobj.c
src/cmd/6g/reg.c
. dropped unused assignments;
src/cmd/6g/gg.h
. added varargck pragmas;
src/cmd/6g/list.c
. adjusted print format for ulong casts;
src/cmd/6g/peep.c
. dropped redundant increment;

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4953049
2011-08-29 09:34:59 -04:00
Lucio De Re
65276933cd 5g: fix build on Plan 9
5g/cgen.c:
. USED(n4) as it is only mentioned in unreachable code later;
. dropped unused assignments;
. commented out unreachable code;
5g/cgen64.c:
5g/ggen.c:
. dropped unused assignments of function return value;
5g/gg.h:
. added varargck pragmas;
5g/peep.c:
. USED(p1) used only in unreacheable code;
. commented out unreachable code;
5g/reg.c:
. dropped unused assignment;

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4953048
2011-08-29 09:34:52 -04:00
Hector Chu
0f5902d6be runtime: fix stack cleanup on windows/amd64
In amd64 it is the caller who cleans the stack.

R=alex.brainman, vcc.163, jp
CC=golang-dev
https://golang.org/cl/4966046
2011-08-29 22:12:56 +10:00
Rob Pike
361c5ace05 template: range over channel
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4951046
2011-08-29 15:56:52 +10:00
Russ Cox
77f0bdce07 gc: fix arm build
Escape analysis was incorrectly assuming that
functions without bodies don't leak their
parameters.  This meant that sync/atomic's
TestAddInt64 was allocating x on its stack,
and then x was not properly aligned for use
with the atomic 64-bit instructions.  Obviously
we should figure out the alignment story on 5g
too, but this fix is correct and should restore the
build to 'ok'.

TBR=lvd
CC=golang-dev
https://golang.org/cl/4964047
2011-08-28 23:29:34 -04:00
Jaroslavas Počepko
f627215bab runtime: go interface to cdecl calbacks
cdecl calbacks have been implemented in C/ASM code, just Go function is missing

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/4969047
2011-08-29 10:40:28 +10:00
Russ Cox
db5f9da425 gc: tweak and enable escape analysis
-s now means *disable* escape analysis.

Fix escape leaks for struct/slice/map literals.
Add ... tracking.
Rewrite new(T) and slice literal into stack allocation when safe.

Add annotations to reflect.
Reflect is too chummy with the compiler,
so changes like these affect it more than they should.

R=lvd, dave, gustavo
CC=golang-dev
https://golang.org/cl/4954043
2011-08-28 12:05:00 -04:00
Alex Brainman
2a80882601 runtime: use cgo runtime functions to call windows syscalls
R=rsc
CC=golang-dev, jp, vcc.163
https://golang.org/cl/4926042
2011-08-27 23:17:00 +10:00
Jaroslavas Počepko
a88994f804 6l, 8l: remove JCXZ; add JCXZW, JCXZL, and JCXZQ
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4950050
2011-08-26 17:45:19 -04:00
Lucio De Re
f6a9807f56 8g: fix build on Plan 9
8g/cgen.c:
8g/gobj.c
. dropped unnecessary assignments;
8g/gg.h
. added varargckk pragmas;
8g/ggen.c
. dropped duplicate assignment;
8g/gsubr.c
. adjusted format in print statement;
. dropped unnecessary assignment;
. replaced GCC's _builtin_return_address(0) with Plan 9's
  getcallerpc(&n) which is defined as a macro in <u.h>;
8g/list.c
. adjusted format in snprint statement;
8g/opt.h
. added varargck pragma (Adr*) that is specific for the invoking
  modules;
8g/peep.c
. dropped unnecessary incrementation;

R=rsc
CC=golang-dev
https://golang.org/cl/4974044
2011-08-26 17:42:59 -04:00
Jaroslavas Počepko
26608d4fbb 6l, 8l: handle forward JCXZ
R=rsc
CC=golang-dev, vcc.163
https://golang.org/cl/4963044
2011-08-26 17:20:19 -04:00
Russ Cox
91643acc6f mime: fix build
The fix is to add ' ' after ';' so that we match
what we used to generate.
Packages like http look for the string with
the space in it, and I don't see a reason to
be so terse.

Also s/buffer/b/

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/4959044
2011-08-26 17:19:52 -04:00
Hector Chu
75199664d9 io: add TeeReader
TeeReader is a Reader that writes what it reads.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4953041
2011-08-26 17:08:59 -04:00
Pascal S. de Kloe
bd3627cd7d mime: text charset defaults
Enforce + document the UTF-8 default.

R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/4627049
2011-08-26 16:55:25 -04:00
Pascal S. de Kloe
fbdbb595b6 mime: media type formatter
R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4654069
2011-08-26 16:55:18 -04:00
Wei Guangjing
e753512e2d cgo: fixes callback for windows amd64
R=rsc
CC=golang-dev
https://golang.org/cl/4826041
2011-08-26 16:43:37 -04:00
Joel Sing
26d9c804f8 8l: add openbsd
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4972043
2011-08-26 15:39:23 -04:00
Albert Strasheim
582f6d4fd7 syscall: Handle RTM_NEWROUTE in ParseNetlinkRouteAttr on Linux.
R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/4954047
2011-08-26 15:38:42 -04:00
Joel Sing
d130611f45 net: disable "tcp" test on openbsd
Doing a socket/listen on an unspecified address with an unspecified
address family is likely to result in an AF_INET6 socket on an IPv6
capable system, which under OpenBSD means IPv6 only - not IPv4 *and*
IPv6. In this case trying to connect to this socket from an IPv4
loopback address is not going to end well.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4807057
2011-08-26 15:38:02 -04:00
Russ Cox
75d337e84b time: fix zone during windows test
Factor out sleep interrupt.

Fixes #1109.

R=alex.brainman, go.peter.90, mattn.jp
CC=golang-dev
https://golang.org/cl/4968041
2011-08-26 15:15:23 -04:00
Ross Light
4541fa96b3 xml: marshal "parent>child" tags correctly
Fixes #2119

R=m.n.summerfield, adg, kevlar, rsc, gustavo, n13m3y3r
CC=golang-dev
https://golang.org/cl/4941042
2011-08-26 12:29:52 -03:00
Brad Fitzpatrick
396cd36179 json: fix decode bug with struct tag names with ,opts being ignored
When the encoder was updated to respect the ",omitempty"
struct tag options, the decoder half was never updated to know
about the new struct tag format. (the format is now an optional
name, followed by zero or more ",option" strings)

This only affected people who used ",omitempty" along with
a field name. In that case, the serialized JSON wouldn't
decode to the original value.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/4965049
2011-08-26 12:27:33 +04:00
Brad Fitzpatrick
822804c600 http: support setting Transport's TLS client config
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4964043
2011-08-26 10:06:35 +04:00
Rob Pike
a45c657db1 bytes.Buffer: clarify that NewBuffer is not for beginners
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4965048
2011-08-26 15:09:23 +10:00
Fumitoshi Ukai
ebf19fb171 websocket: Implements new version of WebSocket protocol.
This introduces new APIs.
- DialConfig can open client connection using Config, so user can specify protocol version, tls.Config if necessary.

- Message can be used to send/receive text/binary data in a frame.
- JSON can be used to send/receive JSON data in a frame.

R=golang-dev, adg, rsc, m, tarmigan, raul.san, yohcop
CC=golang-dev
https://golang.org/cl/4635084
2011-08-26 13:12:08 +10:00
Yasuhiro Matsumoto
7a3095121e syscall: SOMAXCONN should be 0x7fffffff at winsock2.
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/4955042
2011-08-26 12:36:46 +10:00
Benny Siegert
64c9c7f5de image/tiff: decoder optimization.
Write to image.*.Pix directly in the case of RGB, RGBA and NRGBA
images. For the latter two, the file format matches the memory layout
so a simple copy can be used.

RGB image before/after:
tiff.BenchmarkDecoder	748137 ns/op (62.39 MB/s)	251256 ns/op (185.76 MB/s)	x3.0

NRGBA image before/after:
tiff.BenchmarkDecoder	775540 ns/op (80.12 MB/s)	116721 ns/op (532.34 MB/s)	x6.6

R=nigeltao
CC=golang-dev
https://golang.org/cl/4929046
2011-08-26 11:36:52 +10:00
Benny Siegert
f172338a15 image/tiff: add a decode benchmark.
R=nigeltao
CC=golang-dev
https://golang.org/cl/4917049
2011-08-26 11:31:59 +10:00
Robert Griesemer
3a1f29beec godoc: added systematic throttling to indexing goroutine
- implemented stand-alone Throttle mechanism
- added new flag -index_throttle to godoc
- index throttling enables index creation when running
  godoc on app engine as it keeps godoc responsive

R=rsc, dsymonds, adg
CC=golang-dev
https://golang.org/cl/4963043
2011-08-25 17:46:43 -07:00
Gustavo Niemeyer
77db5ff501 go/build: separate test imports out when scanning
This fixes goinstall so it doesn't try to install unneeded
packages or get confused with non-existent loops.

R=golang-dev, adg, gustavo
CC=golang-dev
https://golang.org/cl/4958046
2011-08-25 21:00:20 -03:00
Mikio Hara
825f8c147a net: move internal string manipulation routines to parse.go
R=rsc
CC=golang-dev
https://golang.org/cl/4968044
2011-08-25 19:22:46 -04:00
Mikio Hara
78963f4f1d net: make use of IPv4len, IPv6len
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4957043
2011-08-25 19:00:04 -04:00
Gustavo Niemeyer
0462f77e24 goinstall: report lack of $GOPATH on errors
Fixes #2175.

R=alex.brainman, rsc, gustavo, adg
CC=golang-dev
https://golang.org/cl/4929047
2011-08-25 19:12:03 -03:00
Russ Cox
cb51fdc007 strconv: put decimal on stack
This makes decimal a good test
case for the escape analysis.

With escape analysis:

benchmark                 old ns/op    new ns/op    delta
BenchmarkAtof64Decimal         1954          243  -87.56%
BenchmarkAtof64Float           2008          293  -85.41%
BenchmarkAtof64FloatExp       10106         8814  -12.78%
BenchmarkAtof64Big             5113         3486  -31.82%

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4861042
2011-08-25 17:54:14 -04:00
Russ Cox
987649e09b build: fix more unused parameters
R=ken2
CC=golang-dev
https://golang.org/cl/4971042
2011-08-25 16:29:56 -04:00
Russ Cox
61f84a2cdc gc: shuffle #includes
#include "go.h" (or "gg.h")

becomes

#include <u.h>
#include <libc.h>
#include "go.h"

so that go.y can #include <stdio.h>
after <u.h> but before "go.h".
This is necessary on Plan 9.

R=ken2
CC=golang-dev
https://golang.org/cl/4971041
2011-08-25 16:25:10 -04:00
Russ Cox
55db9fe730 build: fix unused parameters
Found with gcc 4.6 -Wunused -Wextra
but should be applicable to Plan 9 too.

R=ken2
CC=golang-dev
https://golang.org/cl/4958044
2011-08-25 16:08:13 -04:00
Bill Neubauer
948418f16a template: Grammar fix for template documentation.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4944043
2011-08-25 12:25:19 -04:00
Russ Cox
0227c45ede gc: fix some spurious leaks
Probably will spark some discussion.  ☺

R=lvd
CC=golang-dev
https://golang.org/cl/4948041
2011-08-25 09:26:13 -04:00
Dave Cheney
8511ed454a http: return 413 instead of 400 when the request body is too large
RFC2616 says servers should return this status code when
rejecting requests that are too large.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.14

R=bradfitz
CC=golang-dev
https://golang.org/cl/4962041
2011-08-25 14:00:00 +04:00
Nigel Tao
1f0d277cc1 exp/template/html: add some tests for ">" attributes.
R=mikesamuel
CC=golang-dev
https://golang.org/cl/4956042
2011-08-25 13:48:21 +10:00
Mike Samuel
42a56d3e81 exp/template/html: Reworked escapeText to recognize attr boundaries.
The following testcases now pass:

`<a href=x` tests that we do not error on partial unquoted attrs.
`<a href=x ` tests that spaces do end unquoted attrs on spaces.
`<a href=''` tests that we recognize the end of single quoted attrs.
`<a href=""` tests that we recognize the end of double quoted attrs.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/4932051
2011-08-25 11:24:43 +10:00
Gustavo Niemeyer
15580526de version.bash: update VERSION on -save if already present
R=rsc
CC=golang-dev
https://golang.org/cl/4941047
2011-08-24 22:10:25 -03:00
Rob Pike
297a08ea66 gofix: forgot to rename the URL type
Fixes #2182

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4952041
2011-08-25 10:16:11 +10:00
Andrew Gerrand
56f948470e bufio: handle a "\r\n" that straddles the buffer.
Fixes #2164.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4927043
2011-08-25 08:44:12 +10:00
Evan Shaw
de20cec9c9 big: fix nat.scan bug
Scanning "0" with detected base did not actually set the nat to 0.

R=gri
CC=golang-dev
https://golang.org/cl/4923050
2011-08-24 14:55:03 -07:00
Russ Cox
42687d6ce4 gc: simplify escape analysis recursion
Merge escassign(N, x), escassign(x, N), escexpr(n), and escstmt(n) into esc(n).

1. Renaming
https://golang.org/cl/4917050/diff2/1:2001/src/cmd/gc/esc.c

2. Merging.
https://golang.org/cl/4917050/diff2/2001:4001/src/cmd/gc/esc.c

3. Simplify esccall.
https://golang.org/cl/4917050/diff2/4001:5002/src/cmd/gc/esc.c

R=lvd
CC=golang-dev
https://golang.org/cl/4917050
2011-08-24 16:47:32 -04:00
Volker Dobler
f78e7d36a6 math: fix Pow10 loop
Pow10 failed for MinInt32 (endless loop until out of
memory).  Fix by returning 0 and +Inf for all arguments
where the result is not representable in a float64.
Fixes #2159.

R=rsc
CC=golang-dev
https://golang.org/cl/4930041
2011-08-24 13:59:52 -04:00
Mikio Hara
80f79ad305 net: make use of IPv4len, IPv6len
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4926046
2011-08-24 13:59:33 -04:00
Lucio De Re
6ecd5f9fe7 cov: remove tautological #defines
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4941048
2011-08-24 13:59:17 -04:00
Luuk van Dijk
847b61b554 gc: Escape analysis.
For now it's switch-on-and-offable with -s, and the effects can be inspected
with -m.  Defaults are the old codepaths.

R=rsc
CC=golang-dev
https://golang.org/cl/4634073
2011-08-24 19:07:08 +02:00
Robert Griesemer
52818f4583 godoc: use virtual file system when generating package synopses
Fix for godoc on app engine.

R=dsymonds
CC=golang-dev
https://golang.org/cl/4922050
2011-08-24 09:52:16 -07:00
Brad Fitzpatrick
fa6d038e98 http: adjust test threshold for larger suse buffers
My theory is that suse has larger TCP buffer sizes
by default.  I now check over 100MB, rather than over 2MB.
100MB is ~halfway between the 1MB limit and the 200MB
request that's attempted.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4926048
2011-08-24 16:09:49 +04:00
Brad Fitzpatrick
bb4cf3f351 http: on invalid request, send 400 response
Fixes #2160

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4930049
2011-08-24 13:10:22 +04:00
Marcel van Lohuizen
4a4fa38d0e exp/norm: Reduced the size of the byte buffer used by reorderBuffer by half by reusing space when combining.
R=r
CC=golang-dev
https://golang.org/cl/4939042
2011-08-24 11:05:45 +02:00
Russ Cox
00d64c7239 reflect: add Value.Bytes, Value.SetBytes methods
This allows code that wants to handle
[]byte separately to get at the actual slice
instead of just at individual bytes.
It seems to come up often enough.

R=r
CC=golang-dev
https://golang.org/cl/4942051
2011-08-23 22:50:08 -04:00
Russ Cox
66bedf8221 go/build: add test support & use in gotest
A side-effect is that, just like foo_386.go
is only built on 386, foo_386_test.go is only
built for testing on 386.

R=adg, r, mattn.jp
CC=golang-dev
https://golang.org/cl/4942050
2011-08-23 22:45:30 -04:00
Russ Cox
03582b3308 http: delete error kludge
The kludge is targeted at broken web browsers
like Chrome and IE, but it gets in the way of
sending 400 or 500-series error results with
formatted bodies in response to AJAX requests
made by pages executing in those browsers.

Now the AJAX cases will work and Chrome
and IE will be as broken with Go servers as
they are with all the other servers.

Fixes #2169.

R=bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/4930047
2011-08-23 22:39:25 -04:00
Russ Cox
5e188b40f2 build: avoid redundant bss declarations
Some compilers care, sadly.

R=iant, ken
CC=golang-dev
https://golang.org/cl/4931042
2011-08-23 22:39:14 -04:00
Paul Borman
af18e4b9b0 net: add ParseMAC function
ParseMAC parses a string representing MAC-48, EUI-48, or EUI-64 into
a HardwareAddr.

R=rsc, fshahriar
CC=golang-dev
https://golang.org/cl/4922048
2011-08-23 22:38:43 -04:00
Robert Griesemer
e656a184cb go/ast cleanup: base File/PackageExports on FilterFile/FilterPackage code
R=r, rsc
CC=golang-dev
https://golang.org/cl/4927046
2011-08-23 16:03:42 -07:00
Robert Griesemer
cde06f541f go/ast: adjustments to filter function
CL 4938041 made some incorrect changes to the filter
function which caused a different doc/codelab/wiki/index.html
file to be generated.

Added FilterFileExports and FilterPackageExports function.
Same as the existing FileExpors/PackageExports functions
but using shared code. The old functions will be removed
in the next CL.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4932048
2011-08-23 14:17:18 -07:00
Julian Phillips
b99d722963 gc: fix pc/line table
When a line directive was encountered we would push a new 'z' entry into
the history to indicate the start of new file attributation, and a 'Z'
entry to change line numbering.  However we didn't pop the 'z' entry, so
we were actually corrupting the history stack.  The most obvious
occurance of this was in the code that build the symbol tables for the
DWARF information - where an internal stack in the linker would overflow
when more than a few line directives were encountered in a single stack
(Issue 1878).  So now we pop the 'z' entry when we encounter the end of
the file that the directive was in, which maintains the history stack
integrity.

Also, although new 'z' entries for new files had relative paths
expanded, the same was not done for line directives.  Now we do it for
line directives also - so that the now correct DWARF information has the
full path available.

Fixes #1878.

R=rsc
CC=golang-dev
https://golang.org/cl/4938042
2011-08-23 17:01:14 -04:00
Russ Cox
33e9d24ad9 runtime: fix void warnings
Add -V flag to 6c command line to keep them fixed.

R=ken2
CC=golang-dev
https://golang.org/cl/4930046
2011-08-23 13:13:27 -04:00
Robert Griesemer
f6d536bea4 go/parser: fix type switch scoping
Introduce extra scope for the variable declared by a
TypeSwitchGuard so that it doesn't conflict with vars
declared by the initial SimpleStmt of a type switch.

This is a replacement for CL 4896053 which caused
a build breakage.

Also:
- explicitly detect type switches (as opposed to detecting
  expression switches and then do extra testing for type switches)
- fix all outstanding TODOs in parser.go
- ran all tests

R=rsc
CC=golang-dev
https://golang.org/cl/4914044
2011-08-23 09:22:41 -07:00
Brad Fitzpatrick
f0ef4f4746 http: add MaxBytesReader to limit request body size
This adds http.MaxBytesReader, similar to io.LimitReader,
but specific to http, and for preventing a class of DoS
attacks.

This also makes the 10MB ParseForm limit optional (if
not already set by a MaxBytesReader), documents it,
and also adds "PUT" as a valid verb for parsing forms
in the request body.

Improves issue 2093 (DoS protection)
Fixes #2165 (PUT form parsing)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4921049
2011-08-23 12:17:21 +04:00
Russ Cox
03e9ea5b74 runtime: simplify stack traces
Make the stack traces more readable for new
Go programmers while preserving their utility for old hands.

- Change status number [4] to string.
- Elide frames in runtime package (internal details).
- Swap file:line and arguments.
- Drop 'created by' for main goroutine.
- Show goroutines in order of allocation:
  implies main goroutine first if nothing else.

There is no option to get the extra frames back.
Uncomment 'return 1' at the bottom of symtab.c.

$ 6.out
throw: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
main.main()
       /Users/rsc/g/go/src/pkg/runtime/x.go:22 +0x8a

goroutine 2 [select (no cases)]:
main.sel()
       /Users/rsc/g/go/src/pkg/runtime/x.go:11 +0x18
created by main.main
       /Users/rsc/g/go/src/pkg/runtime/x.go:19 +0x23

goroutine 3 [chan receive]:
main.recv(0xf8400010a0, 0x0)
       /Users/rsc/g/go/src/pkg/runtime/x.go:15 +0x2e
created by main.main
       /Users/rsc/g/go/src/pkg/runtime/x.go:20 +0x50

goroutine 4 [chan receive (nil chan)]:
main.recv(0x0, 0x0)
       /Users/rsc/g/go/src/pkg/runtime/x.go:15 +0x2e
created by main.main
       /Users/rsc/g/go/src/pkg/runtime/x.go:21 +0x66
$

$ 6.out index
panic: runtime error: index out of range

goroutine 1 [running]:
main.main()
        /Users/rsc/g/go/src/pkg/runtime/x.go:25 +0xb9
$

$ 6.out nil
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x22ca]

goroutine 1 [running]:
main.main()
        /Users/rsc/g/go/src/pkg/runtime/x.go:28 +0x211
$

$ 6.out panic
panic: panic

goroutine 1 [running]:
main.main()
        /Users/rsc/g/go/src/pkg/runtime/x.go:30 +0x101
$

R=golang-dev, qyzhai, n13m3y3r, r
CC=golang-dev
https://golang.org/cl/4907048
2011-08-22 23:26:39 -04:00
Lucio De Re
45407bd559 ld: handle Plan 9 ar format
The Go version has 64 character long section names; originally,
in Plan 9, the limit was 16.  To provide compatibility, this
change allows the input length to be either the target length
or the earlier option.	The section name is extended with spaces
where required.

This has been tested to work without regressions in the
Go environment, testing the older alternative has not been
possible yet.

R=rsc
CC=golang-dev
https://golang.org/cl/4650071
2011-08-22 23:24:38 -04:00
Joel Sing
bf2d403de8 syscall: openbsd amd64 syscall support
Add support for syscalls on openbsd amd64. This is based on the
existing freebsd amd64 implementation.

R=mikioh.mikioh, rsc, yourcomputerpal
CC=golang-dev
https://golang.org/cl/4798060
2011-08-22 23:24:32 -04:00
Joel Sing
be00d38a35 build: add openbsd
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4832047
2011-08-22 23:24:25 -04:00
Joel Sing
a9fe3a0ce3 os: disable Hostname test on OpenBSD
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4901054
2011-08-22 23:24:16 -04:00
Russ Cox
3554325937 ld: remove duplicate bss definitions
The EXTERN lines in elf.h already define these.
That's not a problem for most C compilers, but
apparently it is for some copies of the OS X linker.

Fixes #2167.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/4936044
2011-08-22 23:23:57 -04:00