xbps-repo: faster 'genindex' target implementation for index-files.plist.

This commit is contained in:
Juan RP
2012-01-17 10:50:35 +01:00
parent 4164573b35
commit beb7284681
5 changed files with 214 additions and 59 deletions

View File

@@ -105,6 +105,37 @@ xbps_find_pkg_in_array_by_pattern(prop_array_t array, const char *pattern)
return find_pkg_in_array(array, pattern, true, false);
}
prop_dictionary_t
xbps_find_pkg_in_array_by_pkgver(prop_array_t array, const char *pkgver)
{
prop_object_iterator_t iter;
prop_object_t obj = NULL;
const char *rpkgver;
bool found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(pkgver != NULL);
iter = prop_array_iterator(array);
if (iter == NULL)
return NULL;
while ((obj = prop_object_iterator_next(iter))) {
if (!prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &rpkgver))
continue;
if (strcmp(pkgver, rpkgver) == 0) {
found = true;
break;
}
}
prop_object_iterator_release(iter);
if (found)
return obj;
return NULL;
}
prop_dictionary_t
xbps_find_virtualpkg_in_array_by_name(prop_array_t array, const char *name)
{

View File

@@ -82,6 +82,14 @@ remove_string_from_array(prop_array_t array, const char *str, int mode)
found = true;
break;
}
} else if (mode == 3) {
/* match by pkgver, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname);
if (strcmp(curname, str) == 0) {
found = true;
break;
}
}
idx++;
}
@@ -114,6 +122,12 @@ xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *name)
return remove_string_from_array(array, name, 2);
}
bool
xbps_remove_pkg_from_array_by_pkgver(prop_array_t array, const char *pkgver)
{
return remove_string_from_array(array, pkgver, 3);
}
bool
xbps_remove_pkg_from_dict_by_name(prop_dictionary_t dict,
const char *key,