Mail Archives: djgpp-workers/1999/10/21/19:00:51
Bonjour M. DJ Delorie
>
> > I was looking at fseek(), fgetpos(), fsetpos() earlier and I noticed
> > that fsetpos() appears to ignore the return value of fseek(). Is
> > this intended? If not, there's a patch below to fix it. I also
> > altered the return value to be -1, to be consistent with fseek(). If
> > this is the intended behaviour, may I ask why?
>
> Linux says:
>
> RETURN VALUES
> The rewind function returns no value. Upon successful
> completion, fgetpos, fseek, fsetpos return 0, and ftell returns
> the current offset. Otherwise, -1 is returned and the global
> variable errno is set to indicate the error.
I would consider this to be a "bug" in the Linux man pages. I think
linux uses GNU lib C now and more accurate informations are in the
info manuals. Probably, in glibc on error fseek() returns EOF, which
maps to -1.
stating -1 explicitely in the man pages, has the nasty side effect of
making people do things like :
if (fsetpos(stream, pos) == -1 /* or < 0 */) { ...}
which may lead to trouble when porting to other operationg systems.
I would advocate for testing != 0.
BTW, if my point did not come across, I'm not saying that fsetpos()
returning -1 is a bug, but applications testing for negative return value
for fsetpos() is not portable.
> IRIX says:
>
> DIAGNOSTICS
> If successful, both fsetpos and fgetpos return zero. On failure,
> they return non-zero and set errno to indicate the error.
>
--
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!
- Raw text -