|
It was thus said that the Great Massimo Sala once stated:
> Current code of the function, last lines:
> ...
> readstatus = ferror(lf.f);
> if (filename) fclose(lf.f); /* close file (even in case of errors) */
> if (readstatus) {
> lua_settop(L, fnameindex); /* ignore results from 'lua_load' */
> return errfile(L, "read", fnameindex);
> }
> lua_remove(L, fnameindex);
> return status;
> }
>
>
> On some OS fclose could change errno. See for example
> http://man7.org/linux/man-pages/man3/fclose.3.html
> The fclose() function may also fail and set errno for any of the
> errors specified for the routines close(2), write(2), or fflush(3).
>
The C standard (C89, C99, and C11 have the same language) states this
about errno:
The value of errno may be set to nonzero by a library function call
whether or not there is an error, provided the use of errno is not
documented in the description of the function in this International
Standard.
fclose() is not documented as setting errno, so it's up to the
implementation (not even the operating system---the C standard library
itself) whether fclose() sets errno or not. I think it was intentional that
errno isn't used in this function.
-spc
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org
_______________________________________________ lua-l mailing list -- lua-l@lists.lua.org To unsubscribe send an email to lua-l-leave@lists.lua.org