]> Cypherpunks repositories - gostls13.git/commit
fmt: handle negative width/prec when supplied as an argument
authorTodd Neal <todd@tneal.org>
Wed, 24 Jun 2015 12:48:35 +0000 (07:48 -0500)
committerRob Pike <r@golang.org>
Thu, 25 Jun 2015 05:34:02 +0000 (05:34 +0000)
commit4e834cff4f7d4f736600d36d209ea6f388a44c44
tree77742420b4df46a1ff842c45cb6d47761d164ab5
parent2bcdb5a5d9220f919413ce90ec92ba4ba9167fb7
fmt: handle negative width/prec when supplied as an argument

Negative width arguments now left align the way a minus-width in the
format string aligns. The minus in the format string overrides the sign
of the argument as in C.

Precision behavior is modified to include an error if the argument is
negative.  This differs from a negative precision in a format string
which just terminates the format.

Additional checks for large magnitude widths and precisions are added to
make the runtime behavior (failure, but with different error messages),
more consistent between format string specified width/precision and
argument specified width/precision.

Fixes #11376

Change-Id: I8c7ed21088e9c18128a45d4c487c5ab9fafd13ef
Reviewed-on: https://go-review.googlesource.com/11405
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
src/fmt/fmt_test.go
src/fmt/print.go