[comp.os.minix] ed.c possible bug & patch

bobmon@iuvax.UUCP (Bob...Mon) (02/14/88)

I compiled the ed.c that Andy Tanenbaum posted, for MSDOS with Turbo C
(for no good reason).  I got some warnings about "possibly incorrect
assignment in comparison".  I am attaching diffs for two of these, which
I think really are incorrect.  (I am sure someone will let me know if
I'm wrong.... :-)

	- Bob Montante

*** ed.c
--- new-ed.c
**************
*** 814,821
  		if(nlines > 1)
  			return(ERR);
  
! 		if(nlines = 0)
! 			line2 = lastln;
  
  		if(*inptr != ' ' && *inptr != HT && *inptr != NL)
  			return(ERR);
--- 835,843 -----
  		if(nlines > 1)
  			return(ERR);
  
! 		if(nlines == 0)			/* The original code tested */
! 			line2 = lastln;		/*	if(nlines = 0)	    */
! 						/* which looks wrong.  RAM  */
  
  		if(*inptr != ' ' && *inptr != HT && *inptr != NL)
  			return(ERR);
**************
**************
*** 2136,2142
  			break;
  
  		case BOL:
! 			if (*linp = boln)
  				advance = 0;
  			break;
  
--- 2161,2167 -----
  			break;
  
  		case BOL:
! 			if (*linp == boln)	/* Replaced (*linp = boln) */
  				advance = 0;
  			break;
  
**************

-- 
You TOO Can Defeat The 4-Line .signature Limit And Be Obnoxious To Your Friends And Neighbours!!!!!								...---...									Charles Cabbage on the Difference Engine running SE grade 10W40 at UKnoWhere	Babble@diffEQ	bob,mon@iuvax.cs.indiana.edu	Chucky on Ada	The Slide Rules!"Spaceship Earth!  There IS no substitute!"