[net.bugs.4bsd] 4.2 TSET minor bug fix

hosking@parsec.UUCP (04/10/84)

#N:parsec:33500002:000:250
parsec!hosking    Apr 10 00:00:00 1984

The following is a minor bug fix for 4.2 TSET.  The original code would
produce odd results if you typed something like:
tset -k^u (as opposed to ^U).


OLD:	#define	CTRL(x)		(x ^ 0100)

NEW:	#define CTRL(x)		(x & ~0140)

					allegra!convex!hosking

emrath@uiuccsb.UUCP (04/11/84)

#R:parsec:33500002:uiuccsb:6300008:000:478
uiuccsb!emrath    Apr 10 21:25:00 1984

>  The following is a minor bug fix for 4.2 TSET.  The original code would
>  produce odd results if you typed something like:
>  tset -k^u (as opposed to ^U).
>
>  OLD:	#define	CTRL(x)		(x ^ 0100)
>
>  NEW:	#define CTRL(x)		(x & ~0140)


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)

liberte@uiucdcs.UUCP (04/18/84)

#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}