(no subject)

D.Wakeling@exeter.ac.uk D.Wakeling@exeter.ac.uk
Sat, 28 Oct 2000 13:13:56 +0100 (BST)


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. 

David 
-------------------------------------------------------------------------------
Dr. David Wakeling, School of Engineering and Computer Science 
University of Exeter, Exeter, Devon, EX4 4PT. 
unofficial web page: http://www.dcs.ex.ac.uk/~david
-------------------------------------------------------------------------------