From: Matthew E. <ma...@gs...> - 2002-03-08 08:59:47
|
> At 08:40 PM 2002-03-05 -0500, P. McBride wrote: > >gedlib/charmaps.c > > > > The array bounds for tran_tables[] should be > > explicitly set rather than depending on the > > initializers. > > > > TRANTABLE tran_tables[] = { > > > > should be changed to: > > > > TRANTABLE tran_tables[NUM_TT_MAPS] = { > > > > Similarly for map_names, and map_keys. > > Or some other change should be made to > > init_mapping() so that the array bounds > > are not exceeded. > > > >-- > >Paul B. McBride (pbm...@rc...) > >http://homepages.rootsweb.com/~pmcbride/index.htm > > > > > > > >_______________________________________________ > >Lifelines-dev mailing list > >Lif...@li... > >https://lists.sourceforge.net/lists/listinfo/lifelines-dev > > > How about > in init_mapping > > /* NUM_TT_MAPS must correspond to #entries in tran_tables */ > ASSERT(sizeof(tran_tables)/sizeof(tran_tables[0]) == NUM_TT_MAPS); > > ? Could we not create a new structure containing a map name, map key and a pointer to a TRANTABLE? The map name/key are only used to reference a TRANTABLE, so it makes sence to have them all together. We'd then have to change all references to map_names (2 places), map_key (3 places) and tran_table (52 places) to point to the proper element in the new structure. I think this is a lot cleaner and more efficient It would probably make sense to change the map keys to something more descriptive, while we're working on changing things. For example: enum { TT_EDITOR_INTERNAL, TT_INTERNAL_EDITOR, TT_GEDCOM_INTERNAL, TT_INTERNAL,GEDCOM, TT_DISPLAY_INTERNAL, TT_INTERNAL_DISPLAY, TT_INTERNAL_REPORT, TT_SORT, TT_CHAR, TT_LOWERCASE, TT_UPPERCASE, TT_PREF, TT_NUM }; struct { char *name; int key; TRANTABLE *table; } tran_tables[TT_NUM] = { { "Editor to Internal", TT_DISPLAY_INTERNAL, NULL }, { "Internal to Editor", TT_INTERNAL_DISPLAY, NULL }, { "GEDCOM to Internal", TT_GEDCOM_INTERNAL, NULL }, { "Internal to GEDCOM", TT_INTERNAL_GEDCOM, NULL }, { "Display to Internal", TT_DISPLAY_INTERNAL, NULL }, { "Internal to Display", TT_INTERNAL_DISPLAY, NULL }, { "Internal to Report", TT_INTERNAL_REPORT, NULL }, { "Sort Order", TT_SORT, NULL }, { "Character", TT_CHAR, NULL }, { "Lowercase", TT_LOWERCASE, NULL }, { "Pref", TT_PREF, NULL }, }; -- Matt Emmerton |