Skip to content

Commit a2db226

Browse files
committed
Rename skipchars to skipuntil
Per discussion in #36132, I believe this name is much clearer. Another option is "seekuntil". Closes #36132
1 parent 52029af commit a2db226

File tree

7 files changed

+28
-22
lines changed

7 files changed

+28
-22
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.5 deprecations

base/exports.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ export
821821
seekend,
822822
seekstart,
823823
skip,
824-
skipchars,
824+
skipuntil,
825825
take!,
826826
truncate,
827827
unmark,

base/io.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ The delimiter can be a `UInt8`, `AbstractChar`, string, or vector.
433433
Keyword argument `keep` controls whether the delimiter is included in the result.
434434
The text is assumed to be encoded in UTF-8.
435435
436-
See also: [`skipchars`](@ref)
436+
See also: [`skipuntil`](@ref)
437437
438438
# Examples
439439
```jldoctest
@@ -1014,7 +1014,7 @@ end
10141014
10151015
Return an iterable object yielding [`read(io, T)`](@ref).
10161016
1017-
See also: [`skipchars`](@ref), [`eachline`](@ref), [`readuntil`](@ref)
1017+
See also: [`skipuntil`](@ref), [`eachline`](@ref), [`readuntil`](@ref)
10181018
10191019
# Examples
10201020
```jldoctest
@@ -1109,7 +1109,7 @@ Commit all currently buffered writes to the given stream.
11091109
flush(io::IO) = nothing
11101110

11111111
"""
1112-
skipchars(predicate, io::IO; linecomment=nothing)
1112+
skipuntil(predicate, io::IO; linecomment=nothing)
11131113
11141114
Advance the stream `io` such that the next-read character will be the first remaining for
11151115
which `predicate` returns `false`. If the keyword argument `linecomment` is specified, all
@@ -1122,14 +1122,14 @@ See also: [`readuntil`](@ref)
11221122
julia> buf = IOBuffer(" text")
11231123
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=1, mark=-1)
11241124
1125-
julia> skipchars(isspace, buf)
1125+
julia> skipuntil(isspace, buf)
11261126
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=5, mark=-1)
11271127
11281128
julia> String(readavailable(buf))
11291129
"text"
11301130
```
11311131
"""
1132-
function skipchars(predicate, io::IO; linecomment=nothing)
1132+
function skipuntil(predicate, io::IO; linecomment=nothing)
11331133
while !eof(io)
11341134
c = read(io, Char)
11351135
if c === linecomment

doc/src/base/io-network.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Base.redirect_stdin
4444
Base.redirect_stdin(::Function, ::Any)
4545
Base.readchomp
4646
Base.truncate
47-
Base.skipchars
47+
Base.skipuntil
4848
Base.countlines
4949
Base.PipeBuffer
5050
Base.readavailable

stdlib/REPL/src/LineEdit.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ end
11181118

11191119
function edit_replace_word_right(buf::IOBuffer, replace::Function)
11201120
# put the cursor at the beginning of the next word
1121-
skipchars(is_non_word_char, buf)
1121+
skipuntil(is_non_word_char, buf)
11221122
b = position(buf)
11231123
char_move_word_right(buf)
11241124
e = position(buf)

test/iobuffer.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -275,27 +275,27 @@ let io = IOBuffer()
275275
@test Base.buffer_writes(io) === io
276276
end
277277

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

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

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

288288
io = IOBuffer(" text")
289-
skipchars(isspace, io)
289+
skipuntil(isspace, io)
290290
@test String(readavailable(io)) == "text"
291291

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

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

test/iostream.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
@testset "skipchars for IOStream" begin
3+
@testset "skipuntil for IOStream" begin
44
mktemp() do path, file
55
function append_to_file(str)
66
mark(file)
@@ -9,31 +9,31 @@
99
reset(file)
1010
end
1111
# test it doesn't error on eof
12-
@test eof(skipchars(isspace, file))
12+
@test eof(skipuntil(isspace, file))
1313

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

1818
# test it correctly detects comment lines
1919
append_to_file("# \n ")
20-
@test eof(skipchars(isspace, file, linecomment='#'))
20+
@test eof(skipuntil(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))
24+
@test !eof(skipuntil(isspace, file))
2525
@test 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='#'))
29+
@test !eof(skipuntil(isspace, file, linecomment='#'))
3030
@test 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")
3535
@test ncodeunits(char) == byte
36-
@test !eof(skipchars(isletter, file))
36+
@test !eof(skipuntil(isletter, file))
3737
@test read(file, Char) == char
3838
end
3939
end

0 commit comments

Comments
 (0)