Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucla-cs!hilo.cs.ucla.edu!dgreen From: dgreen@hilo.cs.ucla.edu (Dan R. Greening) Newsgroups: comp.windows.x Subject: Bug in Storing non-String types to a resource database? Message-ID: <1991May20.192203.8525@cs.ucla.edu> Date: 20 May 91 19:22:03 GMT Sender: usenet@cs.ucla.edu (Mr. News Himself) Organization: UCLA Computer Science Department Lines: 58 Nntp-Posting-Host: hilo.cs.ucla.edu 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 "!"": " 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