From 42d0954b0ebf0cacd2369e42b27f0dda8f380f9f Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 1 Jul 2013 22:39:00 -0400 Subject: [PATCH] fix #3473, readlines of empty file --- src/sys.c | 6 ++---- test/file.jl | 7 +++++++ test/iostring.jl | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sys.c b/src/sys.c index 9214b2088fb0a..2a0f63f19c39a 100644 --- a/src/sys.c +++ b/src/sys.c @@ -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; } diff --git a/test/file.jl b/test/file.jl index e8596c8b2dc46..40804b5e1193b 100644 --- a/test/file.jl +++ b/test/file.jl @@ -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 # ############ diff --git a/test/iostring.jl b/test/iostring.jl index cfaa21957a1c1..26fe5564bbc25 100644 --- a/test/iostring.jl +++ b/test/iostring.jl @@ -115,3 +115,5 @@ skip(io,72) @assert takebuf_string(io) == "" close(io) end + +@test isempty(readlines(IOBuffer()))