1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix compilation on FreeBSD (C.feof is a macro there, that expands to direct field access)

This commit is contained in:
Delyan Angelov 2022-09-24 10:17:27 +00:00
parent d624ad50a7
commit f338dec5c6

View File

@ -237,13 +237,14 @@ pub fn (f &File) read(mut buf []u8) !int {
if buf.len == 0 {
return IError(Eof{})
}
nbytes := int(C.fread(buf.data, 1, buf.len, f.cfile))
// the following is needed, because on FreeBSD, C.feof is a macro:
nbytes := int(C.fread(buf.data, 1, buf.len, &C.FILE(f.cfile)))
// if no bytes were read, check for errors and end-of-file.
if nbytes <= 0 {
if C.feof(f.cfile) != 0 {
if C.feof(&C.FILE(f.cfile)) != 0 {
return IError(Eof{})
}
if C.ferror(f.cfile) != 0 {
if C.ferror(&C.FILE(f.cfile)) != 0 {
return IError(NotExpected{
cause: 'unexpected error from fread'
code: -1