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

210 Commits

Author SHA1 Message Date
Robin Eklind
3692dfdd0a fmt: Remove dead code and make comments and variables consistent.
R=minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/7064055
2013-01-22 17:12:45 -05:00
Oling Cat
f296adf819 fmt: update an old comment; fix a typo.
R=golang-dev, iant
CC=golang-dev, minux.ma
https://golang.org/cl/6998055
2012-12-25 14:54:24 -08:00
Russ Cox
1cad1f8d1c fmt: document width and flags a bit more
Fixes #4581.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7000052
2012-12-22 13:36:39 -05:00
Shenghou Ma
5a2c275be1 fmt, encoding/gob: fix misuse of Read
reader.Read() can return both 0,nil and len(buf),err.
To be safe, we use io.ReadFull instead of doing reader.Read directly.

Fixes #3472.

R=bradfitz, rsc, ality
CC=golang-dev
https://golang.org/cl/6285050
2012-12-18 01:26:48 +08:00
Oling Cat
6dd7da8566 fmt: fix a typo
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6937065
2012-12-17 18:13:12 +11:00
Russ Cox
07cc05864c fmt: fix %v of complex slice
Fixes #4525.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6929049
2012-12-11 11:49:41 -05:00
Shenghou Ma
9e30b708a1 all: set GOMAXPROCS to 1 when counting mallocs
also fix an annoying test that relies on $GOROOT be set.
Fixes #3690.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6844086
2012-12-01 00:38:01 +08:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Rob Pike
e171b97ee6 fmt: document some undocumented details
Better explanation of width for floating-point values.
Explain that scanning does not handle %#q etc.

Fixes #4202.
Fixes #4206.

R=golang-dev, adg, rsc, iant
CC=golang-dev
https://golang.org/cl/6620074
2012-10-12 16:16:55 +11:00
Rob Pike
ffea835b8f fmt: allow # and x together for strings
Silly and small but easy to be consistent.
To make it worthwhile, I eliminated an allocation when using
%x on a byte slice.

Fixes #4149.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6574046
2012-09-27 06:21:38 +10:00
Rob Pike
3ba0f6daf5 fmt: honor integer radix formats (%d etc.) for pointers
Before, pointers always appeared as 0x1234ABCD. This CL
keeps that as the default for %p and %v, but lets explicit
numeric verbs override the default.
Fixes #3936.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6441152
2012-08-17 16:12:25 -07:00
Rob Pike
a308be5fa8 fmt: set p.field before nil check
Fixes #3752.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6331062
2012-06-25 16:48:20 -07:00
Rob Pike
2a0fdf6ea0 fmt.Fscanf: don't read past newline
Makes interactive uses work line-by-line.
Fixes #3481.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/6297075
2012-06-11 17:52:09 -04:00
Daniel Morsing
c8cbbd31f0 fmt: fix doc typo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6308046
2012-06-06 16:54:02 -04:00
Russ Cox
ee3c272611 fmt: fix inadvertent change to %#v
The reordering speedup in CL 6245068 changed the semantics
of %#v by delaying the clearing of some flags.  Restore the old
semantics and add a test.

Fixes #3706.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6302048
2012-06-06 15:08:00 -04:00
Rob Pike
53bc19442d fmt: speed up 10-20%
The check for Stringer etc. can only fire if the test is not a builtin, so avoid
the expensive check if we know there's no chance.
Also put in a fast path for pad, which saves a more modest amount.

benchmark                      old ns/op    new ns/op    delta
BenchmarkSprintfEmpty                148          152   +2.70%
BenchmarkSprintfString               585          497  -15.04%
BenchmarkSprintfInt                  441          396  -10.20%
BenchmarkSprintfIntInt               718          603  -16.02%
BenchmarkSprintfPrefixedInt          676          621   -8.14%
BenchmarkSprintfFloat               1003          953   -4.99%
BenchmarkManyArgs                   2945         2312  -21.49%
BenchmarkScanInts                1704152      1734441   +1.78%
BenchmarkScanRecursiveInt        1837397      1828920   -0.46%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6245068
2012-05-29 15:08:08 -07:00
Rob Pike
a662d3d9a7 fmt: fix crash of %b on huge negative int64
The buffer had 64 bytes but needs one more for the sign.

Fixes #3510.

R=golang-dev, dave, dsymonds
CC=golang-dev
https://golang.org/cl/6011057
2012-04-13 09:28:37 +10:00
Shenghou Ma
62bb39e2ba fmt: remove dead code
Also fix a typo in comment.

R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5808043
2012-03-14 04:59:17 +08:00
Robert Hencke
663a7716a1 crypto/tls, fmt: print fixes
R=golang-dev, bradfitz, minux.ma, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5787069
2012-03-12 12:04:45 +09:00
Volker Dobler
d7d1b18a5d fmt: minor tweak of package doc to show headings in godoc
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5781052
2012-03-08 22:22:36 +11:00
Russ Cox
0bc18811b5 fmt, log: stop using unicode
$ go list -f '{{.ImportPath}} {{.Deps}}' fmt log
fmt [errors io math os reflect runtime strconv sync sync/atomic syscall time unicode/utf8 unsafe]
log [errors fmt io math os reflect runtime strconv sync sync/atomic syscall time unicode/utf8 unsafe]

R=bradfitz, rogpeppe, r, r, rsc
CC=golang-dev
https://golang.org/cl/5753055
2012-03-06 23:27:11 -05:00
Rob Pike
c0e74b63cf fmt: scan FALSE correctly
Fixes bug 2922.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5642072
2012-02-09 14:12:55 +11:00
Russ Cox
00134fe8ef fmt: diagnose invalid verb applied to pointer
Fixes #2851.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5644048
2012-02-07 23:37:05 -05:00
Rémy Oudompheng
842c906e2e runtime: delete UpdateMemStats, replace with ReadMemStats(&stats).
Unexports runtime.MemStats and rename MemStatsType to MemStats.
The new accessor requires passing a pointer to a user-allocated
MemStats structure.

Fixes #2572.

R=bradfitz, rsc, bradfitz, gustavo
CC=golang-dev, remy
https://golang.org/cl/5616072
2012-02-06 19:16:26 +01:00
Russ Cox
d7c04517a0 fmt: fix caching bug in Scan
Black box test is too time-consuming, as the bug
does not appear until Scan has processed 2 GB of
input in total across multiple calls, so no test.

Thanks to Frederick Mayle for the diagnosis and fix.

Fixes #2809.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5611043
2012-01-31 18:38:33 -05:00
Russ Cox
2050a9e478 build: remove Make.pkg, Make.tool
Consequently, remove many package Makefiles,
and shorten the few that remain.

gomake becomes 'go tool make'.

Turn off test phases of run.bash that do not work,
flagged with $BROKEN.  Future CLs will restore these,
but this seemed like a big enough CL already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
2012-01-30 23:43:46 -05:00
Russ Cox
e451fb8ffb fmt: add test of NaN map keys
R=r
CC=golang-dev
https://golang.org/cl/5564063
2012-01-30 13:20:38 -05:00
Rob Pike
b7ec659b54 fmt: fix Malloc test
We need to avoid allocating an extra word for the interface value
passing the floating-point value as an interface{}. It's easy.

Fixes #2722.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5553044
2012-01-17 15:42:02 -08:00
Rob Pike
45d739748e fmt: enable and fix malloc test
On 32-bit machines, %g takes an extra malloc. I don't know why yet,
but this makes the test pass again, and enables it even for -short.

Fixes #2653.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/5542055
2012-01-17 10:45:36 -08:00
Shenghou Ma
4cfa9e3c61 doc: fix comments referring to removed API funcs
The strconv package has removed Atob, AtoF{64,32} and Ftoa.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5540057
2012-01-14 10:59:45 -08:00
Robert Hencke
a3baccefd6 various: fix prints
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5516049
2012-01-05 18:38:01 -08:00
Rob Pike
07db252222 fmt: make the malloc test check its counts
Discover than %g is now down to 1 malloc from 2 from 4.
Have fun with funcs.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5504077
2011-12-22 15:16:06 -08:00
Rob Pike
04faa08c07 fmt: speed up floating point print, clean up some code
%g down to two mallocs from four. Also a mild speedup.

fmt_test.BenchmarkSprintfFloat         3016         2703  -10.38%

Fixes #2557.

R=rsc
CC=golang-dev
https://golang.org/cl/5491054
2011-12-15 12:52:29 -08:00
Rob Pike
24e9683ae6 fmt: don't recur if String method (etc.) misbehaves
Fixes #2555.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/5486076
2011-12-14 16:37:54 -08:00
Rob Pike
38df0459ae strconv: make QuoteRune etc. take a rune argument
Just an oversight it didn't already.
Fixes #2515.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5483064
2011-12-13 11:13:23 -08:00
Russ Cox
a250f37cbc update tree for new default type rule
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5448091
2011-12-08 22:08:03 -05:00
Rob Pike
66410bac3d fmt: benchmark floating point.
mallocs per Sprintf("%x"): 1
mallocs per Sprintf("%g"): 4

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5449106
2011-12-06 08:40:16 -08:00
Rob Pike
0a5508c692 various: we don't cast, we convert
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5437142
2011-12-05 19:40:52 -08:00
Rob Pike
2ed57a8cd8 fmt: only use Stringer or Error for strings
This is a slight change to fmt's semantics, but means that if you use
%d to print an integer with a Stringable value, it will print as an integer.
This came up because Time.Month() couldn't cleanly print as an integer
rather than a name. Using %d on Stringables is silly anyway, so there
should be no effect outside the fmt tests.
As a mild bonus, certain recursive failures of String methods
will also be avoided this way.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5453053
2011-12-05 16:45:51 -08:00
Russ Cox
2666b815a3 use new strconv API
All but 3 cases (in gcimporter.go and hixie.go)
are automatic conversions using gofix.

No attempt is made to use the new Append functions
even though there are definitely opportunities.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5447069
2011-12-05 15:48:46 -05:00
Russ Cox
434a6c85cb gc: use gofmt spacing when printing map type
R=ken2
CC=golang-dev
https://golang.org/cl/5450071
2011-12-02 14:45:07 -05:00
Rémy Oudompheng
8362ee99b0 fmt: don't check for nil when printing arrays as Go syntax.
Also add array values to printing test suite.
Fixes #2468.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/5436053
2011-11-23 09:04:02 -08:00
Russ Cox
a7f1e10d24 fmt: distinguish empty vs nil slice/map in %#v
Also update Scanf tests to cope with DeepEqual
distinguishing empty vs nil slice.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5375091
2011-11-14 16:10:58 -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
Vincent Vanackere
eb1717e035 all: rename os.EOF to io.EOF in various non-code contexts
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5334050
2011-11-03 14:01:30 -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
Luuk van Dijk
50110c9f83 gc: clean up printing.
Got rid of all the magic mystery globals. Now
for %N, %T, and %S, the flags +,- and # set a sticky
debug, sym and export mode, only visible in the new fmt.c.
Default is error mode. Handle h and l flags consistently with
the least side effects, so we can now change
things without worrying about unrelated things
breaking.

fixes #2361

R=rsc
CC=golang-dev
https://golang.org/cl/5316043
2011-10-31 18:09:40 +01:00
Russ Cox
0e81e508be fmt: handle os.Error values
Handling os.Error is no different than handling fmt.Stringer
here, so the code is redundant now, but it will be necessary
once error goes in.

Adding it now will make gofix fix it.

R=r
CC=golang-dev
https://golang.org/cl/5331045
2011-10-27 21:20:44 -07:00
Russ Cox
4e4eca2618 fmt: use rune
Lots of internal edits.

Formatter and Scanner interfaces change
(clients to be checked by govet).

R=r
CC=golang-dev
https://golang.org/cl/5305045
2011-10-25 22:21:33 -07:00