[comp.os.minix] ed.c tuneup

dean@ndmath.UUCP (Dean Alvis) (02/18/88)

	I've enjoyed using the recently posted "ed", both on a UNIX
system and at home under CP/M. One minor annoyance is the slowness
of the write command for large (>>1000 lines) files. One solution
is to replace the calls to gettxt() (which in turn call getptr())
in dowrite(). I've lost the original, so can't provide diffs (sorry),
but the idea is to just use a LINE * in the loop in dowrite(), as
follows:

	LINE *lptr;
	...
	lptr = getptr(from);
	for(lin=from;lin<=to;lin++) {
		str = lptr->l_buff;
		++lines;
		bytes += strlen(str)+1;	/* str + '\n' */
		if(fputs(str,fp) == EOF) {
			...
		}
		fputc('\n',fp);
		lptr = lptr->l_next;
	}

I've tested this version, and haven't run into trouble yet.
Also, this method avoids the strcpy and strcat to the static buffer
in gettxt(), which seem unnecessary (someone correct me if i'm
missing something here).

	Another minor annoyance is the state of the current line
number after global commands - my preference is for the last modified
line to be the new current line. Replacing the return(0) by 
return(curln) at the end of doglob() will produce this behavior.

	dean
-- 
dean@ndmath.UUCP
Dean Alvis, Math. Dept., Univ. of Notre Dame, Notre Dame IN, 46556