Article View: comp.windows.x
Article #36674Re: Does anyone have a fix for R4/PL1 XGetDefault?
From: Casey Leedom
Date: Mon, 12 Feb 1990 06:48
Date: Mon, 12 Feb 1990 06:48
94 lines
3721 bytes
3721 bytes
Well, I didn't get a grand rush of fixes for this problem, so I was
forced to try my own hand at the code. I think I've got an appropriate
fix. It certainly seems to work in any case. I will gladly accept
criticism that will lead to a better fix. This fix is also being send to
xbugs.
Casey
-----
From: casey@gauss.llnl.gov (Casey Leedom)
To: xbugs@expo.lcs.mit.edu
Subject: R4/PL2 XGetDefault doesn't handle complex resource names
-------
VERSION:
R4; fix-1 and fix-2 applied
AREA:
mit/lib/X/XGetDflt.c
SYNOPSIS:
XGetDefault doesn't work 100%. If you attempt to do an XGetDefault(dpy,
prog, "foo.bar"), XGetDefault won't break the string "foo.bar" up into
separate ``Quarks'' and therefore won't match the desired resource.
REPEAT BY:
By inspection. Note that XGetDefault simply passes the ``name''
parameter directly to XrmStringToName without any attempt to break
the string up into it's constituent parts.
SAMPLE FIX:
Not being familiar with this code, I can't make any guarantees about
the appropriateness of my fix. There may be a much better way of
fixing this problem. I particularly don't like the fixed name array
size of 100, but this kind of code permeates the X library, so I
didn't know what to do (I couldn't find an example of how to do it
Right.) On the other hand, the fix does work in all the cases I've
tested ... Buyer beware.
*** mit/lib/X/XGetDflt.c-dist Tue Jan 30 18:35:20 1990
--- mit/lib/X/XGetDflt.c Sun Feb 11 22:32:00 1990
***************
*** 124,134 ****
register char *name; /* name of option program wants */
#endif
{ /* to get, for example, "font" */
! XrmName names[3];
! XrmClass classes[3];
XrmRepresentation fromType;
XrmValue result;
char *progname;
/*
* strip path off of program name (XXX - this is OS specific)
--- 124,136 ----
register char *name; /* name of option program wants */
#endif
{ /* to get, for example, "font" */
! XrmName names[100]; /* 100: YECH -- and XrmStringToNameList */
! XrmClass classes[100]; /* does not even let us pass in this limit */
XrmRepresentation fromType;
XrmValue result;
char *progname;
+ register XrmClass classp;
+ register int i;
/*
* strip path off of program name (XXX - this is OS specific)
***************
*** 150,160 ****
UnlockDisplay(dpy);
names[0] = XrmStringToName(progname);
- names[1] = XrmStringToName(name);
- names[2] = NULLQUARK;
classes[0] = XrmStringToClass("Program");
! classes[1] = XrmStringToClass("Name");
! classes[2] = NULLQUARK;
(void)XrmQGetResource(dpy->db, names, classes, &fromType, &result);
return (result.addr);
}
--- 152,163 ----
UnlockDisplay(dpy);
names[0] = XrmStringToName(progname);
classes[0] = XrmStringToClass("Program");
! XrmStringToNameList(name, &names[1]);
! classp = XrmStringToClass("Name");
! for (i = 1; names[i] != NULLQUARK; i++)
! classes[i] = classp;
! classes[i] = NULLQUARK;
(void)XrmQGetResource(dpy->db, names, classes, &fromType, &result);
return (result.addr);
}
Technical Details
Message-ID:
<48264@lll-winken.LLNL.GOV>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!usc!elroy.jpl.nasa.gov!lll-winken!gauss.llnl.gov!caseyReferences:
<47970@lll-winken.LLNL.GOV>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!usc!elroy.jpl.nasa.gov!lll-winken!gauss.llnl.gov!casey From: casey@gauss.llnl.gov (Casey Leedom) Newsgroups: comp.windows.x Subject: Re: Does anyone have a fix for R4/PL1 XGetDefault? Message-ID: <48264@lll-winken.LLNL.GOV> Date: 12 Feb 90 06:48:30 GMT References: <47970@lll-winken.LLNL.GOV> Sender: usenet@lll-winken.LLNL.GOV Reply-To: casey@gauss.llnl.gov (Casey Leedom) Organization: Lawrence Livermore National Laboratory Lines: 94