[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: file:write() fails silently for read-only files
- From: liam mail <liam.list@...>
- Date: Thu, 8 Sep 2011 11:39:42 +0100
On 7 September 2011 07:15, steve donovan <firstname.lastname@example.org> wrote:
> On Wed, Sep 7, 2011 at 1:09 AM, Josh Simmons <email@example.com> 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
> 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." 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.