Skip to content

Commit fdca2e9

Browse files
committed
Deprecate skipchars for skipuntil
Closes JuliaLang#36132 The name skipchars does not clearly communicate the functionality available. Tests for skipchars were left in place to ensure the @deprecate macro correctly converted those calls to using skipuntil.
1 parent 2897fe8 commit fdca2e9

File tree

6 files changed

+23
-51
lines changed

6 files changed

+23
-51
lines changed

base/deprecated.jl

+6
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,9 @@ macro get!(h, key0, default)
208208
end
209209

210210
# END 1.5 deprecations
211+
212+
# BEGIN 1.6 deprecations
213+
214+
@deprecate skipchars(pred, io::IO; linecomment=nothing) skipuntil(!pred, io::IO; linecomment=linecomment)
215+
216+
# END 1.6 deprecations

base/exports.jl

-1
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ export
820820
seekend,
821821
seekstart,
822822
skip,
823-
skipchars,
824823
skipuntil,
825824
take!,
826825
truncate,

base/io.jl

-32
Original file line numberDiff line numberDiff line change
@@ -1069,38 +1069,6 @@ Commit all currently buffered writes to the given stream.
10691069
"""
10701070
flush(io::IO) = nothing
10711071

1072-
"""
1073-
skipchars(predicate, io::IO; linecomment=nothing)
1074-
1075-
Advance the stream `io` such that the next-read character will be the first remaining for
1076-
which `predicate` returns `false`. If the keyword argument `linecomment` is specified, all
1077-
characters from that character until the start of the next line are ignored.
1078-
1079-
# Examples
1080-
```jldoctest
1081-
julia> buf = IOBuffer(" text")
1082-
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=1, mark=-1)
1083-
1084-
julia> skipchars(isspace, buf)
1085-
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=5, mark=-1)
1086-
1087-
julia> String(readavailable(buf))
1088-
"text"
1089-
```
1090-
"""
1091-
function skipchars(predicate, io::IO; linecomment=nothing)
1092-
while !eof(io)
1093-
c = read(io, Char)
1094-
if c === linecomment
1095-
readline(io)
1096-
elseif !predicate(c)
1097-
skip(io, -ncodeunits(c))
1098-
break
1099-
end
1100-
end
1101-
return io
1102-
end
1103-
11041072
"""
11051073
skipuntil(predicate, io::IO; linecomment=nothing)
11061074

doc/src/base/io-network.md

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Base.redirect_stdin
4343
Base.redirect_stdin(::Function, ::Any)
4444
Base.readchomp
4545
Base.truncate
46-
Base.skipchars
4746
Base.skipuntil
4847
Base.countlines
4948
Base.PipeBuffer

test/iobuffer.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -277,26 +277,26 @@ end
277277

278278
@testset "skipchars" begin
279279
io = IOBuffer("")
280-
@test eof(skipchars(isspace, io))
280+
@test (@test_deprecated (@test_deprecated eof(skipchars(isspace, io))))
281281

282282
io = IOBuffer(" ")
283-
@test eof(skipchars(isspace, io))
283+
@test (@test_deprecated eof(skipchars(isspace, io)))
284284

285285
io = IOBuffer("# \n ")
286-
@test eof(skipchars(isspace, io, linecomment='#'))
286+
@test (@test_deprecated eof(skipchars(isspace, io, linecomment='#')))
287287

288288
io = IOBuffer(" text")
289289
skipchars(isspace, io)
290-
@test String(readavailable(io)) == "text"
290+
@test (@test_deprecated String(readavailable(io)) == "text")
291291

292292
io = IOBuffer(" # comment \n text")
293293
skipchars(isspace, io, linecomment='#')
294-
@test String(readavailable(io)) == "text"
294+
@test (@test_deprecated String(readavailable(io)) == "text")
295295

296296
for char in ['@','߷','','𐋺']
297297
io = IOBuffer("alphabeticalstuff$char")
298-
@test !eof(skipchars(isletter, io))
299-
@test read(io, Char) == char
298+
@test (@test_deprecated !eof(skipchars(isletter, io)))
299+
@test (@test_deprecated read(io, Char) == char)
300300
end
301301
end
302302

test/iostream.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99
reset(file)
1010
end
1111
# test it doesn't error on eof
12-
@test eof(skipchars(isspace, file))
12+
@test (@test_deprecated eof(skipchars(isspace, file)))
1313

1414
# test it correctly skips
1515
append_to_file(" ")
16-
@test eof(skipchars(isspace, file))
16+
@test (@test_deprecated eof(skipchars(isspace, file)))
1717

1818
# test it correctly detects comment lines
1919
append_to_file("# \n ")
20-
@test eof(skipchars(isspace, file, linecomment='#'))
20+
@test (@test_deprecated eof(skipchars(isspace, file, linecomment='#')))
2121

2222
# test it stops at the appropriate time
2323
append_to_file(" not a space")
24-
@test !eof(skipchars(isspace, file))
25-
@test read(file, Char) == 'n'
24+
@test (@test_deprecated !eof(skipchars(isspace, file)))
25+
@test (@test_deprecated read(file, Char) == 'n')
2626

2727
# test it correctly ignores the contents of comment lines
2828
append_to_file(" #not a space \n not a space")
29-
@test !eof(skipchars(isspace, file, linecomment='#'))
30-
@test read(file, Char) == 'n'
29+
@test (@test_deprecated !eof(skipchars(isspace, file, linecomment='#')))
30+
@test (@test_deprecated read(file, Char) == 'n')
3131

3232
# test it correctly handles unicode
3333
for (byte, char) in zip(1:4, ('@','߷','','𐋺'))
3434
append_to_file("abcdef$char")
35-
@test ncodeunits(char) == byte
36-
@test !eof(skipchars(isletter, file))
37-
@test read(file, Char) == char
35+
@test (@test_deprecated ncodeunits(char) == byte)
36+
@test (@test_deprecated !eof(skipchars(isletter, file)))
37+
@test (@test_deprecated read(file, Char) == char)
3838
end
3939
end
4040
end

0 commit comments

Comments
 (0)