Skip to content

Commit bbaf4d2

Browse files
committed
Rename ostream and istream to stream
This distinction is useless.
1 parent fb60bb9 commit bbaf4d2

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/StringEncodings.jl

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ end
8282
const BUFSIZE = 100
8383

8484
type StringEncoder{F<:Encoding, T<:Encoding, S<:IO} <: IO
85-
ostream::S
85+
stream::S
8686
closestream::Bool
8787
cd::Ptr{Void}
8888
inbuf::Vector{UInt8}
@@ -94,7 +94,7 @@ type StringEncoder{F<:Encoding, T<:Encoding, S<:IO} <: IO
9494
end
9595

9696
type StringDecoder{F<:Encoding, T<:Encoding, S<:IO} <: IO
97-
istream::S
97+
stream::S
9898
closestream::Bool
9999
cd::Ptr{Void}
100100
inbuf::Vector{UInt8}
@@ -178,35 +178,35 @@ end
178178
## StringEncoder
179179

180180
"""
181-
StringEncoder(istream, to, from=enc"UTF-8")
181+
StringEncoder(stream, to, from=enc"UTF-8")
182182
183183
Returns a new write-only I/O stream, which converts any text in the encoding `from`
184-
written to it into text in the encoding `to` written to `ostream`. Calling `close` on the
185-
stream is necessary to complete the encoding (but does not close `ostream`).
184+
written to it into text in the encoding `to` written to `stream`. Calling `close` on the
185+
stream is necessary to complete the encoding (but does not close `stream`).
186186
187187
`to` and `from` can be specified either as a string or as an `Encoding` object.
188188
"""
189-
function StringEncoder(ostream::IO, to::Encoding, from::Encoding=enc"UTF-8")
189+
function StringEncoder(stream::IO, to::Encoding, from::Encoding=enc"UTF-8")
190190
cd = iconv_open(ASCIIString(to), ASCIIString(from))
191191
inbuf = Vector{UInt8}(BUFSIZE)
192192
outbuf = Vector{UInt8}(BUFSIZE)
193-
s = StringEncoder{typeof(from), typeof(to), typeof(ostream)}(ostream, false,
193+
s = StringEncoder{typeof(from), typeof(to), typeof(stream)}(stream, false,
194194
cd, inbuf, outbuf,
195195
Ref{Ptr{UInt8}}(pointer(inbuf)), Ref{Ptr{UInt8}}(pointer(outbuf)),
196196
Ref{Csize_t}(0), Ref{Csize_t}(BUFSIZE))
197197
finalizer(s, finalize)
198198
s
199199
end
200200

201-
StringEncoder(ostream::IO, to::AbstractString, from::Encoding=enc"UTF-8") =
202-
StringEncoder(ostream, Encoding(to), from)
203-
StringEncoder(ostream::IO, to::AbstractString, from::AbstractString) =
204-
StringEncoder(ostream, Encoding(to), Encoding(from))
201+
StringEncoder(stream::IO, to::AbstractString, from::Encoding=enc"UTF-8") =
202+
StringEncoder(stream, Encoding(to), from)
203+
StringEncoder(stream::IO, to::AbstractString, from::AbstractString) =
204+
StringEncoder(stream, Encoding(to), Encoding(from))
205205

206206
function show{F, T, S}(io::IO, s::StringEncoder{F, T, S})
207207
from = F()
208208
to = T()
209-
print(io, "StringEncoder{$from, $to}($(s.ostream))")
209+
print(io, "StringEncoder{$from, $to}($(s.stream))")
210210
end
211211

212212
# Flush input buffer and convert it into output buffer
@@ -220,7 +220,7 @@ function flush(s::StringEncoder)
220220
s.outbytesleft[] = 0
221221
while s.outbytesleft[] < BUFSIZE
222222
iconv!(s.cd, s.inbuf, s.outbuf, s.inbufptr, s.outbufptr, s.inbytesleft, s.outbytesleft)
223-
write(s.ostream, sub(s.outbuf, 1:(BUFSIZE - Int(s.outbytesleft[]))))
223+
write(s.stream, sub(s.outbuf, 1:(BUFSIZE - Int(s.outbytesleft[]))))
224224
end
225225

226226
s
@@ -232,7 +232,7 @@ function close(s::StringEncoder)
232232
# Make sure C memory/resources are returned
233233
finalize(s)
234234
if s.closestream
235-
close(s.ostream)
235+
close(s.stream)
236236
end
237237
# flush() wasn't able to empty input buffer, which cannot happen with correct data
238238
s.inbytesleft[] == 0 || throw(IncompleteSequenceError())
@@ -248,38 +248,38 @@ end
248248
## StringDecoder
249249

250250
"""
251-
StringDecoder(istream, from, to=enc"UTF-8")
251+
StringDecoder(stream, from, to=enc"UTF-8")
252252
253253
Returns a new read-only I/O stream, which converts text in the encoding `from`
254-
read from `istream` into text in the encoding `to`. Calling `close` on the
255-
stream does not close `ostream`.
254+
read from `stream` into text in the encoding `to`. Calling `close` on the
255+
stream does not close `stream`.
256256
257257
`to` and `from` can be specified either as a string or as an `Encoding` object.
258258
259259
Note that some implementations (notably the Windows one) may accept invalid sequences
260260
in the input data without raising an error.
261261
"""
262-
function StringDecoder(istream::IO, from::Encoding, to::Encoding=enc"UTF-8")
262+
function StringDecoder(stream::IO, from::Encoding, to::Encoding=enc"UTF-8")
263263
cd = iconv_open(ASCIIString(to), ASCIIString(from))
264264
inbuf = Vector{UInt8}(BUFSIZE)
265265
outbuf = Vector{UInt8}(BUFSIZE)
266-
s = StringDecoder{typeof(from), typeof(to), typeof(istream)}(istream, false,
266+
s = StringDecoder{typeof(from), typeof(to), typeof(stream)}(stream, false,
267267
cd, inbuf, outbuf,
268268
Ref{Ptr{UInt8}}(pointer(inbuf)), Ref{Ptr{UInt8}}(pointer(outbuf)),
269269
Ref{Csize_t}(0), Ref{Csize_t}(BUFSIZE), 0)
270270
finalizer(s, finalize)
271271
s
272272
end
273273

274-
StringDecoder(istream::IO, from::AbstractString, to::Encoding=enc"UTF-8") =
275-
StringDecoder(istream, Encoding(from), to)
276-
StringDecoder(istream::IO, from::AbstractString, to::AbstractString) =
277-
StringDecoder(istream, Encoding(from), Encoding(to))
274+
StringDecoder(stream::IO, from::AbstractString, to::Encoding=enc"UTF-8") =
275+
StringDecoder(stream, Encoding(from), to)
276+
StringDecoder(stream::IO, from::AbstractString, to::AbstractString) =
277+
StringDecoder(stream, Encoding(from), Encoding(to))
278278

279279
function show{F, T, S}(io::IO, s::StringDecoder{F, T, S})
280280
from = F()
281281
to = T()
282-
print(io, "StringDecoder{$from, $to}($(s.istream))")
282+
print(io, "StringDecoder{$from, $to}($(s.stream))")
283283
end
284284

285285
# Fill input buffer and convert it into output buffer
@@ -290,12 +290,12 @@ function fill_buffer!(s::StringDecoder)
290290
s.skip = 0
291291

292292
# Input buffer and input stream empty
293-
if s.inbytesleft[] == 0 && eof(s.istream)
293+
if s.inbytesleft[] == 0 && eof(s.stream)
294294
i = iconv_reset!(s)
295295
return i
296296
end
297297

298-
s.inbytesleft[] += readbytes!(s.istream, sub(s.inbuf, Int(s.inbytesleft[]+1):BUFSIZE))
298+
s.inbytesleft[] += readbytes!(s.stream, sub(s.inbuf, Int(s.inbytesleft[]+1):BUFSIZE))
299299
iconv!(s.cd, s.inbuf, s.outbuf, s.inbufptr, s.outbufptr, s.inbytesleft, s.outbytesleft)
300300
end
301301

@@ -315,7 +315,7 @@ function close(s::StringDecoder)
315315
# Make sure C memory/resources are returned
316316
finalize(s)
317317
if s.closestream
318-
close(s.istream)
318+
close(s.stream)
319319
end
320320
# iconv_reset!() wasn't able to empty input buffer, which cannot happen with correct data
321321
s.inbytesleft[] == 0 || throw(IncompleteSequenceError())
@@ -325,11 +325,11 @@ function read(s::StringDecoder, ::Type{UInt8})
325325
eof(s) ? throw(EOFError()) : s.outbuf[s.skip+=1]
326326
end
327327

328-
isreadable(s::StringDecoder) = isreadable(s.istream)
328+
isreadable(s::StringDecoder) = isreadable(s.stream)
329329
iswritable(s::StringDecoder) = false
330330

331331
isreadable(s::StringEncoder) = false
332-
iswritable(s::StringEncoder) = iswritable(s.ostream)
332+
iswritable(s::StringEncoder) = iswritable(s.stream)
333333

334334

335335
## Convenience I/O functions

0 commit comments

Comments
 (0)