rhl@grendel.Princeton.EDU (Robert Lupton (the Good)) (03/09/91)
With the MIT X11R4 server, passing a garbage XrmDatabase to XrmParseCommand
causes a bus error (NULL is OK). As XrmParseCommand is supposed to set
rather than modify a database this is a little surprising (I imagine
that it is cleaning up), and doesn't appear to be documented.
This was a nasty bug to find --- it depended on the state of the stack left
by the main programme that this was a subroutine of.
Robert
/********************************************************************/
#include <X11/Xlib.h>
#include <X11/Xresource.h>
static XrmOptionDescRec options[] = {
{"-display", ".display", XrmoptionSepArg, NULL},
};
int
main(ac,av)
int ac;
char *av[];
{
char *option_type;
XrmDatabase args_db;
XrmValue value;
XrmInitialize();
args_db = (XrmDatabase)1; /* point somewhere illegal... */
XrmParseCommand(&args_db,options,1,av[0],&ac,av);
XrmGetResource(args_db,"foo.display","",&option_type,&value);
return(0);
}rws@expo.lcs.mit.EDU (Bob Scheifler) (03/09/91)
As XrmParseCommand is supposed to set rather than modify a database What aspect of the (official) documentation implies this to you? In the Xlib manual, the beginning of section 10.11.4, it says "modify a resource database". The description of the database argument is given as "Specifies the resource database.", not "Returns a newly created resource database.". The following paragraph says "loads recognized options into the specified database". It all sounds to me like you're supposed to pass in a valid database.