[comp.bugs.4bsd] inc in MH-6.4

sow@luthcad.UUCP (04/04/87)

Index: .../mh/uip/scansbr.c

Description:
	The inc(1) command, part of MH-6.4, clears the
	maildrop even if a write error has occured.

	Some fputs didn't return write error status correctly.

Repeat-By:
	Put the MH folder on a partition with no space left.
	Do inc, it clears the maildrop without writing the
	mail to the folder.

Fix:
	Check the return status on close.
	Write your own fputs.



*** uip/scansbr.c.old	Fri Apr  3 23:58:08 1987
--- uip/scansbr.c	Sat Apr  4 02:53:32 1987
***************
*** 42,50
  #endif	RPATHS
  
  #define FPUTS(buf) {\
! 		if (fputs(buf,scnout) == EOF)\
! 		    adios (scnmsg, "write error on");\
! 		}
  
  /*  */
  

--- 42,50 -----
  #endif	RPATHS
  
  #define FPUTS(buf) {\
! 		    if(mh_fputs(buf,scnout) == EOF )\
! 		       adios (scnmsg, "write error on");\
! 		   }
  
  /*  */
  
***************
*** 263,269
      *--nxtbuf = tmpbuf;
  
      if (outnum)
! 	(void) fclose (scnout);
  
      return (state != FILEEOF ? SCNERR : encrypted ? SCNENC : SCNMSG);
  }

--- 263,270 -----
      *--nxtbuf = tmpbuf;
  
      if (outnum)
! 	if( fclose (scnout) == EOF)
! 	   adios (scnmsg, "write error on");
  
      return (state != FILEEOF ? SCNERR : encrypted ? SCNENC : SCNMSG);
  }
***************
*** 280,283
  register char  *name;
  {
      return name;
  }

--- 281,295 -----
  register char  *name;
  {
      return name;
+ }
+ 
+ mh_fputs(s, stream)
+ char *s;
+ FILE *stream;
+ {
+ 	char	c;
+ 	while(c = *s++) 
+ 		if(putc(c,stream) == EOF )
+ 			return(EOF);
+ 	return(0);
  }

Sven-Ove Westberg, CAD, University of Lulea, S-951 87 Lulea
Tel:     +46-920-91677  (work)         +46-920-48390  (home)
UUCP:    sow@luthcad.UUCP  or  seismo!mcvax!enea!luthcad!sow
ARPA:    enea!luthcad!sow@seismo.css.gov