Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 930) +++ trunk/src/buffer.c (revision 931) @@ -525,222 +525,11 @@ * into the buffer. */ -/* Figuring out which library entry is the one we want is a little - tricky. For file-based footprints, it's just a matter of finding - the first match in the search list. For m4-based footprints you - need to know what magic to pass to the m4 functions. Fortunately, - the footprint needed is determined when we build the m4 libraries - and stored as a comment in the description, so we can search for - that to find the magic we need. We use a hash to store the - corresponding footprints and pointers to the library tree so we can - quickly find the various bits we need to load a given - footprint. */ - -typedef struct { - char *footprint; - int footprint_allocated; - int menu_idx; - int entry_idx; -} FootprintHashEntry; - -static FootprintHashEntry *footprint_hash = 0; -int footprint_hash_size = 0; - -void -clear_footprint_hash () -{ - int i; - if (!footprint_hash) - return; - for (i=0; ifootprint, b->footprint); - if (i == 0) - i = a->menu_idx - b->menu_idx; - if (i == 0) - i = a->entry_idx - b->entry_idx; - return i; -} - -void -make_footprint_hash () -{ - int i, j; - char *fp; - int num_entries = 0; - - clear_footprint_hash (); - - for (i=0; i 1) - { - i = (min+max)/2; - c = strcmp (footprint, footprint_hash[i].footprint); - if (c < 0) - max = i; - else if (c > 0) - min = i; - else - { - /* We want to return the first match, not just any match. */ - while (i > 0 - && strcmp (footprint, footprint_hash[i-1].footprint) == 0) - i--; - return & footprint_hash[i]; - } - } - return NULL; -} - /* Returns zero on success, non-zero on error. */ int LoadFootprintByName (BufferTypePtr Buffer, char *Footprint) { - int i; - FootprintHashEntry *fpe; - LibraryMenuType *menu; - LibraryEntryType *entry; - char *with_fp = NULL; - - if (!footprint_hash) - make_footprint_hash (); - - fpe = search_footprint_hash (Footprint); - if (!fpe) - { - with_fp = Concat (Footprint, ".fp", NULL); - fpe = search_footprint_hash (with_fp); - if (fpe) - Footprint = with_fp; - } - if (!fpe) - { - Message("Unable to load footprint %s\n", Footprint); - return 1; - } - - menu = & Library.Menu[fpe->menu_idx]; - entry = & menu->Entry[fpe->entry_idx]; - - i = LoadElementToBuffer (Buffer, entry->AllocatedMemory); - if (with_fp) - free (with_fp); - return i ? 0 : 1; - -#ifdef DEBUG - { - int j; - printf("Library search paths: %s\n", Settings.LibrarySearchPaths); - - printf("Library:\n"); - for (i=0; i