Magic Mailing List |
|
From: R. Timothy Edwards (tim AT stravinsky DOT jhuapl.edu) Date: Mon Mar 04 2002 - 09:33:29 EST
Dear Jeff, Prakash Chand pointed out to me an error that I initially blamed on "readline" but eventually decided stems from your cellname completion function code. Prakash writes: > If you take a cif file, do a "cif read" on it, then type "load" and > hit the Tab button to prompt for the cell names, Magic crashes. Magic crashes at txInput.c, line 700, inside "cellname_completion_function": /* Also complete cells that are in main memory only */ while( (he = HashNext(&dbCellDefTable, &db_hs)) != (HashEntry *)NULL ) { CellDef *cd = (CellDef *)HashGetValue(he); if( !(cd->cd_flags & CDINTERNAL) && strcmp(cd->cd_name, UNNAMED) != 0 && strncmp(cd->cd_name, text, len) == 0 ) { return strdup(cd->cd_name); } } HashGetValue(he) returns cd=NULL, which causes the crash at line 700. I am skeptical of the update_cellname_hash() routine, which appears to collect a list of cells by doing a directory list of the directories in the search path. This method ignores the fact that the magic "load" command first looks at the internal database of cells before trying to load from a path. So I think what is happening is that by reading "foo.cif" first, is that the cells exist only in internal memory, and there may not be ANY .mag files in the search path, leading to an empty hash table which apparently returns a NULL result (though I'm not sure why it would do that, but I guess that HashInit puts some kind of entry). Bottom line is, the routines need two corrections: 1) NULL return from HashFind should be ignored (or alternately, HashInit should not be executed until something exists to be put in the hash table; ignoring NULL is a lot easier to implement), and 2) update_cellname_hash should look through the internal cell database as well as the directories in the search path. Regards, Tim
|
|