Commit ccaa2bc5 authored by Darshan Parajuli's avatar Darshan Parajuli Committed by Brad Fitzpatrick

fmt: change some unexported method names to camel case

Change-Id: I12f96a9397cfaebe11e616543d804bd62cd72da0
Reviewed-on: https://go-review.googlesource.com/97379Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 15b0d137
...@@ -122,8 +122,8 @@ func (f *fmt) padString(s string) { ...@@ -122,8 +122,8 @@ func (f *fmt) padString(s string) {
} }
} }
// fmt_boolean formats a boolean. // fmtBoolean formats a boolean.
func (f *fmt) fmt_boolean(v bool) { func (f *fmt) fmtBoolean(v bool) {
if v { if v {
f.padString("true") f.padString("true")
} else { } else {
...@@ -131,8 +131,8 @@ func (f *fmt) fmt_boolean(v bool) { ...@@ -131,8 +131,8 @@ func (f *fmt) fmt_boolean(v bool) {
} }
} }
// fmt_unicode formats a uint64 as "U+0078" or with f.sharp set as "U+0078 'x'". // fmtUnicode formats a uint64 as "U+0078" or with f.sharp set as "U+0078 'x'".
func (f *fmt) fmt_unicode(u uint64) { func (f *fmt) fmtUnicode(u uint64) {
buf := f.intbuf[0:] buf := f.intbuf[0:]
// With default precision set the maximum needed buf length is 18 // With default precision set the maximum needed buf length is 18
...@@ -190,8 +190,8 @@ func (f *fmt) fmt_unicode(u uint64) { ...@@ -190,8 +190,8 @@ func (f *fmt) fmt_unicode(u uint64) {
f.zero = oldZero f.zero = oldZero
} }
// fmt_integer formats signed and unsigned integers. // fmtInteger formats signed and unsigned integers.
func (f *fmt) fmt_integer(u uint64, base int, isSigned bool, digits string) { func (f *fmt) fmtInteger(u uint64, base int, isSigned bool, digits string) {
negative := isSigned && int64(u) < 0 negative := isSigned && int64(u) < 0
if negative { if negative {
u = -u u = -u
...@@ -322,14 +322,14 @@ func (f *fmt) truncate(s string) string { ...@@ -322,14 +322,14 @@ func (f *fmt) truncate(s string) string {
return s return s
} }
// fmt_s formats a string. // fmtS formats a string.
func (f *fmt) fmt_s(s string) { func (f *fmt) fmtS(s string) {
s = f.truncate(s) s = f.truncate(s)
f.padString(s) f.padString(s)
} }
// fmt_sbx formats a string or byte slice as a hexadecimal encoding of its bytes. // fmtSbx formats a string or byte slice as a hexadecimal encoding of its bytes.
func (f *fmt) fmt_sbx(s string, b []byte, digits string) { func (f *fmt) fmtSbx(s string, b []byte, digits string) {
length := len(b) length := len(b)
if b == nil { if b == nil {
// No byte slice present. Assume string s should be encoded. // No byte slice present. Assume string s should be encoded.
...@@ -394,20 +394,20 @@ func (f *fmt) fmt_sbx(s string, b []byte, digits string) { ...@@ -394,20 +394,20 @@ func (f *fmt) fmt_sbx(s string, b []byte, digits string) {
} }
} }
// fmt_sx formats a string as a hexadecimal encoding of its bytes. // fmtSx formats a string as a hexadecimal encoding of its bytes.
func (f *fmt) fmt_sx(s, digits string) { func (f *fmt) fmtSx(s, digits string) {
f.fmt_sbx(s, nil, digits) f.fmtSbx(s, nil, digits)
} }
// fmt_bx formats a byte slice as a hexadecimal encoding of its bytes. // fmtBx formats a byte slice as a hexadecimal encoding of its bytes.
func (f *fmt) fmt_bx(b []byte, digits string) { func (f *fmt) fmtBx(b []byte, digits string) {
f.fmt_sbx("", b, digits) f.fmtSbx("", b, digits)
} }
// fmt_q formats a string as a double-quoted, escaped Go string constant. // fmtQ formats a string as a double-quoted, escaped Go string constant.
// If f.sharp is set a raw (backquoted) string may be returned instead // If f.sharp is set a raw (backquoted) string may be returned instead
// if the string does not contain any control characters other than tab. // if the string does not contain any control characters other than tab.
func (f *fmt) fmt_q(s string) { func (f *fmt) fmtQ(s string) {
s = f.truncate(s) s = f.truncate(s)
if f.sharp && strconv.CanBackquote(s) { if f.sharp && strconv.CanBackquote(s) {
f.padString("`" + s + "`") f.padString("`" + s + "`")
...@@ -421,9 +421,9 @@ func (f *fmt) fmt_q(s string) { ...@@ -421,9 +421,9 @@ func (f *fmt) fmt_q(s string) {
} }
} }
// fmt_c formats an integer as a Unicode character. // fmtC formats an integer as a Unicode character.
// If the character is not valid Unicode, it will print '\ufffd'. // If the character is not valid Unicode, it will print '\ufffd'.
func (f *fmt) fmt_c(c uint64) { func (f *fmt) fmtC(c uint64) {
r := rune(c) r := rune(c)
if c > utf8.MaxRune { if c > utf8.MaxRune {
r = utf8.RuneError r = utf8.RuneError
...@@ -433,9 +433,9 @@ func (f *fmt) fmt_c(c uint64) { ...@@ -433,9 +433,9 @@ func (f *fmt) fmt_c(c uint64) {
f.pad(buf[:w]) f.pad(buf[:w])
} }
// fmt_qc formats an integer as a single-quoted, escaped Go character constant. // fmtQc formats an integer as a single-quoted, escaped Go character constant.
// If the character is not valid Unicode, it will print '\ufffd'. // If the character is not valid Unicode, it will print '\ufffd'.
func (f *fmt) fmt_qc(c uint64) { func (f *fmt) fmtQc(c uint64) {
r := rune(c) r := rune(c)
if c > utf8.MaxRune { if c > utf8.MaxRune {
r = utf8.RuneError r = utf8.RuneError
...@@ -448,9 +448,9 @@ func (f *fmt) fmt_qc(c uint64) { ...@@ -448,9 +448,9 @@ func (f *fmt) fmt_qc(c uint64) {
} }
} }
// fmt_float formats a float64. It assumes that verb is a valid format specifier // fmtFloat formats a float64. It assumes that verb is a valid format specifier
// for strconv.AppendFloat and therefore fits into a byte. // for strconv.AppendFloat and therefore fits into a byte.
func (f *fmt) fmt_float(v float64, size int, verb rune, prec int) { func (f *fmt) fmtFloat(v float64, size int, verb rune, prec int) {
// Explicit precision in format specifier overrules default precision. // Explicit precision in format specifier overrules default precision.
if f.precPresent { if f.precPresent {
prec = f.prec prec = f.prec
......
...@@ -341,7 +341,7 @@ func (p *pp) badVerb(verb rune) { ...@@ -341,7 +341,7 @@ func (p *pp) badVerb(verb rune) {
func (p *pp) fmtBool(v bool, verb rune) { func (p *pp) fmtBool(v bool, verb rune) {
switch verb { switch verb {
case 't', 'v': case 't', 'v':
p.fmt.fmt_boolean(v) p.fmt.fmtBoolean(v)
default: default:
p.badVerb(verb) p.badVerb(verb)
} }
...@@ -352,7 +352,7 @@ func (p *pp) fmtBool(v bool, verb rune) { ...@@ -352,7 +352,7 @@ func (p *pp) fmtBool(v bool, verb rune) {
func (p *pp) fmt0x64(v uint64, leading0x bool) { func (p *pp) fmt0x64(v uint64, leading0x bool) {
sharp := p.fmt.sharp sharp := p.fmt.sharp
p.fmt.sharp = leading0x p.fmt.sharp = leading0x
p.fmt.fmt_integer(v, 16, unsigned, ldigits) p.fmt.fmtInteger(v, 16, unsigned, ldigits)
p.fmt.sharp = sharp p.fmt.sharp = sharp
} }
...@@ -363,28 +363,28 @@ func (p *pp) fmtInteger(v uint64, isSigned bool, verb rune) { ...@@ -363,28 +363,28 @@ func (p *pp) fmtInteger(v uint64, isSigned bool, verb rune) {
if p.fmt.sharpV && !isSigned { if p.fmt.sharpV && !isSigned {
p.fmt0x64(v, true) p.fmt0x64(v, true)
} else { } else {
p.fmt.fmt_integer(v, 10, isSigned, ldigits) p.fmt.fmtInteger(v, 10, isSigned, ldigits)
} }
case 'd': case 'd':
p.fmt.fmt_integer(v, 10, isSigned, ldigits) p.fmt.fmtInteger(v, 10, isSigned, ldigits)
case 'b': case 'b':
p.fmt.fmt_integer(v, 2, isSigned, ldigits) p.fmt.fmtInteger(v, 2, isSigned, ldigits)
case 'o': case 'o':
p.fmt.fmt_integer(v, 8, isSigned, ldigits) p.fmt.fmtInteger(v, 8, isSigned, ldigits)
case 'x': case 'x':
p.fmt.fmt_integer(v, 16, isSigned, ldigits) p.fmt.fmtInteger(v, 16, isSigned, ldigits)
case 'X': case 'X':
p.fmt.fmt_integer(v, 16, isSigned, udigits) p.fmt.fmtInteger(v, 16, isSigned, udigits)
case 'c': case 'c':
p.fmt.fmt_c(v) p.fmt.fmtC(v)
case 'q': case 'q':
if v <= utf8.MaxRune { if v <= utf8.MaxRune {
p.fmt.fmt_qc(v) p.fmt.fmtQc(v)
} else { } else {
p.badVerb(verb) p.badVerb(verb)
} }
case 'U': case 'U':
p.fmt.fmt_unicode(v) p.fmt.fmtUnicode(v)
default: default:
p.badVerb(verb) p.badVerb(verb)
} }
...@@ -395,13 +395,13 @@ func (p *pp) fmtInteger(v uint64, isSigned bool, verb rune) { ...@@ -395,13 +395,13 @@ func (p *pp) fmtInteger(v uint64, isSigned bool, verb rune) {
func (p *pp) fmtFloat(v float64, size int, verb rune) { func (p *pp) fmtFloat(v float64, size int, verb rune) {
switch verb { switch verb {
case 'v': case 'v':
p.fmt.fmt_float(v, size, 'g', -1) p.fmt.fmtFloat(v, size, 'g', -1)
case 'b', 'g', 'G': case 'b', 'g', 'G':
p.fmt.fmt_float(v, size, verb, -1) p.fmt.fmtFloat(v, size, verb, -1)
case 'f', 'e', 'E': case 'f', 'e', 'E':
p.fmt.fmt_float(v, size, verb, 6) p.fmt.fmtFloat(v, size, verb, 6)
case 'F': case 'F':
p.fmt.fmt_float(v, size, 'f', 6) p.fmt.fmtFloat(v, size, 'f', 6)
default: default:
p.badVerb(verb) p.badVerb(verb)
} }
...@@ -432,18 +432,18 @@ func (p *pp) fmtString(v string, verb rune) { ...@@ -432,18 +432,18 @@ func (p *pp) fmtString(v string, verb rune) {
switch verb { switch verb {
case 'v': case 'v':
if p.fmt.sharpV { if p.fmt.sharpV {
p.fmt.fmt_q(v) p.fmt.fmtQ(v)
} else { } else {
p.fmt.fmt_s(v) p.fmt.fmtS(v)
} }
case 's': case 's':
p.fmt.fmt_s(v) p.fmt.fmtS(v)
case 'x': case 'x':
p.fmt.fmt_sx(v, ldigits) p.fmt.fmtSx(v, ldigits)
case 'X': case 'X':
p.fmt.fmt_sx(v, udigits) p.fmt.fmtSx(v, udigits)
case 'q': case 'q':
p.fmt.fmt_q(v) p.fmt.fmtQ(v)
default: default:
p.badVerb(verb) p.badVerb(verb)
} }
...@@ -472,18 +472,18 @@ func (p *pp) fmtBytes(v []byte, verb rune, typeString string) { ...@@ -472,18 +472,18 @@ func (p *pp) fmtBytes(v []byte, verb rune, typeString string) {
if i > 0 { if i > 0 {
p.buf.WriteByte(' ') p.buf.WriteByte(' ')
} }
p.fmt.fmt_integer(uint64(c), 10, unsigned, ldigits) p.fmt.fmtInteger(uint64(c), 10, unsigned, ldigits)
} }
p.buf.WriteByte(']') p.buf.WriteByte(']')
} }
case 's': case 's':
p.fmt.fmt_s(string(v)) p.fmt.fmtS(string(v))
case 'x': case 'x':
p.fmt.fmt_bx(v, ldigits) p.fmt.fmtBx(v, ldigits)
case 'X': case 'X':
p.fmt.fmt_bx(v, udigits) p.fmt.fmtBx(v, udigits)
case 'q': case 'q':
p.fmt.fmt_q(string(v)) p.fmt.fmtQ(string(v))
default: default:
p.printValue(reflect.ValueOf(v), verb, 0) p.printValue(reflect.ValueOf(v), verb, 0)
} }
...@@ -577,7 +577,7 @@ func (p *pp) handleMethods(verb rune) (handled bool) { ...@@ -577,7 +577,7 @@ func (p *pp) handleMethods(verb rune) (handled bool) {
handled = true handled = true
defer p.catchPanic(p.arg, verb) defer p.catchPanic(p.arg, verb)
// Print the result of GoString unadorned. // Print the result of GoString unadorned.
p.fmt.fmt_s(stringer.GoString()) p.fmt.fmtS(stringer.GoString())
return return
} }
} else { } else {
...@@ -626,7 +626,7 @@ func (p *pp) printArg(arg interface{}, verb rune) { ...@@ -626,7 +626,7 @@ func (p *pp) printArg(arg interface{}, verb rune) {
// %T (the value's type) and %p (its address) are special; we always do them first. // %T (the value's type) and %p (its address) are special; we always do them first.
switch verb { switch verb {
case 'T': case 'T':
p.fmt.fmt_s(reflect.TypeOf(arg).String()) p.fmt.fmtS(reflect.TypeOf(arg).String())
return return
case 'p': case 'p':
p.fmtPointer(reflect.ValueOf(arg), 'p') p.fmtPointer(reflect.ValueOf(arg), 'p')
......
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