lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 7 September 2011 07:15, steve donovan <> wrote:
> On Wed, Sep 7, 2011 at 1:09 AM, Josh Simmons <> wrote:
>> The failure is not triggered be errno itself though, so it's possible
>> for any of the functions to return error but not set errno (on windows
>> anyway).
> Yes, the equivalent C program on Windows XP does not set errno after a
> fprintf to a read-only file, _if_ you have previously read from it.
> So definitely not Lua's fault here, looks like a CRT bug.
> steve d.

I would disagree that it is a CRT bug. fwrite which calls fputc is not
required to set errno, although POSIX says it does. What MSDN states
is "If execution is allowed to continue, they return EOF and set errno
to EINVAL."[1] and C99 fwrite states "If an error occurs, the
resulting value of the file position indicator for the stream is
indeterminate." (even though MS does not conform to C99).
>From this I would draw the conclusion that the position indicator is
an indeterminate state and therefore execution can not continue hence
errno is not set, yet this maybe the wrong conclusion.