[comp.os.minix] FIX - Stevie - allow editing of empty files

ko@mscunx.Sp.Unisys.Com (Keith Otis) (10/03/88)

In <641@faui44.informatik.uni-erlangen.de>
  Robert Regn <rtregn@faui44.informatik.uni-erlangen.de> writes:

>Remaining problems are:
>   editing an empty file hangs stevie

I also had this problem after porting stevie to run under msdos.  Below is
a cdiff that will fix the problem.

---------------------   Cut Here   ------------------------------------------
*** fileio.c	Fri Jun 10 16:15:19 1988
--- fileio.c.new	Sun Oct  2 23:23:23 1988
***************
*** 6,11 ****
--- 6,13 ----
   */
  
  #include "stevie.h"
+ #include <sys/types.h>
+ #include <sys/stat.h>
  
  void
  filemess(s)
***************
*** 45,50 ****
--- 47,53 ----
  	int	unprint = 0;
  	int	linecnt = 0;
  	bool_t	wasempty = bufempty();
+ 	struct	stat	stat_buf;
  
  	curr = fromp->linep;
  
***************
*** 54,59 ****
--- 57,66 ----
  	if ( (f=fopen(fname,"r")) == NULL )
  		return TRUE;
  
+ 	stat(fname,&stat_buf);
+ 	if ( stat_buf.st_size == 0 )
+ 		return FALSE;
+ 
  	filemess("");
  
  	for (i=nchars=0; (c=getc(f)) != EOF ;nchars++) {
----------    End  of   Cdiff   ---------------------------------------

Keith Otis  Unisys Marketing Services - Eagan MN   ko@Mscunx.Sp.Unisys.Com
-- 
Keith Otis - Unisys Marketing Services Eagan Mn
Internet: ko@mscunx.SP.Unisys.Com
UseNet: {ihnp4!sx1100, bungia!elric}!mscunx!ko
Phone: (612)-687-2857