Commit e109a2bb authored by Robert Griesemer's avatar Robert Griesemer

big: minor comment adjustments

R=mtj, r
CC=golang-dev
https://golang.org/cl/4814044
parent 12c73615
...@@ -329,9 +329,9 @@ func writeMultiple(s fmt.State, text string, count int) { ...@@ -329,9 +329,9 @@ func writeMultiple(s fmt.State, text string, count int) {
// Format is a support routine for fmt.Formatter. It accepts // Format is a support routine for fmt.Formatter. It accepts
// the formats 'b' (binary), 'o' (octal), 'd' (decimal), 'x' // the formats 'b' (binary), 'o' (octal), 'd' (decimal), 'x'
// (lowercase hexadecimal), and 'X' (uppercase hexadecimal). // (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
// Also supported are the full suite of "Printf" style format // Also supported are the full suite of package fmt's format
// codes for integral types, including PLUS, MINUS, and SPACE // verbs for integral types, including '+', '-', and ' '
// for sign control, HASH for leading ZERO in octal and for // for sign control, '#' for leading zero in octal and for
// hexadecimal, a leading "0x" or "0X" for "%#x" and "%#X" // hexadecimal, a leading "0x" or "0X" for "%#x" and "%#X"
// respectively, specification of minimum digits precision, // respectively, specification of minimum digits precision,
// output field width, space or zero padding, and left or // output field width, space or zero padding, and left or
...@@ -378,9 +378,9 @@ func (x *Int) Format(s fmt.State, ch int) { ...@@ -378,9 +378,9 @@ func (x *Int) Format(s fmt.State, ch int) {
// determine digits with base set by len(cs) and digit characters from cs // determine digits with base set by len(cs) and digit characters from cs
digits := x.abs.string(cs) digits := x.abs.string(cs)
// number of characters for the Sprintf family's three classes of number padding // number of characters for the three classes of number padding
var left int // space characters to left of digits for right justification ("%8d") var left int // space characters to left of digits for right justification ("%8d")
var zeroes int // zero characters (acutally cs[0]) as left-most digits ("%.8d") var zeroes int // zero characters (actually cs[0]) as left-most digits ("%.8d")
var right int // space characters to right of digits for left justification ("%-8d") var right int // space characters to right of digits for left justification ("%-8d")
// determine number padding from precision: the least number of digits to output // determine number padding from precision: the least number of digits to output
...@@ -398,16 +398,19 @@ func (x *Int) Format(s fmt.State, ch int) { ...@@ -398,16 +398,19 @@ func (x *Int) Format(s fmt.State, ch int) {
length := len(sign) + len(prefix) + zeroes + len(digits) length := len(sign) + len(prefix) + zeroes + len(digits)
if width, widthSet := s.Width(); widthSet && length < width { // pad as specified if width, widthSet := s.Width(); widthSet && length < width { // pad as specified
switch d := width - length; { switch d := width - length; {
case s.Flag('-'): // pad on the right with spaces. supersedes '0' when both specified case s.Flag('-'):
// pad on the right with spaces; supersedes '0' when both specified
right = d right = d
case s.Flag('0') && !precisionSet: // pad with zeroes unless precision also specified case s.Flag('0') && !precisionSet:
// pad with zeroes unless precision also specified
zeroes = d zeroes = d
default: // pad on the left with spaces default:
// pad on the left with spaces
left = d left = d
} }
} }
// print Int as [left pad][sign][prefix][zero pad][digits][right pad] // print number as [left pad][sign][prefix][zero pad][digits][right pad]
writeMultiple(s, " ", left) writeMultiple(s, " ", left)
writeMultiple(s, sign, 1) writeMultiple(s, sign, 1)
writeMultiple(s, prefix, 1) writeMultiple(s, prefix, 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment