diff --git a/src/headerlist.c b/src/headerlist.c index dabf987..f8bc454 100644 --- a/src/headerlist.c +++ b/src/headerlist.c @@ -432,52 +432,51 @@ struct providedList* findOrCreateProvidedListEntry(struct providedList* *idx, char* findname, int create, int arch) { - struct providedList *newprovided, *currprovided, *prevprovided = NULL; - int c = 0, i; - int idxbot = 0, idxtop; + struct providedList *newprovided, *currprovided, *prevprovided = NULL; + int c = 0, i; + int idxbot = 0, idxtop; - if (idx[1]) { - idxtop = PROVIDEDLIST_IDX_SIZE; - while (idxtop-idxbot > 1) { - i = (idxtop + idxbot) / 2; - if (! idx[i]) idxtop = i; - else { - c = strcmp(idx[i]->name,findname); - if (c < 0) idxbot = i; - else if (c > 0) idxtop = i; - else { idxbot = i-1; idxtop = i; } - } - } -// printf("idxbot=%d idxtop=%d %s %s\n",idxbot,idxtop,idx[idxbot]->name,findname); - } + if (idx[1]) { + idxtop = PROVIDEDLIST_IDX_SIZE; + while (idxtop-idxbot > 1) { + i = (idxtop + idxbot) / 2; + if (! idx[i]) idxtop = i; + else { + c = strcmp(idx[i]->name,findname); + if (c < 0) idxbot = i; + else if (c > 0) idxtop = i; + else { idxbot = i-1; idxtop = i; } + } + } + //printf("idxbot=%d idxtop=%d %s %s\n",idxbot,idxtop,idx[idxbot]->name,findname); + } - currprovided = idx[idxbot]; - while (currprovided && ((c=strcmp(currprovided->name,findname)) < 0)) { - prevprovided = currprovided; - currprovided = currprovided->next; - } + currprovided = idx[idxbot]; + while (currprovided && ((c=strcmp(currprovided->name,findname)) < 0)) { + prevprovided = currprovided; + currprovided = currprovided->next; + } - if ((!currprovided) || (c > 0)) { - if (!create) return NULL; - providedListCount[arch]++; - newprovided = malloc(sizeof(struct providedList)); - if (prevprovided) { - newprovided->next = prevprovided->next; - prevprovided->next = newprovided; - } else { - idx[0]=newprovided; - newprovided->next = currprovided; - } - newprovided->provider = NULL; - newprovided->numproviders = 0; - newprovided->numbuildproviders = 0; - newprovided->buildprovider = NULL; - newprovided->name = strdup(findname); - newprovided->id = ++providedListId; - return newprovided; - } - - return currprovided; + if ((!currprovided) || (c > 0)) { + if (!create) return NULL; + providedListCount[arch]++; + newprovided = malloc(sizeof(struct providedList)); + if (prevprovided) { + newprovided->next = prevprovided->next; + prevprovided->next = newprovided; + } else { + idx[0]=newprovided; + newprovided->next = currprovided; + } + newprovided->provider = NULL; + newprovided->numproviders = 0; + newprovided->numbuildproviders = 0; + newprovided->buildprovider = NULL; + newprovided->name = strdup(findname); + newprovided->id = ++providedListId; + return newprovided; + } + return currprovided; } struct fileTree*