Skip to content

Commit f03fbf9

Browse files
committed
change skipchars(io, predicate) to skipchars(predicate, io)
This is to be consistent with our style guide.
1 parent 324dc49 commit f03fbf9

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,9 @@ Deprecated or removed
692692

693693
* `nb_available` is now `bytesavailable` ([#25634]).
694694

695+
* `skipchars(io::IO, predicate; linecomment=nothing)` is deprecated in favor of
696+
`skipchars(predicate, io::IO; linecomment=nothing)` ([#25667]).
697+
695698
* `Bidiagonal` constructors now use a `Symbol` (`:U` or `:L`) for the upper/lower
696699
argument, instead of a `Bool` or a `Char` ([#22703]).
697700

base/deprecated.jl

+2
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,8 @@ end
15921592

15931593
@deprecate nb_available bytesavailable
15941594

1595+
@deprecate skipchars(io::IO, predicate; linecomment=nothing) skipchars(predicate, io, linecomment=linecomment)
1596+
15951597
# issue #9053
15961598
if Sys.iswindows()
15971599
function Filesystem.tempname(uunique::UInt32)

base/io.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ Commit all currently buffered writes to the given stream.
912912
flush(io::IO) = nothing
913913

914914
"""
915-
skipchars(io::IO, predicate; linecomment=nothing)
915+
skipchars(predicate, io::IO; linecomment=nothing)
916916
917917
Advance the stream `io` such that the next-read character will be the first remaining for
918918
which `predicate` returns `false`. If the keyword argument `linecomment` is specified, all
@@ -923,19 +923,19 @@ characters from that character until the start of the next line are ignored.
923923
julia> buf = IOBuffer(" text")
924924
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=1, mark=-1)
925925
926-
julia> skipchars(buf, isspace)
926+
julia> skipchars(isspace, buf)
927927
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=5, mark=-1)
928928
929929
julia> String(readavailable(buf))
930930
"text"
931931
```
932932
"""
933-
function skipchars(io::IO, pred; linecomment=nothing)
933+
function skipchars(predicate, io::IO; linecomment=nothing)
934934
while !eof(io)
935935
c = read(io, Char)
936936
if c === linecomment
937937
readline(io)
938-
elseif !pred(c)
938+
elseif !predicate(c)
939939
skip(io, -codelen(c))
940940
break
941941
end

base/repl/LineEdit.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ end
10371037

10381038
function edit_replace_word_right(buf::IOBuffer, replace::Function)
10391039
# put the cursor at the beginning of the next word
1040-
skipchars(buf, is_non_word_char)
1040+
skipchars(is_non_word_char, buf)
10411041
b = position(buf)
10421042
char_move_word_right(buf)
10431043
e = position(buf)

test/iobuffer.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -262,25 +262,25 @@ end
262262
# skipchars
263263
let
264264
io = IOBuffer("")
265-
@test eof(skipchars(io, isspace))
265+
@test eof(skipchars(isspace, io))
266266

267267
io = IOBuffer(" ")
268-
@test eof(skipchars(io, isspace))
268+
@test eof(skipchars(isspace, io))
269269

270270
io = IOBuffer("# \n ")
271-
@test eof(skipchars(io, isspace, linecomment='#'))
271+
@test eof(skipchars(isspace, io, linecomment='#'))
272272

273273
io = IOBuffer(" text")
274-
skipchars(io, isspace)
274+
skipchars(isspace, io)
275275
@test String(readavailable(io)) == "text"
276276

277277
io = IOBuffer(" # comment \n text")
278-
skipchars(io, isspace, linecomment='#')
278+
skipchars(isspace, io, linecomment='#')
279279
@test String(readavailable(io)) == "text"
280280

281281
for char in ['@','߷','','𐋺']
282282
io = IOBuffer("alphabeticalstuff$char")
283-
@test !eof(skipchars(io, isalpha))
283+
@test !eof(skipchars(isalpha, io))
284284
@test read(io, Char) == char
285285
end
286286
end

test/iostream.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@ mktemp() do path, file
1010
end
1111

1212
# test it doesn't error on eof
13-
@test eof(skipchars(file, isspace))
13+
@test eof(skipchars(isspace, file))
1414

1515
# test it correctly skips
1616
append_to_file(" ")
17-
@test eof(skipchars(file, isspace))
17+
@test eof(skipchars(isspace, file))
1818

1919
# test it correctly detects comment lines
2020
append_to_file("# \n ")
21-
@test eof(skipchars(file, isspace, linecomment='#'))
21+
@test eof(skipchars(isspace, file, linecomment='#'))
2222

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

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

3333
# test it correctly handles unicode
3434
for (byte,char) in zip(1:4, ('@','߷','','𐋺'))
3535
append_to_file("abcdef$char")
3636
@test Base.codelen(char) == byte
37-
@test !eof(skipchars(file, isalpha))
37+
@test !eof(skipchars(isalpha, file))
3838
@test read(file, Char) == char
3939
end
4040
end

0 commit comments

Comments
 (0)