Skip to content

Commit

Permalink
readline() should return a String.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmsquire committed Mar 4, 2014
1 parent fdd0e45 commit 268a606
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/GZip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,18 @@ function readline(s::GZipStream)
pos = 1

if gzgets(s, buf) == C_NULL # Throws an exception on error
return buf[1:0]
return ""
end

while(true)
# since gzgets didn't return C_NULL, there must be a \0 in the buffer
eos = search(buf, '\0', pos)
if eos == 1 || buf[eos-1] == '\n'
return resize!(buf, eos-1)
return bytestring(resize!(buf, eos-1))
end

# If we're at the end of the file, return the string
if eof(s) return resize!(buf, eos-1) end
if eof(s) return bytestring(resize!(buf, eos-1)) end

# Otherwise, append to the end of the previous buffer

Expand All @@ -430,7 +430,7 @@ function readline(s::GZipStream)
# Read in the next chunk
if gzgets(s, pointer(buf)+pos-1, GZ_LINE_BUFSIZE) == C_NULL
# eof(s); remove extra buffer space
return resize!(buf, length(buf)-add_len)
return bytestring(resize!(buf, length(buf)-add_len))
end
end
end
Expand Down

0 comments on commit 268a606

Please sign in to comment.