dgreen@hilo.cs.ucla.edu (Dan R. Greening) (05/21/91)
In digging around X11R4/mit/lib/X/Xrm.c, trying to figure out what the resource database does when someone wants to write a non-String typed entry to a file, I came across this piece of code: [if a string then do something] } else { (void) fprintf(stream, "!%s:\t", XrmRepresentationToString(type)); for (i = 0; i < value->size; i++) (void) fprintf(stream, "%02x", (int) value->addr[i]); if (index(value->addr, '\n')) { (void) fprintf(stream, ":\t\\\n"); for (i = 0; value->addr[i]; i++) { if (value->addr[i] == '\n') { (void) fprintf(stream, "\\n"); if (value->addr[i+1]) (void) fprintf(stream, "\\"); (void) fprintf(stream, "\n"); } else { (void) putc(value->addr[i], stream); } } } } else { (void) fprintf(stream, ":\t%s\n", value->addr); } Basically, I think this is probably a bug that nobody has encountered yet. It looks like when a non String-type entry is found, it is written out as <resource-name>"!"<resource-type>": "<hex-representation-for-resource> <string-representation-for-resource-including-nulls> Which is pretty weird. The fix is easy, just replace it with } else { (void) fprintf(stream, "!%s:\t", XrmRepresentationToString(type)); for (i = 0; i < value->size; i++) (void) fprintf(stream, "%02x", (int) value->addr[i]); (void) fprintf(stream, "\n"); } Unfortunately, though one can write out non-String values to a resource file, you can't read them back in! Since PutLineResources uses this to insert the line: XrmQPutResource(pdb, bindings, quarks, XrmQString, &value); Clearly, no fix to allow reading of non-String resources will be made to X11R4. It does seem apparent to me that the resource database routines were intended to handle non-String values (by the simple reason that there is a "type" field in all the Put/Get calls to the resource manager), but these were never fully implemented. Will this be in X11R5? (plead, plead). I could very happily make use of them. -- ____ \ /Dan Greening Software Transformation 1601 Saratoga-Sunnyvale Rd \/ dgreen@cs.ucla.edu (408) 973-8081 x313 Cupertino, CA 95014
rws@expo.lcs.mit.EDU (Bob Scheifler) (05/28/91)
Basically, I think this is probably a bug that nobody has encountered yet. It has been seen before, and "fixed" for R5. Unfortunately, though one can write out non-String values to a resource file, you can't read them back in! You can't write them out in a reasonable fashion either. A hex dump is not very satisfactory, and endian problems, etc. It does seem apparent to me that the resource database routines were intended to handle non-String values (by the simple reason that there is a "type" field in all the Put/Get calls to the resource manager), but these were never fully implemented. I'd say rather it's apparent resource databases were never intended to handle non-String values, but there remain remnants of an incompletely-conceived attempt. :-) Will this be in X11R5? Since you (nor anyone else) have made no (reasonable :-) proposal, and it's too late, nothing will change for R5.