SCO's curses

Brandon S. Allbery KB8JRR/AA allbery at NCoast.ORG
Tue Apr 16 11:08:51 AEST 1991


As quoted from <1991Apr11.022708.11563 at sobeco.com> by mfp at sobeco.com (m.proudman):
+---------------
| int c;
| addch((chtype)(c&0377));
| 
| and also:
| 
| char * p;
| addch((chtype)((*p)&0377));
| 
| I experienced problems similar to yours, and came up with this after
| a bit of playing.  Perhaps someone can give a complete explanation as
| to why it works.
+---------------

(char) is signed on 386/486 processors.  So, (char) 0200 gets sign-extended to
a (chtype) (actually, a (long)) with all the attribute bits set and probably
some wild color specifications as well.  Either mask against 0377 (or 0xFF,
same thing --- or even 255) or use (unsigned char) types.

++Brandon
-- 
Me: Brandon S. Allbery			  Ham: KB8JRR/AA on 2m, 220, 440, 1200
Internet: allbery at NCoast.ORG		(QRT on HF until local problems fixed)
America OnLine: KB8JRR // Delphi: ALLBERY   AMPR: kb8jrr.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery          KB8JRR @ WA8BXN.OH



More information about the Comp.unix.sysv386 mailing list