(no subject)

Jeffrey R. Lewis jeff@galconn.com
Sat, 28 Oct 2000 06:25:32 -0700


D.Wakeling@exeter.ac.uk wrote:

> To: hugs-bugs@haskell.org
> Subject: bug in Classic Hugs Feb 2000
>
> Hello,
>   I believe there is a bug in Classic Hugs version Feb 2000. On my
> Red Hat 6.2 PC, the manual page for fgetpos(3) says:
>
>     RETURN VALUES
>            The  rewind  function  returns  no value.  Upon successful
>            completion, fgetpos, fseek, fsetpos return  0,  and  ftell
>            returns the current offset.
>
> Yet in the function primFun(primHGetPosn) in the file hugs98/src/iomonad.c
> there are the lines:
>
>         primFun(primHGetPosn) {                 /* Get file position     */
>             Int h;
>             HandleArg(h,3);
>             if (handles[h].hmode!=HCLOSED) {
>         #if HAVE_FGETPOS
>                 fpos_t pos;
>                 if (fgetpos(handles[h].hfp,&pos)) { /* <---- WRONG! --- */
>                     IOReturn(mkInt((Int)pos));
>                 }
>         #elif HAVE_FTELL
>                 /* A reasonable approximation for pre-ANSI compilers */
>                 long pos = ftell(handles[h].hfp);
>                 IOReturn(mkInt((Int)pos));
>         #else
>                 /* deliberate fall through to IOFail */
>         #endif
>
> The line indicated as "WRONG" above should be
>
>                 if (fgetpos(handles[h].hfp,&pos) == 0) {
>
> The use of fsetpos(3) looks similarly wrong.

The use of fsetpos/fgetpos was wrong for other reasons (note the blithe coercion
to int of the fpos_t value).  That code has already been thrown out in the CVS
version of hugs98 in favor of the not perfect, but certainly more portable,
ftell.  But thanks for the report!

--Jeff