Word wrap fix for MicroEMACS

willcox at ccvaxa.UUCP willcox at ccvaxa.UUCP
Sun Jan 5 07:10:00 AEST 1986


The "wordwrap" routine in file word.c in the distribution of MicroEMACS
is broken.  In particular, it breaks if the last word you typed had only
one character.  Also, it used NULL, where FALSE was correct.  The following
works much better.

----------------- wrapword(n), from word.c ------------------
wrapword(n)
int n;
{
	register int cnt;
	register LINE *oldp;
	int onech;
        oldp = curwp->w_dotp;
        cnt = -1;
        do {                            
                cnt++;
                if (! backchar(FALSE, 1))
                        return(FALSE);
        } while (! inword());

	if (! backchar (FALSE, 1)) 	/* back over last char of word */
		return (FALSE);

	onech = !inword();		/* remember if one-char word */
	if (! forwchar (FALSE, 1))	/* return to end of word */
		return (FALSE);

	if (!onech) {			/* multi-letter word, back over
					   whole thing */
		if (! backword (FALSE, 1))
			return (FALSE);
	}

        if ((oldp == curwp->w_dotp) && curwp->w_doto) {
                if (! backdel(FALSE, 1))
                        return(FALSE);
                if (! newline(FALSE, 1))
                        return(FALSE);
        }
        return(forwword(FALSE, 1) && forwchar(FALSE, cnt)));
}
--------------------------- END --------------------------
David A. Willcox
Gould CSD-Urbana
1101 E. University Ave.
Urbana, IL 61801
217-384-8500
{decvax!pur-ee,ihnp4}!uiucdcs!ccvaxa!willcox



More information about the Comp.sources.bugs mailing list