os: simplify os.read_bytes_into_newline to fix compilation on freebsd

pull/10167/head
Delyan Angelov 2021-05-22 07:48:12 +03:00
parent b7bf4b034e
commit bf97faf32a
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 4 additions and 3 deletions

View File

@ -376,14 +376,15 @@ pub fn (f &File) read_bytes_into_newline(mut buf []byte) ?int {
mut buf_ptr := 0
mut nbytes := 0
stream := &C.FILE(f.cfile)
for (buf_ptr < buf.len) {
c = C.getc(f.cfile)
c = C.getc(stream)
match c {
C.EOF {
if C.feof(f.cfile) != 0 {
if C.feof(stream) != 0 {
return nbytes
}
if C.ferror(f.cfile) != 0 {
if C.ferror(stream) != 0 {
return error('file read error')
}
}