About fwrite(s, 0, 1, fp)
H.J. Lu
hjl@lucon.org
Mon Oct 26 07:25:00 GMT 1998
> |> However, I just checked the Single Unix specification
> |> ( http://www.rdg.opengroup.org:80/onlinepubs/7908799/ ), and discovered
> |> for fwrite():
> |>
> |> The fwrite() function returns the number of members
> |> successfully written, which may be less than nitems if a write error
> |> ^ note no `only' here!
> |> is encountered. If size or nitems is 0, fwrite() returns 0 and the
> |> state of the stream remains unchanged. Otherwise, if a write error
> |> occurs, the error indicator for the stream is set and errno is set
> |> to indicate the error.
> |>
> |> So it appears to me that there is a conflict of standards here :-(.
> |> What can be done to resolve such a conflict ? Is it advisable to
> |> contact the Open Group about it ?
>
> Note that this standard contradicts itself in the description of fread:
>
> Upon successful completion, fread() returns the number of members
> successfully read which is less than nitems only if a read error or
> ^^^^
> end-of-file is encountered. If size or nitems is 0, fread() returns 0
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> So i'd say the bug is on the Open Group.
>
ISO C must have a testcase in their test suite for this one. Can we
somehow find what it checks for return?
--
H.J. Lu (hjl@gnu.org)
More information about the Libc-hacker
mailing list