[comp.lang.forth] FPC3.5 SED bug report

jhl@frith.egr.msu.edu (01/19/90)

The following is an extract from the text of a letter I've sent
to Tom Zimmer. I figured the net at large might be interested 
in this:

========== cut here ==========

	I recently downloaded F-PC 3.5. I installed it for use
under VP/ix running under SCO Xenix 386. VP/ix is SCO's DOS under
UNIX product. In doing so, I've uncovered a bug in the code for
SED. I believe this problem could also occur on a machine
directly running MSDOS.
	
	The error occurs in the words ?DISKFULL and ?ENOUGHDISK.
VP/ix allows you to store DOS files in with Xenix files on your
disk. Both of the above mentioned words call GETDISKFREE.
GETDISKFREE in turn calls DOS INT 21H function 36H. This function
returns the following values:
	
	Clusters:		0FFFFH
	Bytes/sector:		0200H
	Available clusters:	8514H
	Sectors/cluster:	0001H
	
Since available clusters is greater than 8000H, the two *D
operations result in a negative double number on the stack. This
then causes the subsequent D< to fail. SED then tells you that
your disk is too full to save your file. Changing the *D to UM*
results in proper calculation of free disk space.

Here's the two functions from SEDITOR.SEQ:

: ?diskfull     ( --- f1 )
                renaming 0= ?browse or
                if      false exit
                then
                ed1hndl >nam 1+ c@ ':' =
                if  ed1hndl >nam c@ bl or 96 - else 0 then
                getdiskfree * 0 128 um/mod nip *D	( *D should be UM* )
                65000.  128 um/mod nip 0 d< dup
                if      savescr cursor-off
                        8 4 72 16 box&fill
                        bcr ." \s24\2 WARNING !! "
                        bcr
                        bcr
                        ."   You have LESS than 65000 bytes free on disk\b\:03"
                        bcr
                        bcr ."   There may be " warn-prompt
                        off> renaming
                        off> backingup
                        restscr cursor-on
                then    ;

: ?enoughdisk   ( --- f1 )      \ true if there is enough disk space to save
                ed1hndl >nam 1+ c@ ':' =
                if  ed1hndl >nam c@ bl or 96 - else 0 then
                getdiskfree * 0
                renaming 0=
                if      currentsize 2@ d+
                then    128 um/mod nip *D		( *D should be UM* )
                #edsegs tend toff - - 5 / 4 * 8 / 0 d< dup
                                        \ * .8 / 8 to 128 bytes units
                if      savescr cursor-off
                        8 4 72 14 box&fill
                        bcr ." \s24\4 WARNING !! \b\:03"
                        bcr
                        bcr ."   There is " warn-prompt
                        restscr cursor-on
                then    0= ;

j				|%|John Lawitzke, Dale Computer Corp., R&D
				|%|UUCP: uunet!frith!dale1!jhl	   	Work
				|%|      uunet!frith!ipecac!jhl 	Home
Inquiring minds just wondering. |%|Internet: jhl@frith.egr.msu.edu