File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -207,23 +207,29 @@ end
207207 CR = UInt8(' \r ' )
208208
209209 a = Vector{UInt8}(undef, 8192 )
210+ current_loc = 0
210211 while ! eof(f)
211212 nb = readbytes!(f, a)
212213 for i in 1 : nb
214+ current_loc = i
213215 if a[i] == LF && i> 1 && a[i- 1 ] == CR
214216 CLOSE(f)
215217 return [CR, LF]
216218 elseif a[i] == LF
217219 CLOSE(f)
218220 return [LF]
219221 # we must make sure \r\n is not trapped here
220- # FIXME when \r is the only character in the file we cannot detect linebreak
221222 elseif ! (a[i] in (CR, LF)) && i> 1 && a[i- 1 ] == CR
222223 CLOSE(f)
223224 return [CR]
224225 end
225226 end
226227 end
228+ # if \r is the last character and we could not detect it as linebreak, we can detect it here
229+ if a[current_loc] == CR
230+ CLOSE(f)
231+ return [CR]
232+ end
227233 CLOSE(f)
228234 throw(ArgumentError(" end of line is not detectable, set the `linebreak` argument manually" ))
229235end
You can’t perform that action at this time.
0 commit comments