Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
db1656f3
Commit
db1656f3
authored
Jan 16, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
two more casifications in fmt
R=rsc DELTA=14 (0 added, 0 deleted, 14 changed) OCL=22960 CL=22962
parent
55ebef61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
src/lib/fmt/format.go
src/lib/fmt/format.go
+7
-7
src/lib/fmt/print.go
src/lib/fmt/print.go
+7
-7
No files found.
src/lib/fmt/format.go
View file @
db1656f3
...
...
@@ -413,7 +413,7 @@ func (f *Fmt) Fmt_q(s string) *Fmt {
// floating-point
func
Prec
(
f
*
Fmt
,
def
int
)
int
{
func
do
Prec
(
f
*
Fmt
,
def
int
)
int
{
if
f
.
prec_present
{
return
f
.
prec
;
}
...
...
@@ -428,15 +428,15 @@ func fmtString(f *Fmt, s string) *Fmt {
// float64
func
(
f
*
Fmt
)
Fmt_e64
(
a
float64
)
*
Fmt
{
return
fmtString
(
f
,
strconv
.
Ftoa64
(
a
,
'e'
,
Prec
(
f
,
6
)));
return
fmtString
(
f
,
strconv
.
Ftoa64
(
a
,
'e'
,
do
Prec
(
f
,
6
)));
}
func
(
f
*
Fmt
)
Fmt_f64
(
a
float64
)
*
Fmt
{
return
fmtString
(
f
,
strconv
.
Ftoa64
(
a
,
'f'
,
Prec
(
f
,
6
)));
return
fmtString
(
f
,
strconv
.
Ftoa64
(
a
,
'f'
,
do
Prec
(
f
,
6
)));
}
func
(
f
*
Fmt
)
Fmt_g64
(
a
float64
)
*
Fmt
{
return
fmtString
(
f
,
strconv
.
Ftoa64
(
a
,
'g'
,
Prec
(
f
,
-
1
)));
return
fmtString
(
f
,
strconv
.
Ftoa64
(
a
,
'g'
,
do
Prec
(
f
,
-
1
)));
}
func
(
f
*
Fmt
)
Fmt_fb64
(
a
float64
)
*
Fmt
{
...
...
@@ -447,15 +447,15 @@ func (f *Fmt) Fmt_fb64(a float64) *Fmt {
// cannot defer to float64 versions
// because it will get rounding wrong in corner cases.
func
(
f
*
Fmt
)
Fmt_e32
(
a
float32
)
*
Fmt
{
return
fmtString
(
f
,
strconv
.
Ftoa32
(
a
,
'e'
,
Prec
(
f
,
6
)));
return
fmtString
(
f
,
strconv
.
Ftoa32
(
a
,
'e'
,
do
Prec
(
f
,
6
)));
}
func
(
f
*
Fmt
)
Fmt_f32
(
a
float32
)
*
Fmt
{
return
fmtString
(
f
,
strconv
.
Ftoa32
(
a
,
'f'
,
Prec
(
f
,
6
)));
return
fmtString
(
f
,
strconv
.
Ftoa32
(
a
,
'f'
,
do
Prec
(
f
,
6
)));
}
func
(
f
*
Fmt
)
Fmt_g32
(
a
float32
)
*
Fmt
{
return
fmtString
(
f
,
strconv
.
Ftoa32
(
a
,
'g'
,
Prec
(
f
,
-
1
)));
return
fmtString
(
f
,
strconv
.
Ftoa32
(
a
,
'g'
,
do
Prec
(
f
,
-
1
)));
}
func
(
f
*
Fmt
)
Fmt_fb32
(
a
float32
)
*
Fmt
{
...
...
src/lib/fmt/print.go
View file @
db1656f3
...
...
@@ -45,7 +45,7 @@ type pp struct {
fmt
*
Fmt
;
}
func
Printer
()
*
pp
{
func
new
Printer
()
*
pp
{
p
:=
new
(
pp
);
p
.
fmt
=
fmt
.
New
();
return
p
;
...
...
@@ -130,7 +130,7 @@ func (p *pp) doprint(v reflect.StructValue, addspace, addnewline bool);
export
func
Fprintf
(
w
io
.
Write
,
format
string
,
a
...
)
(
n
int
,
error
*
os
.
Error
)
{
v
:=
reflect
.
NewValue
(
a
)
.
(
reflect
.
PtrValue
)
.
Sub
()
.
(
reflect
.
StructValue
);
p
:=
Printer
();
p
:=
new
Printer
();
p
.
doprintf
(
format
,
v
);
n
,
error
=
w
.
Write
(
p
.
buf
[
0
:
p
.
n
]);
return
n
,
error
;
...
...
@@ -143,7 +143,7 @@ export func Printf(format string, v ...) (n int, errno *os.Error) {
export
func
Sprintf
(
format
string
,
a
...
)
string
{
v
:=
reflect
.
NewValue
(
a
)
.
(
reflect
.
PtrValue
)
.
Sub
()
.
(
reflect
.
StructValue
);
p
:=
Printer
();
p
:=
new
Printer
();
p
.
doprintf
(
format
,
v
);
s
:=
string
(
p
.
buf
)[
0
:
p
.
n
];
return
s
;
...
...
@@ -154,7 +154,7 @@ export func Sprintf(format string, a ...) string {
export
func
Fprint
(
w
io
.
Write
,
a
...
)
(
n
int
,
error
*
os
.
Error
)
{
v
:=
reflect
.
NewValue
(
a
)
.
(
reflect
.
PtrValue
)
.
Sub
()
.
(
reflect
.
StructValue
);
p
:=
Printer
();
p
:=
new
Printer
();
p
.
doprint
(
v
,
false
,
false
);
n
,
error
=
w
.
Write
(
p
.
buf
[
0
:
p
.
n
]);
return
n
,
error
;
...
...
@@ -167,7 +167,7 @@ export func Print(v ...) (n int, errno *os.Error) {
export
func
Sprint
(
a
...
)
string
{
v
:=
reflect
.
NewValue
(
a
)
.
(
reflect
.
PtrValue
)
.
Sub
()
.
(
reflect
.
StructValue
);
p
:=
Printer
();
p
:=
new
Printer
();
p
.
doprint
(
v
,
false
,
false
);
s
:=
string
(
p
.
buf
)[
0
:
p
.
n
];
return
s
;
...
...
@@ -179,7 +179,7 @@ export func Sprint(a ...) string {
export
func
Fprintln
(
w
io
.
Write
,
a
...
)
(
n
int
,
error
*
os
.
Error
)
{
v
:=
reflect
.
NewValue
(
a
)
.
(
reflect
.
PtrValue
)
.
Sub
()
.
(
reflect
.
StructValue
);
p
:=
Printer
();
p
:=
new
Printer
();
p
.
doprint
(
v
,
true
,
true
);
n
,
error
=
w
.
Write
(
p
.
buf
[
0
:
p
.
n
]);
return
n
,
error
;
...
...
@@ -192,7 +192,7 @@ export func Println(v ...) (n int, errno *os.Error) {
export
func
Sprintln
(
a
...
)
string
{
v
:=
reflect
.
NewValue
(
a
)
.
(
reflect
.
PtrValue
)
.
Sub
()
.
(
reflect
.
StructValue
);
p
:=
Printer
();
p
:=
new
Printer
();
p
.
doprint
(
v
,
true
,
true
);
s
:=
string
(
p
.
buf
)[
0
:
p
.
n
];
return
s
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment