]> Cypherpunks repositories - gostls13.git/commit
fmt: handle precision 0 format stings in standard way
authorMichael T. Jones <mtj@google.com>
Thu, 21 Jul 2011 06:46:51 +0000 (16:46 +1000)
committerRob Pike <r@golang.org>
Thu, 21 Jul 2011 06:46:51 +0000 (16:46 +1000)
commit8cdee891d70c9e66dd22dffa1aa804721f07aacf
treebbb9314ebf73cabfc116a6e8fea5b364f3344550
parent0f7a1951b82b80dcf1b8398e8ead03ed158e029e
fmt: handle precision 0 format stings in standard way

The C-stdlib heritage of printf/fprintf/sprintf has two odd
aspects for precisions of zero with integers. First, the zero
can be specified in any of these ways, "%4.0d", "%.0d" and
"%.d" which was not previously supported here. Secondly, the
seemingly universal interpretation of precision for integers
is that precision==0 and value==0 means print nothing at all.
The code here now handles this for integers just as the code
in big/int.c does the same for the Int type. New tests are
added to fmt_test.go to verify these changes.

R=r, r
CC=golang-dev
https://golang.org/cl/4717045
src/pkg/fmt/fmt_test.go
src/pkg/fmt/format.go
src/pkg/fmt/print.go