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

668 Commits

Author SHA1 Message Date
Adam Langley
252ef18d04 exp/terminal: rename shell to terminal and add SetSize
It was never really a shell, but the name carried
over from SSH's ServerShell.

Two small functional changes:

Add SetSize, which allows the size of the terminal
to be changed in response, say, to an SSH message.

Don't write the prompt if there's already something
on the current line.

R=rsc
CC=golang-dev
https://golang.org/cl/5376066
2011-11-11 14:04:33 -05:00
Adam Langley
d08f57e68c exp/terminal: rename terminal.go to util.go
(This is part of removing the duplicate code between exp/terminal and
exp/ssh, but hg is having a very hard time keeping up so I'm doing it
in small steps.)

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5373061
2011-11-11 11:18:45 -05:00
Rob Pike
30aa701fec renaming_2: gofix -r go1pkgrename src/pkg/[a-l]*
R=rsc
CC=golang-dev
https://golang.org/cl/5358041
2011-11-08 15:40:58 -08:00
Dave Cheney
1170a6460f exp/ssh: improved client authentication support
This CL adds an API for handling the various SSH
authenticaton methods. None and password continue
to be the only supported methods.

R=bradfitz, agl, n13m3y3r, rsc, cw
CC=golang-dev
https://golang.org/cl/5328045
2011-11-07 12:37:05 -05:00
Luuk van Dijk
aac144b120 gc: detect type switch variable not used cases.
Fixes #873
Fixes #2162

R=rsc
CC=golang-dev
https://golang.org/cl/5341043
2011-11-04 17:03:50 +01:00
Gustavo Niemeyer
f2dc50b48d html,bzip2,sql: rename Error methods that return error to Err
There are three classes of methods/functions called Error:

a) The Error method in the just introduced error interface
b) Error methods that create or report errors (http.Error, etc)
c) Error methods that return errors previously associated with
   the receiver (Tokenizer.Error, rows.Error, etc).

This CL introduces the convention that methods in case (c)
should be named Err.

The reasoning for the change is:

- The change differentiates the two kinds of APIs based on
  names rather than just on signature, unloading Error a bit
- Err is closer to the err variable name that is so commonly
  used with the intent of verifying an error
- Err is shorter and thus more convenient to be used often
  on error verifications, such as in iterators following the
  convention of the sql package.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5327064
2011-11-04 09:50:20 -04:00
Rob Pike
5cb4a15320 html,log,math: renamings
This is Go 1 package renaming CL #2.
This one merely moves the source; the import strings will be
changed after the next weekly release.

exp/template/html -> html/template
big -> math/big
cmath -> math/cmplx
rand -> math/rand
syslog -> log/syslog

The only edits are in Makefiles and deps.bash.

Note that this CL moves exp/template/html out of exp. I decided
to do that so all the renamings can be done together, even though
the API (and that of template, for that matter) is still fluid.

R=r, rsc
CC=golang-dev
https://golang.org/cl/5332053
2011-11-03 12:42:57 -07:00
Russ Cox
965845a86d all: sort imports
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5319072
2011-11-02 15:54:16 -04:00
Brad Fitzpatrick
8089e57812 exp/sql: finish transactions, flesh out types, docs
Fixes #2328 (float, bool)

R=rsc, r
CC=golang-dev
https://golang.org/cl/5294067
2011-11-02 11:46:04 -07:00
Russ Cox
492098eb75 all: rename os.Error to error in various non-code contexts
R=adg
CC=golang-dev
https://golang.org/cl/5328062
2011-11-01 22:58:09 -04:00
Russ Cox
c2049d2dfe src/pkg/[a-m]*: gofix -r error -force=error
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5322051
2011-11-01 22:04:37 -04:00
Russ Cox
c93b6a1756 exp/ebnf: manual fixup for error
(The definition of ErrorList is in another file, so gofix
has no hope of getting this right.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5330043
2011-11-01 21:49:33 -04:00
Russ Cox
e67d3c44f7 exp/types: add error type to universe
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5327051
2011-11-01 21:47:33 -04:00
Russ Cox
7b04471dfa gopack: change archive file name length back to 16
This CL grew the archive file name length from 16 to 64:

        changeset:   909:58574851d792
        user:        Russ Cox <rsc@golang.org>
        date:        Mon Oct 20 13:53:56 2008 -0700

Back then, every x.go file in a package became an x.6 file
in the archive.  It was important to be able to allow the
use of long Go source file names, hence the increase in size.

Today, all Go source files compile into a single _go_.6 file
regardless of their names, so the archive file name length
no longer needs to be long.  The longer name causes some
problems on Plan 9, where the native archive format is the
same but with 16-byte names, so revert back to 16.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5333050
2011-11-01 00:29:16 -04:00
Scott Lawrence
cae23f036a template: fix error checking on execute without parse
Fixed error checking in exec.go to give a sensible error message when
execution is attempted before a successful parse (rather than an
outright panic).

R=r
CC=golang-dev
https://golang.org/cl/5306065
2011-10-31 16:07:17 -07:00
Marcel van Lohuizen
eef7809193 exp/norm: fixed bug that creeped in with moving to the new
regexp, which caused the last line of a test block to be ignored.

R=r, rsc
CC=golang-dev
https://golang.org/cl/5177052
2011-10-31 10:58:04 +01:00
Dave Cheney
0f6b80c694 exp/ssh: fix length header leaking into channel data streams.
The payload of a data message is defined as an SSH string type,
which uses the first four bytes to encode its length. When channelData
and channelExtendedData were added I defined Payload as []byte to
be able to use it directly without a string to []byte conversion. This
resulted in the length data leaking into the payload data.

This CL fixes the bug, and restores agl's original fast path code.

Additionally, a bug whereby s.lock was not released if a packet arrived
for an invalid channel has been fixed.

Finally, as they were no longer used, I have removed
the channelData and channelExtedendData structs.

R=agl, rsc
CC=golang-dev
https://golang.org/cl/5330053
2011-10-29 14:22:30 -04:00
Russ Cox
c1178aae86 strconv: use better errors than os.EINVAL, os.ERANGE
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5327052
2011-10-27 19:46:31 -07:00
Russ Cox
32f3770ec5 pkg: remove .String() from some print arguments
I found these by adding a check to govet, but the check
produces far too many false positives to be useful.
Even so, these few seem worth cleaning up.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/5311067
2011-10-27 18:03:52 -07:00
Russ Cox
c945f77f41 exp/norm: use rune
Nothing terribly interesting here. (!)

Since the public APIs are all in terms of UTF-8,
the changes are all internal only.

R=mpvl, gri, r
CC=golang-dev
https://golang.org/cl/5309042
2011-10-25 22:26:12 -07:00
Russ Cox
4911622055 exp/template/html: use rune
Nothing terribly interesting here.

R=mikesamuel, nigeltao, r
CC=golang-dev
https://golang.org/cl/5307044
2011-10-25 22:22:26 -07:00
Russ Cox
28c06182c0 exp/winfsnotify: fix govet-found bug
R=golang-dev, hectorchu
CC=golang-dev
https://golang.org/cl/5304044
2011-10-25 22:21:14 -07:00
Russ Cox
5be33e9543 godoc, exp/ebnf, exp/types, go/scanner, scanner: use rune
API question: is a scanner token an int or a rune?

Since the rune is the common case and the token values
are the special (negative) case, I chose rune.  But it could
easily go the other way.

R=gri
CC=golang-dev
https://golang.org/cl/5301049
2011-10-25 22:20:20 -07:00
Russ Cox
f4568882eb exp/types: add rune to universe
R=gri
CC=golang-dev
https://golang.org/cl/5295045
2011-10-25 22:19:09 -07:00
Dave Cheney
5791233461 exp/ssh: introduce Session to replace Cmd for interactive commands
This CL replaces the Cmd type with a Session type representing
interactive channels. This lays the foundation for supporting
other kinds of channels like direct-tcpip or x11.

client.go:
* replace chanlist map with slice.
* generalize stdout and stderr into a single type.
* unexport ClientChan to clientChan.

doc.go:
* update ServerConfig/ServerConn documentation.
* update Client example for Session.

message.go:
* make channelExtendedData more like channelData.

session.go:
* added Session which replaces Cmd.

R=agl, rsc, n13m3y3r, gustavo
CC=golang-dev
https://golang.org/cl/5302054
2011-10-24 19:13:55 -04:00
Dave Cheney
8bfb217123 exp/ssh: server cleanups
server.go/channel.go:
* rename Server to ServerConfig to match Client.
* rename ServerConnection to ServeConn to match Client.
* add Listen/Listener.
* ServerConn.Handshake(), general cleanups.

client.go:
* fix bug where fmt.Error was not assigned to err

R=rsc, agl
CC=golang-dev
https://golang.org/cl/5265049
2011-10-21 11:04:28 -04:00
Dave Cheney
792a55f5db exp/ssh: add experimental ssh client
Requires CL 5285044

client.go:
* add Dial, ClientConn, ClientChan, ClientConfig and Cmd.

doc.go:
* add Client documentation.

server.go:
* adjust for readVersion change.

transport.go:
* return an os.Error not a bool from readVersion.

R=rsc, agl, n13m3y3r
CC=golang-dev
https://golang.org/cl/5162047
2011-10-20 15:44:45 -04:00
Hector Chu
9e1a2adf07 exp/winfsnotify: fix test
R=alex.brainman, mattn.jp
CC=golang-dev
https://golang.org/cl/5311047
2011-10-20 08:10:58 +01:00
Russ Cox
bb8c4ed22a exp/types: fix crash in parseBasicType on unknown type
R=gri
CC=golang-dev
https://golang.org/cl/5302044
2011-10-19 12:49:01 -04:00
Mikio Hara
e13635c1e0 os/inotify: move to exp/inotify
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5295044
2011-10-19 10:54:45 +09:00
Nigel Tao
98e723ed09 html: fix escape_test.go for CSS escaper change 5306042.
R=mikesamuel
CC=golang-dev
https://golang.org/cl/5313044
2011-10-19 10:54:04 +11:00
Mike Samuel
fc3ce34903 exp/template/html: fix bug in cssEscaper
cssEscaper escapes using the CSS convention: `\` + hex + optional-space

It outputs the space when the escape could be followed by
a hex digit to distinguish a "\na" from "\u00aa".

It did not output a space when the escape is followed by a space
character so did not distinguish "\n " from "\n".

Currently when doing lookahead, it does not distinguish spaces that
will be escaped later by the same function from ones that will not.
This is correct but suboptimal.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5306042
2011-10-18 17:01:42 -05:00
Hector Chu
7ecf6c997e exp/winfsnotify: filesystem watcher for Windows
R=rsc, alex.brainman, bradfitz
CC=bsiegert, go.peter.90, golang-dev
https://golang.org/cl/4188047
2011-10-18 21:09:58 +01:00
Adam Langley
7bc4f8de0f exp/terminal: split terminal handling from exp/ssh
This change splits terminal handling from exp/ssh, as suggested
several times in the ssh code review.

shell.go and shell_test.go are copies from exp/ssh with minimal
changes, so don't need another full review. A future CL will remove
that code from exp/ssh.

R=bradfitz, r, dave, rsc
CC=golang-dev
https://golang.org/cl/5278049
2011-10-18 12:58:57 -04:00
Dave Cheney
ec158f77bd exp/ssh: general cleanups for client support
common.go:
* simplify findAgreedAlgorithms.
* add channelExtendedData support.

messages.go:
* add clientExtendedData.

server.go:
*  use simplified findAgreedAlgorithms.

server_shell.go:
* fix shadowed err return value.

transport.go:
* introduce separate cipher, mac and compression for each direction.
* added filteredConn and packetWriter interfaces.
* newTransport requires a source of randomness.

R=golang-dev, agl, rsc
CC=golang-dev
https://golang.org/cl/5285044
2011-10-18 12:54:48 -04:00
Russ Cox
313c8224d5 gofix -r mapdelete
R=golang-dev, r, adg, r, cw
CC=golang-dev
https://golang.org/cl/5266045
2011-10-18 09:56:34 -04:00
Russ Cox
d2b73730b7 exp/template/html: do not depend on reflection on internal fields
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5286049
2011-10-17 18:23:59 -04:00
Robert Griesemer
812249fe5e gotype: move to exp/gotype per Go 1 plan
R=r, dsymonds
CC=golang-dev
https://golang.org/cl/5269043
2011-10-13 16:36:53 -07:00
Robert Griesemer
29c2838cb4 go/types: move to exp/types per Go 1 plan
This package is only used by gotype at the moment.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5266042
2011-10-13 15:41:48 -07:00
Russ Cox
06862617c1 build: fix for new return restriction
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5257057
2011-10-13 12:17:18 -04:00
Robert Hencke
c50182480d pkg: fix incorrect prints found by govet
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/5266041
2011-10-13 13:34:01 +11:00
Christopher Wedgwood
707e5acd71 updates: append(y,[]byte(z)...) -> append(y,z...)"
(more are possible but omitted for now as they are part of
specific tests where rather than changing what is there we
should probably expand the tests to cover the new case)

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/5247058
2011-10-12 13:42:04 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Nigel Tao
9969803f6c exp/template/html: differentiate URL-valued attributes (such as href)
from others (such as title) during escaping.

R=r, mikesamuel, dsymonds
CC=golang-dev
https://golang.org/cl/4919042
2011-08-23 13:22:26 +10:00
Marcel van Lohuizen
d9c9c48797 exp/norm: added implemenation for []byte versions of methods.
R=r
CC=golang-dev
https://golang.org/cl/4925041
2011-08-22 12:52:04 +02:00
Marcel van Lohuizen
45b7084b92 exp/norm: a few minor fixes to support the implementation of norm.
maketables.go/tables.go
- Properly set combinesForward flag for JamoL and JamoV.
- Fixed Printf bug.
composition.go
- Make insertString use the same control flow as insert.
- Better Hangul and non-Hangul mixing.
forminfo.go
- Fixed bug in compBoundaryBefore that affected a few esoteric cases.
- Buffer overflow now tested in normalize_test.go (other CL).

R=r
CC=golang-dev
https://golang.org/cl/4924041
2011-08-22 12:11:29 +02:00
Mike Samuel
e4a89d7cca exp/template/html: defines a parse context for a subset of HTML.
This defines just enough context to distinguish HTML URI attributes
from parsed character data.

It does not affect any public module API as I thought I would get
early comment on style for defining enumerations and tables.

R=rsc, r, nigeltao, r
CC=golang-dev
https://golang.org/cl/4906043
2011-08-18 10:40:29 +10:00
Marcel van Lohuizen
b40bd5efb7 exp/norm: implementation of decomposition and composing functionality.
forminfo.go:
- Wrappers for table data.
- Per Form dispatch table.
composition.go:
- reorderBuffer type.  Implements decomposition, reordering, and composition.
- Note: decompose and decomposeString fields in formInfo could be replaced by
  a pointer to the trie for the respective form.  The proposed design makes
  testing easier, though.
normalization.go:
- Temporarily added panic("not implemented") methods to make the tests run.
  These will be removed again with the next CL, which will introduce the
  implementation.

R=r, rogpeppe, mpvl, rsc
CC=golang-dev
https://golang.org/cl/4875043
2011-08-17 18:12:39 +10:00
Mike Samuel
7dce257ac8 exp/template/html: rework Reverse(*Template) to do naive autoescaping
Replaces the toy func Reverse(*Template) with one that implements
naive autoescaping.

Now Escape(*Template) walks a template parse tree to find all
template actions and adds the |html command to them if it is not
already present.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4867049
2011-08-17 16:00:02 +10:00
Rob Pike
a22e77e6ae template: move exp/template into template.
(Leave exp/template/html where it is for now.)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4899048
2011-08-17 14:55:57 +10:00
Rob Pike
1d8f822c17 url: new package
This is just moving the URL code from package http into its own package,
which has been planned for a while.
Besides clarity, this also breaks a nascent dependency cycle the new template
package was about to introduce.

Add a gofix module, url, and use it to generate changes outside http and url.

Sadness about the churn, gladness about some of the naming improvements.

R=dsymonds, bradfitz, rsc, gustavo, r
CC=golang-dev
https://golang.org/cl/4893043
2011-08-17 13:36:02 +10:00
Gustavo Niemeyer
e3df71f50b exp/template: support field syntax on maps
While using exp/template in practice, the syntax for
indexing values using the "index" action was found to be
very inconvenient for frequent use when handling dynamic
data from maps such as the ones used with json and yaml,
that use a type like map[string]interface{}.

For these kinds of maps, the default handling of fields as
{{.Field}} makes the task of handling the several references
significantly more pleasant and elegant, and is equivalent
to what's currently done in the "template" package and in
other external packages (e.g. mustache).

Even with this change, the index action is still relevant
as it allows indexing maps in other scenarios where keys
wouldn't be valid field names.

R=golang-dev, r, gustavo
CC=golang-dev
https://golang.org/cl/4898043
2011-08-15 00:56:01 -03:00
Gustavo Niemeyer
e3f3a5411a exp/template: don't panic on range of nil interface
This avoids a non-obvious panic when range is used on a
nil interface, and fixes it by behaving as if the range
was empty.

The new behavior is equivalent to the outcome of iterating
on a nil map or slice, and is useful because it allows
generic structures such as used in json (map[string]interface{})
to behave correctly if a key generally set to a list or map
isn't present.

R=golang-dev, r, gustavo
CC=golang-dev
https://golang.org/cl/4876046
2011-08-15 00:22:28 -03:00
Robert Hencke
8a439334ad exp/norm: fix incorrect prints found by govet.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4895042
2011-08-14 14:02:48 +10:00
David Symonds
5e48e648f1 exp/template: rename filter: url -> urlquery.
R=r, rsc
CC=golang-dev
https://golang.org/cl/4873046
2011-08-13 14:00:16 +10:00
Marcel van Lohuizen
4abbdc0399 exp/norm: generate trie struct in triegen.go for better encapsulation.
R=r, r
CC=golang-dev
https://golang.org/cl/4837071
2011-08-12 18:00:31 +02:00
Marcel van Lohuizen
58a92bd1ef exp/norm: generate trie struct in triegen.go for better encapsulation.
R=r, r
CC=golang-dev
https://golang.org/cl/4837071
2011-08-12 17:44:14 +02:00
Mike Samuel
595e9d5034 exp/template/html: New package with a toy template transformation.
func Reverse(*Template) *Template
returns a template that produces the reverse of the original
for any input.

Changes outside exp/template/html include:
- Adding a getter for a template's FuncMap so that derived templates
  can inherit function definitions.
- Exported one node factory function, newIdentifier.
  Deriving tempaltes requires constructing new nodes, but I didn't
  export all of them because I think shallow copy functions might
  be more useful for this kind of work.
- Bugfix: Template's Name() method ignores the name field so
  template.New("foo") is a nil dereference instead of "foo".

Caveats: Reverse is a toy.  It is not UTF-8 safe, and does not
preserve order of calls to funcs in FuncMap.

For context, see http://groups.google.com/group/golang-nuts/browse_thread/thread/e8bc7c771aae3f20/b1ac41dc6f609b6e?lnk=gst

R=rsc, r, nigeltao, r
CC=golang-dev
https://golang.org/cl/4808089
2011-08-12 14:34:29 +10:00
David Symonds
fe59d86dd6 exp/template: fix implementation of printValue.
R=r
CC=golang-dev
https://golang.org/cl/4878042
2011-08-12 13:29:56 +10:00
Rob Pike
b1d1da405a exp/template: add builtin len function
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4868045
2011-08-12 11:47:44 +10:00
Rob Pike
6ca968c791 exp/template: find the String method by taking the address if we need to.
Also simplify nil handling in printing.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4869042
2011-08-11 14:36:51 +10:00
Gustavo Niemeyer
f3625e7087 exp/template: rename Parse*File and Parse*Files for clarity
IMPORTANT: Previous usage of *Files will continue to compile
fine but misbehave since the interface is compatible.

The following functions have been renamed:

    ParseFiles => ParseGlob
    ParseFile => ParseFiles
    ParseSetFiles => ParseSetGlob
    ParseSetFile => ParseSetFiles
    ParseTemplateFiles => ParseTemplateGlob
    ParseTemplateFile => ParseTemplateFiles

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4867041
2011-08-10 23:28:48 -05:00
Rob Pike
39fa2a5bf2 exp/template: truth for interface values.
Also protect against invalid (zero Value) reflect.Values.

R=rsc, gri
CC=golang-dev
https://golang.org/cl/4810094
2011-08-11 08:27:16 +10:00
Marcel van Lohuizen
849b54a2f9 exp/norm: added trie lookup code and associated tests.
- triegen.go: Factored out trie generation code from maketables.go
  (only renamed printTrieTables to printTables and made it a method).
- maketesttables.go: new tool to generate data for the trie unit test.
- Makefile: changed accordingly.
- trie.go: trie lookup code.
- trietest_data.go: generated by maketesttables.go.
- trie_test.go: unit test for trie.go.

R=r
CC=golang-dev
https://golang.org/cl/4844053
2011-08-10 15:36:27 +02:00
Marcel van Lohuizen
00cb627b87 exp/norm: added trie lookup code and associated tests.
- triegen.go: Factored out trie generation code from maketables.go
  (only renamed printTrieTables to printTables and made it a method).
- maketesttables.go: new tool to generate data for the trie unit test.
- Makefile: changed accordingly.
- trie.go: trie lookup code.
- trietest_data.go: generated by maketesttables.go.
- trie_test.go: unit test for trie.go.

R=r
CC=golang-dev
https://golang.org/cl/4844053
2011-08-10 15:34:12 +02:00
Rob Pike
1adda4601a exp/template: do not take address of interface variable to find methods.
Also allow struct values as "with" targets.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4809086
2011-08-09 17:07:29 +10:00
Rob Pike
7506ee7584 exp/template: remove reflect from the API
It means keeping two sets of maps, but things look cleaner from
the outside.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4839056
2011-08-09 16:49:36 +10:00
Rob Pike
c66917d2b6 exp/template: split the parse tree into a separate package exp/template/parse
Mostly a mechanical change, with a few cleanups to make the split easier.
The external interface to exp/template is unaffected.

In another round I will play with the function map setup to see if I can
avoid exposing reflect across the boundary, but that will require some
structural changes I did not want to mix into this CL.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4849049
2011-08-09 15:42:53 +10:00
John Asmuth
ffc0830c75 container/vector: removed last instances of vector outside of container/vector itself from the core libs
R=gri
CC=golang-dev
https://golang.org/cl/4810078
2011-08-08 11:27:09 -07:00
Rob Pike
9c2ebab826 exp/template: document that comments may span newlines.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4855045
2011-08-08 23:42:49 +10:00
David Symonds
a09ba8b638 exp/template: url filter.
R=r
CC=golang-dev
https://golang.org/cl/4837063
2011-08-08 16:29:57 +10:00
David Symonds
ec010fddb5 exp/template: fix Must example.
R=r
CC=golang-dev
https://golang.org/cl/4839052
2011-08-08 15:38:37 +10:00
Rob Pike
5b1f159fb5 exp/norm: fix build by adding a test placeholder
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4838050
2011-08-05 08:25:49 +10:00
Marcel van Lohuizen
b35d49fca1 exp/norm: maketables tool for generating tables for normalization.
R=r, bsiegert, r, alex.brainman
CC=golang-dev
https://golang.org/cl/4662080
2011-08-04 23:15:19 +02:00
Rob Pike
3dbe10c453 exp/template: return nil value from helpers on error, even methods.
R=rsc
CC=golang-dev
https://golang.org/cl/4835046
2011-08-01 20:02:52 -07:00
Roger Peppe
6ed27d4770 exp/template: make index function on maps return zero value when key not present.
R=r
CC=golang-dev
https://golang.org/cl/4808065
2011-08-01 09:03:35 -07:00
Roger Peppe
5c5ce6d24d exp/template: ensure that a valid Set is returned even on error.
R=r
CC=golang-dev
https://golang.org/cl/4838044
2011-08-01 09:02:06 -07:00
Alex Brainman
9d7e39340d syscall: delay load of dll functions until they are called
Before this change, syscall package would load
all dlls used anywhere in the go tree on startup.
For example, this program:

package main

import "fmt"

func main() {
       fmt.Printf("Hello world\n")
}

would load these dlls

kernel32.dll
advapi32.dll
shell32.dll
wsock32.dll
ws2_32.dll
dnsapi.dll
iphlpapi.dll

Most of these dlls are network related and are not used
in this program. Now the same program loads only

kernel32.dll
shell32.dll

This decreases start times somewhat.

This also relaxes the rules of which dlls can be included
in the standard library. We could now include system calls
that are not available on all versions of Windows, because
we could decide if we should call them during runtime.

R=rsc, vcc.163
CC=golang-dev
https://golang.org/cl/4815046
2011-07-31 20:07:04 +10:00
Andrew Gerrand
ffccc026cb exp/norm: correct package doc comment
Fixes #2118.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/4815073
2011-07-30 18:02:09 -07:00
Robert Griesemer
7162f39fc3 exp/template: fix endless loop
No progress was made in indirect() if the reflect.Value
was an non-nil and non-empty interface.

R=r, r
CC=golang-dev
https://golang.org/cl/4810060
2011-07-30 17:11:52 -07:00
Rob Pike
1b4dff0f69 exp/template: simplify the helper functions
- create a pair of "Must" functions, one for templates, one for sets
- regularize the return values of the parsers so they can be wrapped by Must
- delete all the old Must functions and methods.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/4826052
2011-07-28 16:19:16 -07:00
Roger Peppe
ca68b2810d exp/template: make Set.ParseFile etc resolve functions in the Set
Fixes #2114

R=r
CC=golang-dev
https://golang.org/cl/4823056
2011-07-28 09:59:20 -07:00
Roger Peppe
3041f2a37c exp/template: make Set.MustParse* methods return the set.
This brings them into line with the Template.MustParse* methods
and makes it possible to use them in global variable initializations.

R=r
CC=golang-dev
https://golang.org/cl/4798059
2011-07-28 08:41:06 -07:00
Rob Pike
5a52c6ad29 rpc and exp/template: simplify tests for exported items
Fix code to count mallocs - needed to call UpdateMemStats.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4823055
2011-07-27 21:26:16 -07:00
Russ Cox
a1e7cd97d5 exp/regexp: implement regexp API using exp/regexp/syntax
Still need to write tests for new syntax
and fix bugs that the tests find, but this
is a good check point.

All tests pass.

Compared against existing regexp:

benchmark                                old ns/op    new ns/op    delta
regexp.BenchmarkLiteral                       1869          620  -66.83%
regexp.BenchmarkNotLiteral                    9489         7823  -17.56%
regexp.BenchmarkMatchClass                   10372         8386  -19.15%
regexp.BenchmarkMatchClass_InRange           10800         7750  -28.24%
regexp.BenchmarkReplaceAll                   13492         8519  -36.86%
regexp.BenchmarkAnchoredLiteralShortNonMatch   747          339  -54.62%
regexp.BenchmarkAnchoredLiteralLongNonMatch    599          335  -44.07%
regexp.BenchmarkAnchoredShortMatch            2137          917  -57.09%
regexp.BenchmarkAnchoredLongMatch             2029          917  -54.81%

R=r, r
CC=golang-dev, sam.thorogood
https://golang.org/cl/4820046
2011-07-24 17:00:28 -04:00
Rob Pike
2d972ad493 exp/template: construct sets from plain template files
This is the last piece (I hope) of the set creation code.
These helpers create sets from files containing individual
template definitions, free of {{define}} clauses. This
design is helpful if the templates live one per file,
undecorated.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4801052
2011-07-23 18:10:30 +10:00
Rob Pike
f0d8af200c exp/template: trivial cleanup in test
Clean up glitch created by flurry of editing.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4808052
2011-07-22 17:52:46 +10:00
Rob Pike
222450addb exp/template: add globbing helpers to load groups of files into sets.
Also make the Set.Parse methods variadic so you can parse static lists of files without loops.

R=rsc, dsymonds, r
CC=golang-dev
https://golang.org/cl/4802051
2011-07-22 13:55:45 +10:00
Rob Pike
3e79c958c4 exp/template: plain actions with declarations should produce no output.
This is already the behavior for pipelines producing values for if, with, and range.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4808050
2011-07-22 10:51:40 +10:00
Roger Peppe
47647b9865 exp/template: fix action variable declarations inside range
R=r
CC=golang-dev
https://golang.org/cl/4807043
2011-07-22 09:53:25 +10:00
Rob Pike
0f7a1951b8 exp/template: A template can be in one set only.
This simplifies the API and makes it easier to make the template
invocation statically secure, at the cost of some minor flexibility.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/4794045
2011-07-21 14:22:01 +10:00
Marcel van Lohuizen
df07b6d14a exp/norm: API for normalization library.
R=r, r, mpvl, rsc
CC=golang-dev
https://golang.org/cl/4678041
2011-07-20 19:46:05 +10:00
Alex Brainman
208e6e6dfc exp/wingui: make sure it builds again
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4770041
2011-07-19 13:18:21 +10:00
Rob Pike
9a5bb287e8 exp/template: dig into empty interfaces so a struct (say) stored in an empty
interface field can be unpacked. We don't have type assertions here so we
must be forthright.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4757047
2011-07-18 17:34:42 +10:00
Rob Pike
c705701c69 exp/templates: variable scope persists until "end".
The previous CL doicumented and diagnosed the old situation.
This one changes it to something more traditional: any action
may declare a variable, and the block structure of scopes
applies only to control seequences.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4748047
2011-07-17 13:31:59 +10:00
Rob Pike
331840f509 exp/template: allow declaration of variables only inside control structures.
In simple pipelines the declaration has no scope.
Also document the scope.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4761044
2011-07-17 12:32:00 +10:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Rob Pike
fc1f0bd5e9 exp/template: allow range actions to declare a key and element variable.
{{range $key, $element := pipeline}}
This CL is smaller than it looks due to some rearrangement and renaming.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4709047
2011-07-14 13:15:55 +10:00
David Symonds
a16ad6fe0f exp/template: escape < and > in JS escaper.
Angle brackets can trigger some browser sniffers,
causing some output to be interpreted as HTML.
Escaping angle brackets closes that security hole.

R=r
CC=golang-dev
https://golang.org/cl/4714044
2011-07-14 12:02:58 +10:00
Rob Pike
dfffc7a5d5 exp/template: include function name in error returned by function or method call.
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/4711049
2011-07-14 11:32:06 +10:00
Rob Pike
19e207d24d exp/template: simplify method and function calls by using the value's Method
rather than the type's, so a method's invocation works the same as a function's.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/4704049
2011-07-14 11:00:23 +10:00
Rob Pike
469e333106 exp/template: tweak behavior of booleans.
Russ suggested this technique, making the "and" and "or" functions handier.
But it's hacky, and I can be talked out of it.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/4698044
2011-07-14 07:59:04 +10:00
Rob Pike
c3344d61bd exp/template: allow niladic methods inside chained field references.
Also really fix the bug about dot vs. receivers.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4705047
2011-07-14 07:52:07 +10:00
Brad Fitzpatrick
dcdaeebdfb docs: fix wrong it's -> its
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/4702046
2011-07-13 10:54:51 -07:00
Sam Thorogood
e3a773479d exp/regexp/syntax: add Prog.NumCap
R=rsc, r
CC=golang-dev
https://golang.org/cl/4662083
2011-07-13 10:15:00 -07:00
Robert Griesemer
4c986d86b1 exp/eval, exp/ogle: remove packages eval and ogle
An externally maintained version of exp/eval can
be found at: https://bitbucket.org/binet/go-eval/ .

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/4695047
2011-07-13 09:40:53 -07:00
Rob Pike
7aa1a1a64d exp/template: doc and API changes suggested by rsc.
- template invocation is by string constant only.
- NewSet is gone.
- no global Funcs
- writer is now first arg to Execute

R=rsc, r
CC=golang-dev
https://golang.org/cl/4700043
2011-07-13 15:58:31 +10:00
Rob Pike
2e9388e321 exp/template: add Set.AddSet and Set.Union.
Document and test that Set.Parse can be called multiple times.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4703044
2011-07-13 13:50:05 +10:00
Rob Pike
41efecf51c exp/template: allow variables as template names.
Just an oversight it wasn't already there.
Thanks to islandberry@live.com for pointing out the omission.

R=golang-dev, dsymonds
CC=golang-dev, islandberry
https://golang.org/cl/4703043
2011-07-13 13:21:18 +10:00
Nigel Tao
8bd5089513 image: change Pix from []FooColor to []uint8.
Some benchmark numbers below. The image/draw fast-paths show dramatic
improvement, the generic slow-paths show a smaller slow-down.

BEFORE
png.BenchmarkEncodePaletted      200       8203800 ns/op      37.45 MB/s
png.BenchmarkEncodeRGBOpaque         100      26940440 ns/op      45.61 MB/s
png.BenchmarkEncodeRGBA       20      73821000 ns/op      16.65 MB/s
jpeg.BenchmarkEncodeRGBOpaque         50      35598640 ns/op      34.52 MB/s
draw.BenchmarkFillOver	     500	   4024226 ns/op
draw.BenchmarkFillSrc	   10000	    152736 ns/op
draw.BenchmarkCopyOver	     500	   3452824 ns/op
draw.BenchmarkCopySrc	   50000	     73218 ns/op
draw.BenchmarkNRGBAOver	     500	   3941234 ns/op
draw.BenchmarkNRGBASrc	    1000	   2484400 ns/op
draw.BenchmarkYCbCr	    1000	   2609005 ns/op
draw.BenchmarkGlyphOver	    2000	   1169575 ns/op
draw.BenchmarkRGBA	     200	   9031390 ns/op
draw.BenchmarkGenericOver	      50	  34636620 ns/op
draw.BenchmarkGenericMaskOver	     100	  16561150 ns/op
draw.BenchmarkGenericSrc	     100	  13873760 ns/op
draw.BenchmarkGenericMaskSrc	     100	  25198860 ns/op

AFTER
png.BenchmarkEncodePaletted      200       8206600 ns/op      37.43 MB/s
png.BenchmarkEncodeRGBOpaque         100      26129530 ns/op      47.03 MB/s
png.BenchmarkEncodeRGBA       20      75776750 ns/op      16.22 MB/s
jpeg.BenchmarkEncodeRGBOpaque         50      37192940 ns/op      33.04 MB/s
draw.BenchmarkFillOver	     500	   3008134 ns/op
draw.BenchmarkFillSrc	   10000	    154214 ns/op
draw.BenchmarkCopyOver	    1000	   2169988 ns/op
draw.BenchmarkCopySrc	   50000	     73095 ns/op
draw.BenchmarkNRGBAOver	    1000	   2491079 ns/op
draw.BenchmarkNRGBASrc	    2000	   1361244 ns/op
draw.BenchmarkYCbCr	    1000	   2554269 ns/op
draw.BenchmarkGlyphOver	    2000	   1042225 ns/op
draw.BenchmarkRGBA	     100	  10233340 ns/op
draw.BenchmarkGenericOver	      50	  38421560 ns/op
draw.BenchmarkGenericMaskOver	     100	  17521190 ns/op
draw.BenchmarkGenericSrc	     100	  16351200 ns/op
draw.BenchmarkGenericMaskSrc	     100	  26538190 ns/op

R=r
CC=golang-dev
https://golang.org/cl/4675076
2011-07-12 16:39:38 +10:00
Rob Pike
7c47741811 exp/template: make numbers adhere to Go's rules for ideal constants.
Without further type informatnion, 1.0 is a float and an integer
must fit in an int.

R=rsc
CC=golang-dev
https://golang.org/cl/4696042
2011-07-12 13:15:26 +10:00
Rob Pike
d366c36945 exp/template: fix bug in argument evaluation.
Must keep dot and the receiver separate - variables broke that symmetry.
Also clean up function invocation and rename "data" to "dot" for clarity.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4678048
2011-07-11 18:06:24 +10:00
Rob Pike
7b79b3b244 exp/template: fields and methods on variables.
Not strictly necessary (you could achieve the same, clumsily,
via with blocks) but great to have: $x.Field, $y.Method.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4678047
2011-07-11 15:23:38 +10:00
Rob Pike
96bbcc4256 exp/template: documentation glitches and typos.
Also explain that len(v)==0 makes v a 'zero value'
in template execution.

R=golang-dev, dsymonds, adg, r
CC=golang-dev
https://golang.org/cl/4691041
2011-07-11 14:43:21 +10:00
Rob Pike
0027dc91b0 exp/template: simpler parse of char constants.
We can avoid the check against empty constants (''),
which UnquoteChar doesn't handle well, by leaving on
the trailing quote and seeing that's all we have left at the end.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4657090
2011-07-11 12:36:10 +10:00
Rob Pike
bf9531f80b exp/template: character constants.
Easier to implement than to justify leaving them out.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4662089
2011-07-11 11:46:22 +10:00
Rob Pike
e7030e7fef exp/template: static check for defined variables.
Worth catching at parse time rather than execution. Plus it's really easy.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4641100
2011-07-11 10:01:15 +10:00
Rob Pike
1fe9c9a78f exp/eval: delete binary
Mistakenly checked in.
Fixes #2058.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4670057
2011-07-11 09:36:17 +10:00
Rob Pike
abae847134 exp/template: add functions print and println.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4687041
2011-07-11 09:19:18 +10:00
Rob Pike
4acddca41b exp/template: package documentation
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4675072
2011-07-10 20:56:26 +10:00
Nigel Tao
87d9e7e166 image: change Pix[0] to mean top-left corner of an image's Rect instead
of the origin.

image/png and image/jpeg benchmarks show no significant changes.

The image/draw changes suggest to me that making a gofix for this is not
feasible. People are just going to have to make manual fixes.

R=r
CC=golang-dev
https://golang.org/cl/4681044
2011-07-10 14:29:47 +10:00
Rob Pike
3987b91213 exp/template: better template invocation
1) Make the value optional ({{template "foo"}})
2) Allow the template identifier to be a thing of type *Template.
The second makes it easy to drop templates in to a set dynamically
during invocation.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4671056
2011-07-10 07:32:01 +10:00
Rob Pike
e86d727e60 exp/template: vars as arguments to functions and methods.
That should be it, bugs aside.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4671055
2011-07-09 17:11:35 +10:00
Rob Pike
58baf64827 exp/template: variable evaluation.
Still need to do static checking of declarations during parse.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/4667070
2011-07-09 12:05:39 +10:00
Rob Pike
bbf5eb5ba2 exp/template: delete upward evaluation.
It was an ill-advised carryover from the previous template package.
Also clean up function evaluation.
Also add a Name method to Template.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4657088
2011-07-09 08:59:56 +10:00
Rob Pike
d3d08e1e3a exp/template: forgot to allow . as a function argument
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4671053
2011-07-08 18:25:46 +10:00
Rob Pike
b8c664297b exp/template: parse variables and declarations
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4631099
2011-07-08 17:54:16 +10:00
Rob Pike
ee14989e43 exp/template: lex variables
Variables start with'$' and are declared with ':='.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4662084
2011-07-08 17:53:55 +10:00
Rob Pike
02039b6345 exp/template: add a tree-walking example to the test.
Also fix a comment formatting glitch.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4672054
2011-07-08 16:49:06 +10:00
Andrew Gerrand
ad58dc9d26 exp/template: the must-have MustParse functions
R=r
CC=golang-dev
https://golang.org/cl/4641096
2011-07-08 16:01:32 +10:00
Rob Pike
a852981d17 exp/template: allow fields and methods to be found in parent structs.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4657085
2011-07-08 15:22:05 +10:00
Andrew Gerrand
5bcbcab311 sort: rename helpers: s/Sort// in sort.Sort[Float64s|Ints|Strings]
Includes 'sorthelpers' gofix and updates to tree.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4631098
2011-07-08 10:52:50 +10:00
Rob Pike
238274ede0 exp/template: handle pointers and values in empty interfaces.
R=golang-dev, r, mattn.jp
CC=golang-dev
https://golang.org/cl/4664064
2011-07-07 14:51:35 +10:00
Rob Pike
8d538c6d3d exp/template: change the name from 'metacharacter' to 'delimiter',
because that's what they are.
No semantic change.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4675060
2011-07-07 10:56:33 +10:00
Rob Pike
46ecd6f141 exp/template: index: forgot the always last-to-arrive uintptr.
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4636087
2011-07-07 07:00:48 +10:00
Rob Pike
6732bd3526 exp/template: index function for arrays, slices, and maps.
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/4643072
2011-07-06 22:27:06 +10:00
Rob Pike
64228e36a4 exp/template: silence test noise (but add a flag to put it back)
Also delete a TODO and clean up a little evaluation code.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4643071
2011-07-06 17:46:36 +10:00
David Symonds
33705ddea1 exp/template: add a JavaScript escaper.
R=r
CC=golang-dev
https://golang.org/cl/4671048
2011-07-06 16:51:49 +10:00
Rob Pike
a33cc423b4 exp/template: allow an empty interface value to be the target of range, etc.
We extract the concrete value inside.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4677041
2011-07-06 16:40:46 +10:00
Rob Pike
381a555f40 exp/template: improve error message for non-exported field.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4636086
2011-07-06 15:56:39 +10:00
David Symonds
9d5ed1744a exp/template: add missing dotNode case.
R=r
CC=golang-dev
https://golang.org/cl/4672044
2011-07-06 15:14:10 +10:00
Rob Pike
9495dd31d2 exp/template: fixes and updates.
- fix line numbers - forgot to update state.line during execution
- add a comment convention {{/* comment */}}
- set.Template returns the named template in the set
- set.Execute executes the named template in the set
- use a local methodByName so this package can be used with earlier release of reflect.
- use initial cap to detect exported names

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4668054
2011-07-06 14:46:41 +10:00
David Symonds
d45ba2c146 exp/template: remove debugging dreg.
R=r, gri
TBR=r
CC=golang-dev
https://golang.org/cl/4671047
2011-07-06 14:18:46 +10:00
Rob Pike
329990d525 exp/template: remove the need for a goroutine.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4626095
2011-07-06 11:02:53 +10:00
Rob Pike
4657d7d7db exp/template: remove the visibility of the token channel from the parser.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4675053
2011-07-06 10:13:53 +10:00
Rob Pike
eea5443572 exp/template: add templates to sets; boolean logic.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4670045
2011-07-05 17:05:15 +10:00
Rob Pike
5b1658232e exp/template: statically check that functions names have been defined.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4675046
2011-07-05 16:02:34 +10:00
Rob Pike
cc9fed7c1a exp/template: add an html escaping function.
R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/4626092
2011-07-05 15:58:54 +10:00
Rob Pike
b177c97803 exp/template: functions
Add the ability to attach functions to template and template sets.
Make variadic functions and methods work.
Still to come: static checking of function names during parse.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4643068
2011-07-05 14:23:51 +10:00
Rob Pike
13f889778e exp/template: add template sets, allowing templates to reference one another
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4673042
2011-07-04 15:15:47 +10:00
Rob Pike
72efdea20e exp/template: allow complex numbers, add 'with', 'define', and 'template' keywords.
Also simplify the handling of keywords.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4639096
2011-07-04 11:50:35 +10:00
Brad Fitzpatrick
3aa8272e44 fix build; add simplify.go to regexp Makefile
R=rsc
CC=golang-dev
https://golang.org/cl/4643062
2011-06-30 10:45:36 -07:00
Russ Cox
b4cae4aee2 exp/regexp/syntax: finish Regexp manipulation
Except for the inevitable bug fixes, the Regexp code is done.

R=sam.thorogood, r
CC=golang-dev
https://golang.org/cl/4635082
2011-06-30 10:26:22 -04:00
Rob Pike
c756a1954c exp/template: boolean constants
R=rsc
CC=golang-dev
https://golang.org/cl/4628073
2011-06-29 15:02:04 +10:00
Russ Cox
7e1a3e9f20 exp/regexp/syntax: incremental concat, alternate
Also reuse of *Regexp nodes.

I believe this is the end of the parser.
The only non-execution code that remains is
the code to expand x{3,5} into simpler operations.

R=sam.thorogood, r
CC=golang-dev
https://golang.org/cl/4629078
2011-06-29 00:55:37 -04:00
Rob Pike
c2e0d604ee exp/template: fix build
wrong path in Makefile. why didn't my all.bash fail?
TBR=dsymonds

R=dsymonds
CC=golang-dev
https://golang.org/cl/4630075
2011-06-29 13:55:49 +10:00
Rob Pike
a733f0bcd1 exp/template: use MethodByName, add to build.
R=rsc, adg, r
CC=golang-dev
https://golang.org/cl/4641081
2011-06-29 13:44:13 +10:00
Rob Pike
81592c298b Add the beginnings of the template execution code. Lots still to do,
including evaluation up the data tree (in this code all fields must be
in dot itself), plus more control structure, but the basics are in place.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4665041
2011-06-28 23:04:08 +10:00
Russ Cox
52cd055f91 exp/regexp/syntax: case-folding in character classes
Also fix \x{123} parsing.

R=r
CC=golang-dev
https://golang.org/cl/4632052
2011-06-27 23:23:51 -04:00
Russ Cox
46e7466080 exp/regexp/syntax: compiled form
R=r, sam.thorogood, kevlar
CC=golang-dev, rsc
https://golang.org/cl/4636046
2011-06-27 19:52:59 -04:00
Rob Pike
ebb1566a46 strings.Split: make the default to split all.
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.

R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
2011-06-28 09:43:14 +10:00
Rob Pike
96731619ce exp/template: make -0 be an unsigned int.
Fix (inconsequential) type error in list initializer.

R=rsc
CC=golang-dev
https://golang.org/cl/4638058
2011-06-23 10:19:29 +10:00
Rob Pike
cd7826e5f6 First cut at the parser for the new template package.
This is not a full grammar, but the pieces are there to implement whatever we converge on.

R=rsc
CC=golang-dev
https://golang.org/cl/4629053
2011-06-23 09:27:28 +10:00
Russ Cox
21e75da486 respect goto restrictions
R=gri
CC=golang-dev
https://golang.org/cl/4625044
2011-06-17 06:07:13 -04:00
Russ Cox
1a4681ed74 exp/regexp/syntax: more escapes, character classes
Still TODO: parsing optimizations

make_perl_groups.pl is copied with minimal modifications
(just to generate Go syntax instead of C++) from RE2.
Google Inc is "The RE2 Author" of that file and is one of
the Go Authors, so copyright changed to the Go Authors instead.

R=sam.thorogood, r, fvbommel, robert.hencke
CC=golang-dev
https://golang.org/cl/4612041
2011-06-14 14:30:10 -04:00
Russ Cox
b96c3477f8 exp/regexp/syntax: syntax data structures, parser
Parser is a work in progress but can populate most of the
interesting parts of the data structure, so a good checkpoint.
All the complicated Perl syntax is missing, as are various
important optimizations made during parsing to the
syntax tree.

The plan is that exp/regexp's API will mimic regexp,
and exp/regexp/syntax provides the parser directly
for programs that need it (and for implementing exp/regexp).

Once finished, exp/regexp will replace regexp.

R=r, sam.thorogood, kevlar, edsrzf
CC=golang-dev
https://golang.org/cl/4538123
2011-06-13 09:20:23 -04:00
Rob Pike
7bc8e90e36 exp/template: lexical scanner for new template package.
An unusual design using slice and a goroutine makes for a
compact scanner with very little allocation.

R=rsc, r
CC=golang-dev, kevlar
https://golang.org/cl/4610041
2011-06-13 16:08:35 +10:00
Nigel Tao
b47a38dedb image/draw: move exp/draw to image/draw and exp/gui.
R=r
CC=golang-dev
https://golang.org/cl/4515191
2011-06-05 14:27:38 +10:00
Nigel Tao
f531ef3279 image: rename Contains and ContainsRectangle to In.
R=r
CC=golang-dev
https://golang.org/cl/4539104
2011-06-03 13:18:15 +10:00
Nigel Tao
ae5a972d9e exp/draw: fix clipping bug where sp/mp were not shifted when r.Min was.
image: add Rectangle.ContainsRectangle method.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4517130
2011-06-03 11:43:54 +10:00
Yasuhiro Matsumoto
c0decc35ae exp/eval: fix compile error.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4550086
2011-05-26 22:05:25 +10:00
Robert Hencke
c8727c81bb pkg: spelling tweaks, A-H
R=ality, bradfitz, rsc, dsymonds, adg, qyzhai, dchest
CC=golang-dev
https://golang.org/cl/4536063
2011-05-18 13:14:56 -04:00
Alex Brainman
8253edcb4c wingui: fix Makefile after rename
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4477046
2011-05-06 17:15:46 +10:00
Nigel Tao
13f08cd807 exp/draw: fast paths for drawing a YCbCr or an NRGBA onto an RGBA.
On my laptop, I had an 800x600 jpeg and an 800x600 png (with
transparency). I timed how long it took to draw each image onto an
equivalently sized, zeroed RGBA image.

Previously, the jpeg took 75ms and the png took 70ms, going through
the medium-fast path, i.e. func drawRGBA in draw.go.

After this CL, the jpeg took 14ms, and the png took 21ms with the
Over operator and 12ms with the Src operator.

It's only a rough estimate basd on one image file, but it should
give an idea of the order of magnitude of improvement.

R=rsc, r
CC=adg, golang-dev
https://golang.org/cl/4468044
2011-05-04 10:17:53 -07:00
Russ Cox
07abf1c732 fix tree for reflect rename
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4435067
2011-04-25 13:39:36 -04:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Russ Cox
4c006182dc pkg: manual cleanup of some gofixed code
R=golang-dev, niemeyer, r
CC=golang-dev
https://golang.org/cl/4372052
2011-04-13 23:36:00 -04:00
Robert Griesemer
a2e286828b gofmt: gofmt -s -w src misc
R=r, bradfitzwork
CC=golang-dev
https://golang.org/cl/4406044
2011-04-13 15:13:59 -07:00
Russ Cox
db5c5d6fa6 update go tree for reflect changes
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4353043
2011-04-08 12:27:58 -04:00
Rob Pike
8a90fd3c72 os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)

This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)

The interesting packages are:
        gofix
        os
Everything else is automatically generated except for hand tweaks to:
        src/pkg/io/ioutil/ioutil.go
        src/pkg/io/ioutil/tempfile.go
        src/pkg/crypto/tls/generate_cert.go
        src/cmd/goyacc/goyacc.go
        src/cmd/goyacc/units.y

R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
2011-04-04 23:42:14 -07:00
Russ Cox
5546cc7eab update tree for package net changes
Converted with gofix.

R=adg
CC=golang-dev
https://golang.org/cl/4284049
2011-03-28 23:28:53 -04:00
Robert Griesemer
b2658452a6 go/scanner: return literal as string instead of []byte
Removed many string conversions in dependent code.
Runs all tests. No change to gofmt output.

R=r
CC=golang-dev
https://golang.org/cl/4291070
2011-03-28 16:44:28 -07:00
Rob Pike
7f9acb53cb testing: shorten some more tests
R=rsc
CC=golang-dev
https://golang.org/cl/4314044
2011-03-26 11:25:22 -07:00
Robert Griesemer
7ea8cdaabd go/ast: merge CaseClause and TypeCaseClause
(per rsc's suggestion)

R=rsc
CC=golang-dev
https://golang.org/cl/4276057
2011-03-16 14:25:59 -07:00
Russ Cox
b04209ca97 debug/proc: fix build
R=r
CC=golang-dev
https://golang.org/cl/4273060
2011-03-15 19:39:50 -04:00
Robert Griesemer
021b040a1e go/ast, go/parser: populate identifier scopes at parse time
The parser populates all scopes for a given file (except
type-related scopes for structs, interfaces, and methods
of types) at parse time.

A new parser flag, DeclarationErrors, enables error messages
related to declaration errors (as far as it is possible to
provide them).

The resulting AST has all (non-field, non-method) identifiers
resolved that can be resolved w/o doing imports or parsing
missing package files.

The ast.File node contains the (partially complete)
package scope and a list of unresolved global identifiers.

All type-specific data structures have been removed from the AST.

The existing typechecker is functional but needs to be adjusted
(simplified) accordingly. Utility functions to resolve all
identifiers for a package (after handling imports and parsing
all package files) are  missing.

Unrelated changes:
- Rename typechecker/testdata files to that they are not considered
  by gofmt.
- Minor cleanups/simplifications.

Parses all .go files in src and misc without declaration errors.
Runs all tests. Changes do not affect gofmt output.

R=rsc
CC=golang-dev
https://golang.org/cl/4244049
2011-03-07 11:01:23 -08:00
Alex Brainman
75fb2f6c82 8l/6l: new -Hwindowsgui flag allows to build windows gui pe
Fixes #1516.

R=rsc, mattn
CC=golang-dev
https://golang.org/cl/4214041
2011-02-24 16:10:30 +11:00
Robert Griesemer
cd0f799e65 exp/eval, go/printer: fix build
There are some minor irregularities in the printer
output (some paren's are present that should be
removed), but these are unrelated issues.
Will review in a 2nd step.

R=rsc
CC=golang-dev
https://golang.org/cl/4188068
2011-02-22 18:17:03 -08:00
Alex Brainman
cf75c86cdf syscall: change windows apis with bool return value to return errno instead
This change is to make these apis similar to their unix counterparts.

R=rsc
CC=golang-dev
https://golang.org/cl/4185042
2011-02-11 10:15:51 +11:00
Rob Pike
34fc17a820 src/*: fix incorrect prints found by govet
R=gri
CC=golang-dev
https://golang.org/cl/4169044
2011-02-09 17:11:01 -08:00
Rob Pike
fb9e37cd9b template: reverse order of arguments to Execute
In line with other functions such as Fprintf, put the
thing to be written first.

Apologies for the breakages this is sure to cause.

R=rsc, gri, adg, eds, r2, aam
CC=golang-dev
https://golang.org/cl/4169042
2011-02-09 14:23:01 -08:00
Hector Chu
62afa225af windows: multiple improvements and cleanups
The callback mechanism has been made more flexible.
Eliminated one round of argument copying in Syscall.
Faster Get/SetLastError implemented.
Added gettime for gc perf profiling.

R=rsc, brainman, mattn, rog
CC=golang-dev
https://golang.org/cl/4058046
2011-02-01 11:49:24 -05:00
Russ Cox
f4e76d8309 replace non-blocking send, receive syntax with select
R=golang-dev, nigeltao, niemeyer, r
CC=golang-dev
https://golang.org/cl/4079053
2011-01-31 18:36:28 -05:00
Hector Chu
90294a08c8 runtime: make Walk webbrowser example work
R=rsc, brainman, lxn
CC=golang-dev
https://golang.org/cl/4005045
2011-01-25 17:56:33 +11:00
Alex Brainman
f0b8f84d37 runtime: implementation of callback functions for windows
R=rsc, lxn, alex.brainman, dho
CC=golang-dev
https://golang.org/cl/1696051
2011-01-22 13:55:53 +11:00
Russ Cox
f2b5a07453 delete float, complex - code changes
also:
	cmplx -> complex
	float64(1.0) -> 1.0
	float64(1) -> 1.0

R=gri, r, gri1, r2
CC=golang-dev
https://golang.org/cl/3991043
2011-01-19 23:09:00 -05:00
Robert Griesemer
4ed7c59a50 fix build (this time for real): adjust typechecker test, ogle
R=r, r2
CC=golang-dev
https://golang.org/cl/4006041
2011-01-13 17:41:45 -08:00
Robert Griesemer
bff2c207e4 go/scanner: Make Init take a *token.File instead of a *token.FileSet.
Until now, each scan of a file added a new file to the file set.
With this change, a file can be re-scanned using the same *token.File
w/o changing the file set. Eventually this will enable the re-use of
cached source code in godoc (for the fulltext index). At the moment,
source files are read over and over again from disk.

This is the first step in that direction.

R=r, rsc, r2
CC=golang-dev
https://golang.org/cl/4001041
2011-01-13 17:20:26 -08:00
Robert Griesemer
8184778abf fix occurrences of occur[^sr .,?!;\n]
R=r, r2
CC=golang-dev
https://golang.org/cl/3794043
2011-01-04 13:16:50 -08:00
Robert Griesemer
9214016b3d go/ast: provide complete node text range info
- add End() method to all nodes; the text range of a node n is [n.Pos(), n.End())
- various small bug fixes in the process
- fixed several comments

R=r, rsc
CC=golang-dev
https://golang.org/cl/3769042
2011-01-04 10:14:16 -08:00
Sebastien Binet
33145c4868 simple fix to not have 'exp/eval' panic in presence of slices like s[:2]
R=golang-dev, gri
CC=binet, golang-dev
https://golang.org/cl/3782044
2010-12-27 10:05:32 -08:00
Nigel Tao
0bf2aa1aa7 exp/draw: remove Border function.
It was only used by exp/4s, and even if it is general purpose, I think
it belongs in a graphics library atop exp/draw, not in exp/draw itself.

R=rsc
CC=golang-dev
https://golang.org/cl/3705041
2010-12-16 15:11:10 +11:00
Russ Cox
0c54225b51 remove nacl
The recent linker changes broke NaCl support
a month ago, and there are no known users of it.

The NaCl code can always be recovered from the
repository history.

R=adg, r
CC=golang-dev
https://golang.org/cl/3671042
2010-12-15 11:49:23 -05:00
Ryan Hitchman
062406bc64 throughout: simplify two-variable ranges with unused second variable
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/3529041
2010-12-08 21:36:56 -08:00
Rob Pike
14804a412b event.go: another print glitch from gocheck.
R=rsc
CC=golang-dev
https://golang.org/cl/3524041
2010-12-08 17:12:25 -05:00
Robert Griesemer
5a9ad8b9e3 go/ast: use token.Pos instead of token.Position; adjust all dependent code
Specifically:

	* lib/godoc:
	- provide file set (FSet) argument to formatters where needed

	* src/cmd:
	- cgo, ebnflint, godoc, gofmt, goinstall: provide file set (fset) where needed
	- godoc: remove local binary search with sort.Search (change by rsc),
	  extract file set for formatters

	* src/pkg:
	- exp/eval: remove embedded token.Position fields from nodes and replace
	  with named token.Pos fields; add corresponding Pos() accessor methods
	- go/token: added file.Line(), changed signature of File.Position()

	* test/fixedbugs/:
	- bug206.go: change test to not rely on token.Pos details

	* added various extra comments
	* Runs all.bash
	* gofmt formats all of src, misc w/o changes
	* godoc runs

	* performance:
	- The new version of godoc consumes about the same space after indexing
	  has completed, but indexing is half the speed. Significant space savings
	  are expected from smaller ASTs, but since they are thrown away after a
	  file has been indexed, this is not visible anymore. The slower indexing
	  time is due to the much more expensive computation of line information.
	  However, with the new compressed position information, indexing can be
	  rewritten and simplified. Furthermore, computing the line info can be
	  done more efficiently.

        New godoc, immediately after indexing completed (best of three runs):

	  PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE
	44381 godoc        0.0%  0:38.00   4    19    149  145M   184K   148M   176M

	2010/12/03 17:58:35 index updated (39.231s, 18505 unique words, 386387 spots)
	2010/12/03 17:58:35 bytes=90858456 footprint=199182584
	2010/12/03 17:58:36 bytes=47858568 footprint=167295224

	Old godoc, immediately after indexing completed (best of three runs):

	  PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE
	23167 godoc        0.0%  0:22.02   4    17    132  129M   184K   132M   173M

	2010/12/03 14:51:32 index updated (24.892s, 18765 unique words, 393830 spots)
	2010/12/03 14:51:32 bytes=66404528 footprint=163907832
	2010/12/03 14:51:32 bytes=46282224 footprint=163907832

	The different numbers for unique words/spots stem from the fact the the
	two workspaces are not exactly identical. The new godoc maintains a large
	file set data structure during indexing which (probably) is the reason
	for the larger heap (90858456 vs 66404528) before garbage collection.

R=rsc, r
CC=golang-dev
https://golang.org/cl/3050041
2010-12-06 14:23:18 -08:00
Anschel Schaffer-Cohen
f5bc87cb75 exp/eval: build fix for parser.ParseFile API change.
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/3283042
2010-11-29 09:25:31 +11:00
Rob Pike
4e9cc085d2 testing: eliminate testing/regexp
Rather than updating the stripped-down regexp implementation embedded
in testing, delete it by passing the one function we need from the package
main file created by gotest.

R=rsc
CC=golang-dev
https://golang.org/cl/2761043
2010-10-28 16:54:24 -07:00
Russ Cox
69c4e9380b use append
R=gri, r, r2
CC=golang-dev
https://golang.org/cl/2743042
2010-10-27 19:47:23 -07:00
Russ Cox
d86ab015f7 use copy
R=gri
CC=golang-dev
https://golang.org/cl/2763041
2010-10-26 21:52:54 -07:00
Robert Griesemer
3478891d12 gofmt -s -w src misc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2662041
2010-10-22 10:06:33 -07:00
Rob Pike
12da5a90e0 log: new interface
New logging interface simplifies and generalizes.

1) Loggers now have only one output.
2) log.Stdout, Stderr, Crash and friends are gone.
	Logging is now always to standard error by default.
3) log.Panic* replaces log.Crash*.
4) Exiting and panicking are not part of the logger's state; instead
	the functions Exit* and Panic* simply call Exit or panic after
	printing.
5) There is now one 'standard logger'.  Instead of calling Stderr,
	use Print etc.  There are now triples, by analogy with fmt:
		Print, Println, Printf
	What was log.Stderr is now best represented by log.Println,
	since there are now separate Print and Println functions
	(and methods).
6) New functions SetOutput, SetFlags, and SetPrefix allow global
	editing of the standard logger's properties.   This is new
	functionality. For instance, one can call
		log.SetFlags(log.Lshortfile|log.Ltime|log.Lmicroseconds)
	to get all logging output to show file name, line number, and
	time stamp.

In short, for most purposes
	log.Stderr -> log.Println or log.Print
	log.Stderrf -> log.Printf
	log.Crash -> log.Panicln or log.Panic
	log.Crashf -> log.Panicf
	log.Exit -> log.Exitln or log.Exit
	log.Exitf -> log.Exitf (no change)

This has a slight breakage: since loggers now write only to one
output, existing calls to log.New() need to delete the second argument.
Also, custom loggers with exit or panic properties will need to be
reworked.

All package code updated to new interface.

The test has been reworked somewhat.

The old interface will be removed after the new release.
For now, its elements are marked 'deprecated' in their comments.

Fixes #1184.

R=rsc
CC=golang-dev
https://golang.org/cl/2419042
2010-10-12 12:59:18 -07:00
Nigel Tao
a3e971d355 image: another build fix regarding ColorImage.
R=adg
TBR=adg
CC=golang-dev
https://golang.org/cl/2449041
2010-10-12 14:33:37 +11:00
Nigel Tao
cd0a75f3d7 exp/draw: unbreak build.
R=adg
CC=golang-dev
https://golang.org/cl/2448041
2010-10-12 14:05:50 +11:00
Nigel Tao
b5a480f035 image: add image.Tiled type, the Go equivalent of Plan9's repl bit.
Make ColorImage methods' receiver type be a pointer.

R=r, rsc
CC=golang-dev
https://golang.org/cl/2345043
2010-10-12 13:44:11 +11:00
Russ Cox
e6ecf9765a exp/iterable: delete
Package iterable has outlived its utility.

It is an interesting demonstration, but it encourages
people to use iteration over channels where simple
iteration over array indices or a linked list would be
cheaper, simpler, and have fewer races.

R=dsymonds, r
CC=golang-dev
https://golang.org/cl/2436041
2010-10-11 22:38:42 -04:00
Nigel Tao
fd311cb144 exp/draw/x11: support X11 vendors other than "The X.Org Foundation".
R=adg, ehog.hedge
CC=golang-dev
https://golang.org/cl/2385041
2010-10-09 11:22:14 +11:00
Russ Cox
2ee420fa5e ... changes
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/2273042
2010-09-24 11:55:48 -04:00
Nigel Tao
099d7b4d1d exp/draw: remove "this isn't ready yet" comments.
R=rsc, r2
CC=golang-dev
https://golang.org/cl/2248046
2010-09-24 12:15:49 +10:00
Russ Cox
052cd29dd6 nacl: update instructions for new SDK
R=nigeltao_gnome, nigeltao
CC=golang-dev
https://golang.org/cl/2253042
2010-09-23 22:05:20 -04:00
Nigel Tao
d181625b9c exp/spacewar: fix build.
R=rsc
CC=golang-dev
https://golang.org/cl/2265042
2010-09-24 11:07:52 +10:00
Nigel Tao
58795ea31a exp/4s, exp/nacl/av: sync to recent exp/draw changes.
R=rsc
CC=golang-dev
https://golang.org/cl/2257042
2010-09-22 12:20:56 +10:00
Nigel Tao
bd77a889e6 exp/nacl/av: update color to max out at 1<<16-1 instead of 1<<32-1.
Fix missing return in Set(x, y, color).

R=r
CC=golang-dev
https://golang.org/cl/2256042
2010-09-21 16:13:19 +10:00
Nigel Tao
afbee9d87d exp/draw/x11: mouse location is a signed integer.
R=r
CC=golang-dev
https://golang.org/cl/2192043
2010-09-20 10:18:09 +10:00
Sebastien Binet
caf3b4a749 Preliminary support for 'copy' builtin function in exp/eval
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/2157042
2010-09-14 17:25:34 +10:00
Nigel Tao
5801928817 exp/draw: fast path for drawing overlapping image.RGBAs.
R=r, nigeltao
CC=golang-dev
https://golang.org/cl/2145045
2010-09-10 20:09:56 +10:00
Nigel Tao
d660d4a6d0 exp/draw: fix double-counting of pt.Min for the src and mask points.
The min is typically zero, which is why this hasn't bitten us yet.

R=r
CC=golang-dev
https://golang.org/cl/2119048
2010-09-10 19:48:27 +10:00
Nigel Tao
2deee2936c exp/draw: clip destination rectangle to the image bounds.
image: introduce Intersect and Union rectangle methods.

R=r, rog, nigeltao
CC=golang-dev
https://golang.org/cl/2115043
2010-09-09 19:12:54 +10:00
Nigel Tao
6c8b85273c exp/draw: rename Context to Window, and add a Close method.
exp/draw/x11: allow clean shutdown when the user closes the window.

R=r
CC=golang-dev
https://golang.org/cl/2134045
2010-09-09 18:06:59 +10:00
Nigel Tao
fa92b113b1 exp/draw: reintroduce the MouseEvent.Nsec timestamp.
R=rsc
CC=golang-dev
https://golang.org/cl/2166042
2010-09-07 23:42:01 +10:00
Nigel Tao
c849b23ce9 exp/draw: unify a draw.Context's keyboard, mouse, etc. channels into a
single event channel.

A quit event is now represented by closing that channel.

R=r, rsc, nigeltao
CC=golang-dev
https://golang.org/cl/2114042
2010-09-06 19:22:49 +10:00