From 8fddaf22a7ccdddebc3e3ff416bf0b8ef759e22c Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 11 Mar 2008 16:48:20 -0400 Subject: [PATCH] fix generated provides of files provided by more than one package (uniqueify_properties() assumes that each property only belongs to a single package, so our previous strategy of generating a single property with an indirect package list wouldn't work.) --- razor.c | 40 +++++++++++++++++----------------------- 1 files changed, 17 insertions(+), 23 deletions(-) diff --git a/razor.c b/razor.c index 2682d85..0e28604 100644 --- a/razor.c +++ b/razor.c @@ -753,9 +753,10 @@ find_file_provides(struct razor_importer *importer) struct razor_property *prop; struct razor_entry *top, *entry; struct razor_package *packages; - struct array pkgarray, pkgprops; - uint32_t *req, *req_start, *req_end, *pkg, *pkg_end; - uint32_t *map, newprop_id, *newprop; + struct array pkgprops; + struct list *pkg; + uint32_t *req, *req_start, *req_end; + uint32_t *map, *newprop; char *pool; pool = importer->set->string_pool.data; @@ -772,31 +773,24 @@ find_file_provides(struct razor_importer *importer) if (req > req_start && req[0] == req[-1]) continue; entry = find_entry(importer->set, top, &pool[*req]); - if (entry) { + if (!entry) + continue; + + for (pkg = list_first(&entry->packages, &importer->set->package_pool); pkg; pkg = list_next(pkg)) { prop = array_add(&importer->set->properties, sizeof *prop); prop->name = *req; prop->type = RAZOR_PROPERTY_PROVIDES; prop->relation = RAZOR_VERSION_EQUAL; prop->version = hashtable_tokenize(&importer->table, ""); - - /* Copy package list from entry to property */ - array_init(&pkgarray); - list_to_array(list_first(&entry->packages, &importer->set->package_pool), &pkgarray); - list_set_array(&prop->packages, &importer->set->package_pool, &pkgarray, 0); - - /* Update property list of each providing package */ - pkg_end = pkgarray.data + pkgarray.size; - newprop_id = prop - (struct razor_property *)importer->set->properties.data; - - for (pkg = pkgarray.data; pkg < pkg_end; pkg++) { - array_init(&pkgprops); - list_to_array(list_first(&packages[*pkg].properties, &importer->set->property_pool), &pkgprops); - newprop = array_add(&pkgprops, sizeof *newprop); - *newprop = newprop_id; - list_set_array(&packages[*pkg].properties, &importer->set->property_pool, &pkgprops, 1); - array_release(&pkgprops); - } - array_release(&pkgarray); + list_set_ptr(&prop->packages, pkg->data); + + /* Update property list of pkg */ + array_init(&pkgprops); + list_to_array(list_first(&packages[pkg->data].properties, &importer->set->property_pool), &pkgprops); + newprop = array_add(&pkgprops, sizeof *newprop); + *newprop = prop - (struct razor_property *)importer->set->properties.data; + list_set_array(&packages[pkg->data].properties, &importer->set->property_pool, &pkgprops, 1); + array_release(&pkgprops); } } -- 1.7.1