4.2 TSET minor bug fix - (nf)

liberte at uiucdcs.UUCP liberte at uiucdcs.UUCP
Wed Apr 18 17:49:00 AEST 1984


#R:parsec:33500002:uiucdcs:8200017:000:776
uiucdcs!liberte    Apr 18 01:49:00 1984

/**** uiucdcs:net.bugs.4bsd / uiuccsb!emrath /  9:25 pm  Apr 10, 1984 ****/
You won't be able to use 'tset -e^?' to use rubout for erasing.
Some people have been known to do this.  How 'bout?
#define CTRL(x)	((x) & ~((x) >> 1 & 040) ^ 0100)	/* P.U. */
	or
#define CTRL(x) ((x) & 0100 ? (x) &~ 0140 : (x) | 0100)
/* ---------- */

These two attempts fail because of actual parameter evaluation side effects,
i.e. the flag pointer is incremented.  One fix is to change the macro calls.
My fix is to use the parameter only once.  This will work on 2s complement
machines (like VAX).

# define	CTRL(x)		(((((x) + 1) &~ 0140) - 1) & 0177)
/* is it worth it? */

Daniel LaLiberte,  U of Illinois, Urbana-Champaign, Computer Science
{moderation in all things - including moderation}



More information about the Comp.bugs.4bsd.ucb-fixes mailing list