2
2
3
3
# ## auxiliary functions
4
4
5
- function _repwrite (out:: IO , c:: Char , n:: Int )
5
+ # ## print char n times
6
+
7
+ function _repprint (out:: IO , c:: Char , n:: Int )
6
8
while n > 0
7
- write (out, c)
9
+ print (out, c)
8
10
n -= 1
9
11
end
10
12
end
@@ -16,15 +18,15 @@ function _pfmt_s(out::IO, fs::FormatSpec, s::Union{AbstractString,Char})
16
18
wid = fs. width
17
19
slen = length (s)
18
20
if wid <= slen
19
- write (out, s)
21
+ print (out, s)
20
22
else
21
23
a = fs. align
22
24
if a == ' <'
23
- write (out, s)
24
- _repwrite (out, fs. fill, wid- slen)
25
+ print (out, s)
26
+ _repprint (out, fs. fill, wid- slen)
25
27
else
26
- _repwrite (out, fs. fill, wid- slen)
27
- write (out, s)
28
+ _repprint (out, fs. fill, wid- slen)
29
+ print (out, s)
28
30
end
29
31
end
30
32
end
@@ -70,19 +72,19 @@ _signchar(x::Real, s::Char) = signbit(x) ? '-' :
70
72
function _pfmt_int (out:: IO , sch:: Char , ip:: String , zs:: Integer , ax:: Integer , op:: Op ) where {Op}
71
73
# print sign
72
74
if sch != ' \0 '
73
- write (out, sch)
75
+ print (out, sch)
74
76
end
75
77
# print prefix
76
78
if ! isempty (ip)
77
- write (out, ip)
79
+ print (out, ip)
78
80
end
79
81
# print padding zeros
80
82
if zs > 0
81
- _repwrite (out, ' 0' , zs)
83
+ _repprint (out, ' 0' , zs)
82
84
end
83
85
# print actual digits
84
86
if ax == 0
85
- write (out, ' 0' )
87
+ print (out, ' 0' )
86
88
else
87
89
_pfmt_intdigits (out, ax, op)
88
90
end
@@ -97,7 +99,7 @@ function _pfmt_intdigits(out::IO, ax::T, op::Op) where {Op, T<:Integer}
97
99
r = ax
98
100
while b > 0
99
101
(q, r) = divrem (r, b)
100
- write (out, _digitchar (q, op))
102
+ print (out, _digitchar (q, op))
101
103
b = _div (b, op)
102
104
end
103
105
end
@@ -128,9 +130,9 @@ function _pfmt_i(out::IO, fs::FormatSpec, x::Integer, op::Op) where {Op}
128
130
a = fs. align
129
131
if a == ' <'
130
132
_pfmt_int (out, sch, ip, 0 , ax, op)
131
- _repwrite (out, fs. fill, wid- xlen)
133
+ _repprint (out, fs. fill, wid- xlen)
132
134
else
133
- _repwrite (out, fs. fill, wid- xlen)
135
+ _repprint (out, fs. fill, wid- xlen)
134
136
_pfmt_int (out, sch, ip, 0 , ax, op)
135
137
end
136
138
end
@@ -142,26 +144,26 @@ end
142
144
function _pfmt_float (out:: IO , sch:: Char , zs:: Integer , intv:: Real , decv:: Real , prec:: Int )
143
145
# print sign
144
146
if sch != ' \0 '
145
- write (out, sch)
147
+ print (out, sch)
146
148
end
147
149
# print padding zeros
148
150
if zs > 0
149
- _repwrite (out, ' 0' , zs)
151
+ _repprint (out, ' 0' , zs)
150
152
end
151
153
idecv = round (Integer, decv * exp10 (prec))
152
154
# print integer part
153
155
if intv == 0
154
- write (out, ' 0' )
156
+ print (out, ' 0' )
155
157
else
156
158
_pfmt_intdigits (out, intv, _Dec ())
157
159
end
158
160
# print decimal point
159
- write (out, ' .' )
161
+ print (out, ' .' )
160
162
# print decimal part
161
163
if prec > 0
162
164
nd = _ndigits (idecv, _Dec ())
163
165
if nd < prec
164
- _repwrite (out, ' 0' , prec - nd)
166
+ _repprint (out, ' 0' , prec - nd)
165
167
end
166
168
_pfmt_intdigits (out, idecv, _Dec ())
167
169
end
@@ -190,9 +192,9 @@ function _pfmt_f(out::IO, fs::FormatSpec, x::AbstractFloat)
190
192
a = fs. align
191
193
if a == ' <'
192
194
_pfmt_float (out, sch, 0 , intv, decv, fs. prec)
193
- _repwrite (out, fs. fill, wid- xlen)
195
+ _repprint (out, fs. fill, wid- xlen)
194
196
else
195
- _repwrite (out, fs. fill, wid- xlen)
197
+ _repprint (out, fs. fill, wid- xlen)
196
198
_pfmt_float (out, sch, 0 , intv, decv, fs. prec)
197
199
end
198
200
end
@@ -202,15 +204,15 @@ function _pfmt_floate(out::IO, sch::Char, zs::Integer, u::Real, prec::Int, e::In
202
204
intv = trunc (Integer,u)
203
205
decv = u - intv
204
206
_pfmt_float (out, sch, zs, intv, decv, prec)
205
- write (out, ec)
207
+ print (out, ec)
206
208
if e >= 0
207
- write (out, ' +' )
209
+ print (out, ' +' )
208
210
else
209
- write (out, ' -' )
211
+ print (out, ' -' )
210
212
e = - e
211
213
end
212
214
if e < 10
213
- write (out, ' 0' )
215
+ print (out, ' 0' )
214
216
end
215
217
_pfmt_intdigits (out, e, _Dec ())
216
218
end
@@ -249,9 +251,9 @@ function _pfmt_e(out::IO, fs::FormatSpec, x::AbstractFloat)
249
251
a = fs. align
250
252
if a == ' <'
251
253
_pfmt_floate (out, sch, 0 , u, fs. prec, e, ec)
252
- _repwrite (out, fs. fill, wid- xlen)
254
+ _repprint (out, fs. fill, wid- xlen)
253
255
else
254
- _repwrite (out, fs. fill, wid- xlen)
256
+ _repprint (out, fs. fill, wid- xlen)
255
257
_pfmt_floate (out, sch, 0 , u, fs. prec, e, ec)
256
258
end
257
259
end
0 commit comments