Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2311)

Issue 4717045: fmt: handle precision 0 format stings in standard way

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by mtj
Modified:
12 years, 9 months ago
Reviewers:
r, mtj1
CC:
r2, r, golang-dev
Visibility:
Public.

Description

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.

Patch Set 1 #

Patch Set 2 : diff -r 7f39a0541e03 https://go.googlecode.com/hg/ #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -0 lines) Patch
M src/pkg/fmt/fmt_test.go View 1 1 chunk +2 lines, -0 lines 1 comment Download
M src/pkg/fmt/format.go View 1 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/fmt/print.go View 1 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 4
r
http://codereview.appspot.com/4717045/diff/2001/src/pkg/fmt/fmt_test.go File src/pkg/fmt/fmt_test.go (right): http://codereview.appspot.com/4717045/diff/2001/src/pkg/fmt/fmt_test.go#newcode185 src/pkg/fmt/fmt_test.go:185: {"%.d", 0, ""}, shouldn't there be non-zero test cases, ...
12 years, 9 months ago (2011-07-21 06:45:15 UTC) #1
r
apologies, never mind. i'm a CL behind. LGTM
12 years, 9 months ago (2011-07-21 06:46:00 UTC) #2
r
*** Submitted as http://code.google.com/p/go/source/detail?r=8f4c6113ed2d *** fmt: handle precision 0 format stings in standard way The ...
12 years, 9 months ago (2011-07-21 06:47:06 UTC) #3
mtj1
12 years, 9 months ago (2011-07-21 06:51:01 UTC) #4
Great, thanks. One less dangling change in my tree!

Michael T. Jones | Chief Technology Advocate  | mtj@google.com |  +1
650-335-5765



On Wed, Jul 20, 2011 at 11:47 PM, <r@golang.org> wrote:

> *** Submitted as
>
http://code.google.com/p/go/**source/detail?r=8f4c6113ed2d<http://code.google...
>
> 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
>
> http://codereview.appspot.com/**4717045<http://codereview.appspot.com/4717045>
>
> Committer: Rob Pike <r@golang.org>
>
>
>
>
http://codereview.appspot.com/**4717045/<http://codereview.appspot.com/4717045/>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b