mcdaniel@adi.com (Tim McDaniel) (08/15/90)
According to the "Xlib Programming Manual for Version 11", Volume 1, Adrian Nye, O'Reilly & Associates, Inc., section 11.4.3 (and in other manuals), there are certain precedence rules for querying a resource database for a particular instance name/class name pair. In particular, rules 2 and 3 are: 2. Database entries with instance or class prefixed by a dot (.) are more specific than those preceded by an asterisk (*). 3. Instances are more specific than classes. According to these precedence rules, a query for "foo.bar"/"Foo.Bar" with a database containing .Foo.bar: Good *foo.bar: Bad should match the "Good" line, I think: rule 2 says that the tight match on ".Foo" should take precedence over the loose match on "*foo". However, since the "rules" are clear as mud (take rule 1: whatinthe- hell is an "attribute"?), and I couldn't see how to implement them, I read the source for XrmGetResource. It is in ~x11/src/mit/lib/X/Xrm.c on my system. It calls GetEntry, a static function, to do the work. GetEntry essentially begins with /* Check very first name & class in both tight and loose tables */ name = *names; if (tight != NULL) GetEntryLookup(tight, name); if (loose != NULL) GetEntryLookup(loose, name); /*A*/ class = *classes; if (tight != NULL) GetEntryLookup(tight, class); /*B*/ if (loose != NULL) GetEntryLookup(loose, class); where "names" is an array representing the components of the instance name to be retrieved, and "classes" is an array representing the components of the class name. "tight" is the set of possible "tight binding" matches at this level, as in ".a", and "loose" is the set of possible "loose bindings" at this level, as in "*a". GetEntryLookup causes the lookup process to stop when a match is found. The problem, I think, is with the lines marked A and B. It appears to check for a loose match on the instance name before checking for a tight match on the class name. So the example above would retrieve the "Bad" line. Perhaps the code should be name = *names; class = *classes; if (tight != NULL) GetEntryLookup(tight, name); if (tight != NULL) GetEntryLookup(tight, class); /*B*/ if (loose != NULL) GetEntryLookup(loose, name); /*A*/ if (loose != NULL) GetEntryLookup(loose, class); ? I don't have the time or inclination to actually run a test program on this. I'm not an X programmer, or even an X user. I'm just interested in configuration files, and I wanted to know how X dealt with the problem. But I thought that people ought to know about my hypothesis, in case it is indeed a problem. Perhaps someone could write a test program? -- -- Tim McDaniel Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel