SCO's curses

Larry Philps larryp at sco.COM
Wed Apr 17 04:50:25 AEST 1991


In <1991Apr16.010851.6047 at NCoast.ORG> allbery at NCoast.ORG (Brandon S. Allbery KB8JRR/AA) writes:

> 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.

There is a compiler option (documented), -J, that will cause the compiler
to change the default type of char from signed to unsigned.  This should
also fix things.

---
Larry Philps,	 SCO Canada, Inc (Formerly: HCR Corporation)
Postman:  130 Bloor St. West, 10th floor, Toronto, Ontario.  M5S 1N5
InterNet: larryp at sco.COM  or larryp%scocan at uunet.uu.net
UUCP:	 {uunet,utcsri,sco}!scocan!larryp
Phone:	 (416) 922-1937
Fax:	 (416) 922-8397



More information about the Comp.unix.sysv386 mailing list