summaryrefslogtreecommitdiff
path: root/src/pkg/fmt/print.go
AgeCommit message (Collapse)AuthorFilesLines
2011-02-14Imported Upstream version 2011-02-01.1upstream/2011-02-01.1Ondřej Surý1-22/+35
2011-01-17Imported Upstream version 2011.01.12upstream/2011.01.12Ondřej Surý1-222/+162
2010-06-28fmt.Printf: fix bug in handling of %#v.Rob Pike1-45/+53
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-21reflect: add Type.Bits method, add tags to prohibit conversionsRuss Cox1-4/+4
gob: substitute slice for map R=r CC=golang-dev http://codereview.appspot.com/1699045
2010-06-20reflect: add Kind, remove Int8Type, Int8Value, etc.Russ Cox1-32/+9
update other code to match. R=r CC=golang-dev http://codereview.appspot.com/1680044
2010-06-14fmt.Printf: write tests for %T.Rob Pike1-1/+1
Fix a bug that caused it to ignore field widths. R=rsc CC=golang-dev http://codereview.appspot.com/1704041
2010-06-14fmt.Print*: reimplement to switch on type first.Rob Pike1-496/+379
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-06-03fmt.Scan: field widthsRob Pike1-8/+11
Also fix an interface bug: white-space-delimited doesn't work well for cases like "%d, %d" on "23, 23") R=rsc CC=golang-dev http://codereview.appspot.com/1502041
2010-06-02fmt.Scan: scan []byte argumentsRob Pike1-1/+0
R=rsc CC=golang-dev http://codereview.appspot.com/1486041
2010-06-02fmt.Scanf: implement formats, provide Sscanf (strings)Rob Pike1-6/+33
- provide convenience functions for scanning strings - enable Scanf etc. - update doc comments R=rsc CC=golang-dev http://codereview.appspot.com/1451044
2010-05-31fmt: fix end-of-array error in parsenum.Rob Pike1-8/+4
Fixes issue 821. R=rsc CC=golang-dev http://codereview.appspot.com/1434041
2010-05-28fmt.Scan: add Fscan and Fscanln and make Scan and ScanlnRob Pike1-1/+17
read from standard input. Add description of scanning to the package comment. R=rsc CC=golang-dev http://codereview.appspot.com/1390041
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-05-21go/printer, gofmt: fix printing of labels,Robert Griesemer1-1/+2
apply gofmt to src, misc Fixes issue 752. R=rsc CC=golang-dev http://codereview.appspot.com/1240044 Committer: Robert Griesemer <gri@golang.org>
2010-05-13Prevent Printf crashing when giving an extra nil argument.Roger Peppe1-2/+4
R=rsc, r CC=golang-dev http://codereview.appspot.com/1195041 Committer: Rob Pike <r@golang.org>
2010-04-28fmt: %T print <nil> for nilChristopher Wedgwood1-0/+4
R=r CC=golang-dev, rsc http://codereview.appspot.com/1014043 Committer: Rob Pike <r@golang.org>
2010-04-12fmt format verb %b bugAndrei Vieru1-2/+6
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-1/+0
add tests. R=rsc, ken2, ken3 CC=golang-dev http://codereview.appspot.com/261041
2010-03-06PTALKen Thompson1-65/+26
R=r CC=golang-dev http://codereview.appspot.com/254043
2010-03-056g complex type usableKen Thompson1-0/+120
8g and 5g have stubs to ignore complex R=rsc CC=golang-dev http://codereview.appspot.com/257042
2010-02-28Count utf8 runes, not bytes when determining string width. NoteStephen Ma1-1/+3
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>
2010-02-25use []byte("abc") in place of []byte{'a', 'b', 'c'}Russ Cox1-9/+9
R=gri CC=golang-dev http://codereview.appspot.com/223059
2010-02-25%q in fmt: if the object is a Stringer, use String() to get the value to quote.Rob Pike1-0/+7
R=rsc CC=golang-dev http://codereview.appspot.com/224051
2010-02-15Fix printing of named floating point types.Ian Lance Taylor1-4/+4
Try to avoid infinite recursion if String fails due to printing a bad type. Add test for String method with named basic types. R=r CC=golang-dev http://codereview.appspot.com/207102
2010-02-05handle nils safely in Printf.Rob Pike1-2/+7
add some tests for erroneous formats. R=rsc CC=golang-dev http://codereview.appspot.com/201058
2010-02-02Change type of Printf's args to ... interface{}Rob Pike1-96/+205
R=rsc CC=golang-dev http://codereview.appspot.com/197043
2009-12-23fix up %pRob Pike1-4/+7
- use an interface {Get()} - implement Get for maps, slices - for slices, retrieves the address of the end of the array, which will give the same value for every slice of the same array. R=rsc CC=golang-dev http://codereview.appspot.com/179129
2009-12-22Allow %p on reference types, for debugging.Rob Pike1-17/+9
(Also fix case sensitivity in test for PTR inside fmt_test.go) Fixes issue 441. R=rsc, iant CC=golang-dev http://codereview.appspot.com/180112
2009-12-15 1) Change default gofmt default settings forRobert Griesemer1-205/+205
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-5/+13
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-47/+47
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-163/+167
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-11-20gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkgRuss Cox1-2/+2
R=r, gri CC=golang-dev http://codereview.appspot.com/156115
2009-11-09 - replaced gofmt expression formatting algorithm withRobert Griesemer1-10/+10
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-110/+110
R=rsc, r http://go/go-review/1025029
2009-11-06- fine-tuning of one-line func heuristic (nodes.go)Robert Griesemer1-6/+2
- 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-11-05gofmt-ify template, time, unsafe, flag, fmtRobert Griesemer1-2/+2
(replacement for CLs 1017039, 1017041, 1017040, 1018054) R=r http://go/go-review/1018060
2009-10-08more lgtm files from gofmtRuss Cox1-1/+1
R=gri OCL=35485 CL=35488
2009-10-06apply gofmt to datafmt, ebnf, exec, expvar, flag, fmtRuss Cox1-70/+70
R=gri DELTA=456 (6 added, 3 deleted, 447 changed) OCL=35398 CL=35406
2009-09-15more "declared and not used".Russ Cox1-2/+2
the last round omitted := range and only checked 1 out of N vars in a multi-var := R=r OCL=34624 CL=34638
2009-09-10fix indentationRuss Cox1-146/+146
R=r DELTA=166 (0 added, 0 deleted, 166 changed) OCL=34521 CL=34527
2009-08-31fmt: add verbs:Russ Cox1-58/+186
%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-08-28print the value using (in effect) %v when Printf is given mismatched args ↵Rob Pike1-2/+8
for its format Printf("%s", 2) gives %s(int=2) R=rsc DELTA=12 (10 added, 0 deleted, 2 changed) OCL=34042 CL=34044
2009-08-12convert low-level (used by testing) packages toRuss Cox1-4/+0
whole-package compilation. new Makefiles, tests now in separate package bytes flag fmt io math once os reflect strconv sync time utf8 delete import "xxx" in package xxx. inside package xxx, xxx is not declared anymore so s/xxx.//g delete file and package level forward declarations. note the new internal_test.go and sync and strconv to provide public access to internals during testing. the installed version of the package omits that file and thus does not open the internals to all clients. R=r OCL=33065 CL=33097
2009-08-10remove unnecessary pkg. referencesRuss Cox1-1/+1
R=r DELTA=95 (0 added, 0 deleted, 95 changed) OCL=33012 CL=33012
2009-07-31make %v and %p consistentRob Pike1-1/+1
R=rsc DELTA=1 (0 added, 0 deleted, 1 changed) OCL=32591 CL=32593
2009-07-30fix a long-standing typoRob Pike1-2/+2
R=rsc DELTA=2 (0 added, 0 deleted, 2 changed) OCL=32540 CL=32545
2009-07-10reflection for interface setRuss Cox1-1/+1
rename map access methods to Elem, SetElem. R=r DELTA=95 (66 added, 7 deleted, 22 changed) OCL=31456 CL=31469
2009-07-09printing mapsRob Pike1-1/+13
R=rsc DELTA=57 (39 added, 3 deleted, 15 changed) OCL=31424 CL=31430
2009-07-07fmt: use new reflect interface (CL 31107)Russ Cox1-158/+132
R=r DELTA=208 (37 added, 63 deleted, 108 changed) OCL=31111 CL=31281