Skip to content

Commit

Permalink
fix #3473, readlines of empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 2, 2013
1 parent e2ecb0f commit 42d0954
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ DLLEXPORT int jl_ios_eof(ios_t *s)
{
if (ios_eof(s))
return 1;
if (s->state == bst_rd) {
if (ios_readprep(s, 1) < 1)
return 1;
}
if (ios_readprep(s, 1) < 1)
return 1;
return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ test_monitor(0.1)
# @test isfile(file) == true
# @test readall(file) == "Here is some text"

emptyfile = joinpath(dir, "empty")
touch(emptyfile)
emptyf = open(emptyfile)
@test isempty(readlines(emptyf))
close(emptyf)
rm(emptyfile)

############
# Clean up #
############
Expand Down
2 changes: 2 additions & 0 deletions test/iostring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ skip(io,72)
@assert takebuf_string(io) == ""
close(io)
end

@test isempty(readlines(IOBuffer()))

0 comments on commit 42d0954

Please sign in to comment.