🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #37999

Re: bug in XtGetApplicationResources

#37999
From: Paul Asente
Date: Tue, 13 Mar 1990 02:10
34 lines
1743 bytes
In article <5062@helios.ee.lbl.gov> envbvs@epb2.lbl.gov (Brian V. Smith) writes:
>int     landscape = 1; /******  PROBLEM BECAUSE OF THIS  *****/
>int     RHS_PANEL = 0;
>
>static XtResource application_resources[] = {
>        {XtNjustify, XtCJustify, XtRBoolean, sizeof(int),
>                 (Cardinal)&RHS_PANEL, XtRBoolean, (caddr_t)&false},
>        {"landscape", XtCOrientation, XtRBoolean, sizeof(int),
>                 (Cardinal)&landscape, XtRBoolean, (caddr_t)&true},
>};

This is horribly nonportable and may be your problem.  The offset field, a
Cardinal, is an unsigned int of at least 16 bits.  There's no
guarantee that you can store an address into a Cardinal value without
losing bits or having weird sign extension problems.  You should have

struct _appres {
	int     landscape;
	int     RHS_PANEL;
} appres;

static XtResource application_resources[] = {
	{XtNjustify, XtCJustify, XtRInt, sizeof(int),
	     XtOffset((struct _appres *), RHS_PANEL),
	     XtRInt, (caddr_t)&false},
...

And you pass &appres to XtGetApplicationResources as the base.

Notice that I also changed the XtRBooleans to XtRInts to match the data
declarations.  Either or both of these could be your problem.

	-paul asente
	    asente@decwrl.dec.com	decwrl!asente
Technical Details
Message-ID: <3004@bacchus.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!asente
References: <5061@helios.ee.lbl.gov> <5062@helios.ee.lbl.gov>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!asente
From: asente@decwrl.dec.com (Paul Asente)
Newsgroups: comp.windows.x
Subject: Re: bug in XtGetApplicationResources
Keywords: incorrect parsing of resources on sun 4
Message-ID: <3004@bacchus.dec.com>
Date: 13 Mar 90 02:10:10 GMT
References: <5061@helios.ee.lbl.gov> <5062@helios.ee.lbl.gov>
Organization: DEC Western Software Lab
Lines: 34