aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fmt/format.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-05-15 15:18:09 -0700
committerRob Pike <r@golang.org>2009-05-15 15:18:09 -0700
commitc81d09d92bee8f21a79d8bbef3efc6f9f0e36a7e (patch)
treedb9c107d3b0ff9d19cffe1568325b8a7f275b5bb /src/lib/fmt/format.go
parent66f5e89082ce981b9c025dfa1f2421ec525ecf73 (diff)
downloadgo-c81d09d92bee8f21a79d8bbef3efc6f9f0e36a7e.tar.xz
implement %#o %#x %#X formats
R=rsc OCL=28936 CL=28936
Diffstat (limited to 'src/lib/fmt/format.go')
-rw-r--r--src/lib/fmt/format.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/fmt/format.go b/src/lib/fmt/format.go
index a66440f261..3cd492980d 100644
--- a/src/lib/fmt/format.go
+++ b/src/lib/fmt/format.go
@@ -202,6 +202,21 @@ func (f *Fmt) integer(a int64, base uint, is_signed bool, digits *string) string
i--;
}
+ if f.sharp {
+ switch base {
+ case 8:
+ if buf[i+1] != '0' {
+ buf[i] = '0';
+ i--;
+ }
+ case 16:
+ buf[i] = 'x' + digits[10]-'a';
+ i--;
+ buf[i] = '0';
+ i--;
+ }
+ }
+
if negative {
buf[i] = '-';
i--;