[comp.sys.mac] small LSC ControlMgr.h problem

mms@utgpu.UUCP (10/31/87)

A small problem I found while writing my Very First CDEF (in LSC 2.01)...

In the definition of the typedef ControlRecord, field contrlHilite
(among others) is of type char.  If the control is to be inactive,
this field should be set to 255.  Unfortunately, if contrlHilite is
subsequently compared to 255 or 0xff, the code generated sign-extends
contrlHilite but not 255 and therefore does not find them to be equal.

I believe contrlHilite should be of type unsigned char and not char.

John Chew
-- 
john j. chew (v3.0)                       poslfit@gpu.utcs.toronto.edu
+1 416 463 5403 (300/1200 bps)            poslfit@utorgpu.bitnet
{cbosgd,decvax,mnetor,utai,utcsri,{allegra,linus}!utzoo}!utgpu!poslfit
"Script-G for open, sub-delta for durchschnitt"

lippin@wheatena (The Apathist) (11/01/87)

Recently mms@gpu.utcs.UUCP (John J. Chew III) said:
>
>In the definition of the typedef ControlRecord, field contrlHilite
>(among others) is of type char.  If the control is to be inactive,
>this field should be set to 255.  Unfortunately, if contrlHilite is
>subsequently compared to 255 or 0xff, the code generated sign-extends
>contrlHilite but not 255 and therefore does not find them to be equal.
>
>I believe contrlHilite should be of type unsigned char and not char.

That wouldn't hurt (I never cared for sign in chars anyway), but
you should be comparing it to (char)255, as it is a char after all.

					--Tom Lippincott
					..ucbvax!bosco!lippin

"If there were more people like you, there'd be less people like you!"
		--Hawkeye Pierce, of Colonel Flagg, M*A*S*H

dtw@F.GP.CS.CMU.EDU (Duane Williams) (11/01/87)

Both contrlHilite and contrlVis should be declared "Byte".

singer@endor.harvard.edu (Richard Siegel) (11/02/87)

In article <1987Oct30.230309.12490@gpu.utcs.toronto.edu> mms@gpu.utcs.UUCP (John J. Chew III) writes:
>
>A small problem I found while writing my Very First CDEF (in LSC 2.01)...

>I believe contrlHilite should be of type unsigned char and not char.

	This has been noted and fixed; thanks for the correction.

		--Rich

**The opinions stated herein are my own opinions and do not necessarily
represent the policies or opinions of my employer (THINK Technologies, Inc).

* Richard M. Siegel | {decvax, ucbvax, sun}!harvard!endor!singer    *
* Customer Support  | singer@endor.harvard.edu			    *
* Symantec, THINK Technologies Division.  (No snappy quote)         *

raylau@dasys1.UUCP (Raymond Lau) (11/03/87)

In my opinion, I feel that everything documented in IM as a CHAR should be an unsigned char in C.  IM makes no mention of signed char's...and has thus documented the entire OS/Toolbox w/the assumption that all chars are unsigned.  (Well, signed chars don't make much sense in Pascal).  signed chars have caused more than one problem for me in the past...  Why not keep them as unsigned chars?


-----------------------------------------------------------------------------
Raymond Lau                      {allegra,philabs,cmcl2}!phri\
Big Electric Cat Public Unix           {bellcore,cmcl2}!cucard!dasys1!raylau
New York, NY, USA                               {sun}!hoptoad/         
GEnie:RayLau   Delphi:RaymondLau   CIS:76174,2617
"Take it and StuffIt."