summaryrefslogtreecommitdiff
path: root/src/pkg/fmt/format.go
AgeCommit message (Collapse)AuthorFilesLines
2012-04-06Imported Upstream version 1upstream/1Ondřej Surý1-55/+57
2011-09-13Imported Upstream version 60upstream/60Ondřej Surý1-0/+452
2011-09-13Imported Upstream version 60Ondřej Surý1-447/+0
2011-08-03Imported Upstream version 59upstream/59Ondřej Surý1-2/+32
2011-06-30Imported Upstream version 58upstream/58Ondřej Surý1-0/+7
2011-04-26Imported Upstream version 2011.04.13upstream/2011.04.13Ondřej Surý1-5/+17
2011-04-20Imported Upstream version 2011.03.07.1upstream/2011.03.07.1Ondřej Surý1-2/+2
2011-02-14Imported Upstream version 2011-02-01.1upstream/2011-02-01.1Ondřej Surý1-33/+0
2011-01-17Imported Upstream version 2011.01.12upstream/2011.01.12Ondřej Surý1-0/+11
2010-06-28fmt.Printf: fix bug in handling of %#v.Rob Pike1-18/+7
nice side effect: slices now obey their format verb. example: fmt.Printf("%q\n", []string{"a"}) R=rsc CC=golang-dev http://codereview.appspot.com/1729045
2010-06-14fmt.Print*: reimplement to switch on type first.Rob Pike1-89/+6
This shortens, simplifies and regularizes the code significantly. (Improvements to reflect could make another step.) Passes all.bash. One semantic change occurs: The String() method changes behavior. It used to run only for string formats such as %s and %q. Instead, it now runs whenever the item has the method and the result is then processed by the format as a string. Besides the regularization, this has three effects: 1) width is honored for String() items 2) %x works for String() items 3) implementations of String that merely recur will recur forever Regarding point 3, example from the updated documentation: type X int func (x X) String() string { return Sprintf("%d", x) } should cast the value before recurring: func (x X) String() string { return Sprintf("%d", int(x)) } R=rsc CC=golang-dev http://codereview.appspot.com/1613045
2010-05-27changes &x -> x[0:] for array to slice conversionRuss Cox1-1/+1
R=gri CC=golang-dev http://codereview.appspot.com/1326042
2010-04-12fmt format verb %b bugAndrei Vieru1-7/+4
fmt.Printf("%b", int8(-1)) prints 64 ones instead of 8. This happens only for signed integers (int8, in16 and int32). I guess it's because of the way the conversion between integer types works. From go spec: "Conversions between integer types. If the value is a signed quantity, it is sign extended to implicit infinite precision ....". And there are several conversions to int64 and uint64 in the fmt package. This pathch solves only half of the problem. On a 32 bit system, an fmt.Printf("%b", int(-1)) should still print 64 ones. R=golang-dev, r CC=golang-dev http://codereview.appspot.com/891049 Committer: Rob Pike <r@golang.org>
2010-03-06fix bug in complex printing: imaginary didn't have same format as real.Rob Pike1-9/+18
add tests. R=rsc, ken2, ken3 CC=golang-dev http://codereview.appspot.com/261041
2010-03-06PTALKen Thompson1-0/+54
R=r CC=golang-dev http://codereview.appspot.com/254043
2010-02-28Count utf8 runes, not bytes when determining string width. NoteStephen Ma1-1/+2
that pad() still counts bytes, but it's currently only used for 1 byte runes. Fixes issue 612. R=r CC=golang-dev http://codereview.appspot.com/217064 Committer: Rob Pike <r@golang.org>
2009-12-15 1) Change default gofmt default settings forRobert Griesemer1-138/+138
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067
2009-12-06save a few ns by inlining (which mostly simplifies things anyway).Rob Pike1-109/+87
a couple of cleanups. don't keep big buffers in the free list. R=rsc CC=golang-dev http://codereview.appspot.com/166078
2009-12-06unexport Fmt. it's not needed outside this package any moreRob Pike1-158/+132
cleans up godoc's output for package fmt substantially. R=rsc CC=golang-dev http://codereview.appspot.com/165070
2009-12-06Make printing faster by avoiding mallocs and some other advances.Rob Pike1-214/+184
Roughly 33% faster for simple cases, probably more for complex ones. Before: mallocs per Sprintf(""): 4 mallocs per Sprintf("xxx"): 6 mallocs per Sprintf("%x"): 10 mallocs per Sprintf("%x %x"): 12 Now: mallocs per Sprintf(""): 2 mallocs per Sprintf("xxx"): 3 mallocs per Sprintf("%x"): 5 mallocs per Sprintf("%x %x"): 7 Speed improves because of avoiding mallocs and also by sharing a bytes.Buffer between print.go and format.go rather than copying the data back after each printed item. Before: fmt_test.BenchmarkSprintfEmpty 1000000 1346 ns/op fmt_test.BenchmarkSprintfString 500000 3461 ns/op fmt_test.BenchmarkSprintfInt 500000 3671 ns/op Now: fmt_test.BenchmarkSprintfEmpty 2000000 995 ns/op fmt_test.BenchmarkSprintfString 1000000 2745 ns/op fmt_test.BenchmarkSprintfInt 1000000 2391 ns/op fmt_test.BenchmarkSprintfIntInt 500000 3751 ns/op I believe there is more to get but this is a good milestone. R=rsc CC=golang-dev, hong http://codereview.appspot.com/166076
2009-12-03minor improvement to formatting: don't allocate padding strings every time.Rob Pike1-12/+19
R=rsc http://codereview.appspot.com/164090
2009-11-20add unimplemented %+ and % (space) flags to floating-point print.Rob Pike1-11/+23
fix %E: was same as %e. add tests. Fixes issue 278. R=rsc CC=golang-dev http://codereview.appspot.com/157111
2009-11-09 - replaced gofmt expression formatting algorithm withRobert Griesemer1-7/+7
rsc's algorithm - applied gofmt -w misc src - partial CL (remaining files in other CLs) R=rsc, r http://go/go-review/1026036
2009-11-09remove semis after statements in one-statement statement listsRobert Griesemer1-28/+28
R=rsc, r http://go/go-review/1025029
2009-11-06- fine-tuning of one-line func heuristic (nodes.go)Robert Griesemer1-63/+21
- enabled for function declarations (not just function literals) - applied gofmt -w $GOROOT/src (look for instance at src/pkg/debug/elf/elf.go) R=r, rsc CC=go-dev http://go/go-review/1026006
2009-10-06apply gofmt to datafmt, ebnf, exec, expvar, flag, fmtRuss Cox1-29/+29
R=gri DELTA=456 (6 added, 3 deleted, 447 changed) OCL=35398 CL=35406
2009-08-31fmt: add verbs:Russ Cox1-0/+20
%E - upper case %e %G - upper case %g %#v - Go syntax R=r DELTA=332 (238 added, 47 deleted, 47 changed) OCL=34091 CL=34145
2009-06-22changes required if we disallow the implicit *Russ Cox1-12/+13
in cap, len, [], and range on maps, strings, and slices. R=r DELTA=57 (2 added, 12 deleted, 43 changed) OCL=30549 CL=30590
2009-06-09mv src/lib to src/pkgRob Pike1-0/+533
tests: all.bash passes, gobuild still works, godoc still works. R=rsc OCL=30096 CL=30102