Hello Vincent,

On Sat, Jan 10, 2009 at 3:07 AM, Vincent Lefevre <vinc...@vinc17.org> wrote:
> Package: manpages-dev
> Version: 3.15-1
> Severity: normal
>
> The sentence
>
>    The value EOF is returned if the end of input is reached before
>    either the first successful conversion or a matching failure
>    occurs.
>
> does not look correct English to me. The word "either" may be
> misplaced.

It is correct English, though slightly hard to parse.

    The value EOF is returned if [[the end of input is reached]] before
    either [[the first successful conversion]] or [[a matching failure
    occurs]].

The value EOF is returned if X [occurs] before either Y or Z.

> Anyway, the C standard says something different, e.g.
> for fscanf:
>
>    The fscanf function returns the value of the macro EOF if an input
>    failure occurs before any conversion.
>
> Matching failures do not seem to be a cause of EOF, but have an
> influence on the number of input items assigned. Indeed the C
> standard says (and nothing more):
>
>    Otherwise, the function returns the number of input items
>    assigned, which can be fewer than provided for, or even zero,
>    in the event of an early matching failure.
>
>
> Also, the scanf(3) man page says:
>
>    EOF is also returned if a read error occurs, in which case the
>    error indicator for the stream (see ferror(3)) is set, and
>    errno is set indicate the error.
>
> This does not seem to be allowed by the C standard (see the two cited
> sentences above). For instance, in
>
>  n = fscanf (stdin, "%d %d", &x, &y);
>
> if there has been at least a conversion, i.e. if x has been modified,
> then n must not be EOF, but at least 1, even when there has been a
> read error later. Now, I don't know whether this is an error in the
> man page or in the glibc itself.

The POSIX.1 spec says something different, much closer to the Linux man page:

[[
Upon successful completion, these functions shall return the number of
successfully matched
and assigned input items; this number can be zero in the event of an
early matching failure. If
the input ends before the first matching failure or conversion, EOF
shall be returned. If any
error occurs, EOF shall be returned, and errno shall be set to
indicate the error. If a read error
occurs, the error indicator for the stream shall be set.
]]

So, I am not yet convinced that there is any problem, but am open to more input.

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to