audit, index, search, upgrade: use foreach_array_item
parent
59d15ab259
commit
edf03b155b
|
@ -195,12 +195,11 @@ recurse_check:
|
|||
atctx->pathlen--;
|
||||
} else {
|
||||
struct apk_db_file *dbf;
|
||||
struct apk_protected_path_array *ppaths = dir->protected_paths;
|
||||
int i, protected = dir->protected, symlinks_only = dir->symlinks_only;
|
||||
struct apk_protected_path *ppath;
|
||||
int protected = dir->protected, symlinks_only = dir->symlinks_only;
|
||||
|
||||
/* inherit file's protection mask */
|
||||
for (i = 0; i < ppaths->num; i++) {
|
||||
struct apk_protected_path *ppath = &ppaths->item[i];
|
||||
foreach_array_item(ppath, dir->protected_paths) {
|
||||
char *slash = strchr(ppath->relative_pattern, '/');
|
||||
if (slash == NULL) {
|
||||
if (fnmatch(ppath->relative_pattern, name, FNM_PATHNAME) != 0)
|
||||
|
|
|
@ -92,7 +92,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
|
|||
struct counts counts = {0};
|
||||
struct apk_ostream *os;
|
||||
struct apk_file_info fi;
|
||||
int total, r, i, j, found, newpkgs = 0, errors = 0;
|
||||
int total, r, i, found, newpkgs = 0, errors = 0;
|
||||
struct index_ctx *ictx = (struct index_ctx *) ctx;
|
||||
struct apk_package *pkg;
|
||||
|
||||
|
@ -119,6 +119,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
|
|||
|
||||
found = FALSE;
|
||||
do {
|
||||
struct apk_provider *p;
|
||||
struct apk_name *name;
|
||||
char *fname, *fend;
|
||||
apk_blob_t bname, bver;
|
||||
|
@ -145,8 +146,8 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
|
|||
if (name == NULL)
|
||||
break;
|
||||
|
||||
for (j = 0; j < name->providers->num; j++) {
|
||||
pkg = name->providers->item[j].pkg;
|
||||
foreach_array_item(p, name->providers) {
|
||||
pkg = p->pkg;
|
||||
if (pkg->name != name)
|
||||
continue;
|
||||
if (apk_blob_compare(bver, *pkg->version) != 0)
|
||||
|
|
12
src/search.c
12
src/search.c
|
@ -119,16 +119,14 @@ static void print_result_pkg(struct search_ctx *ctx, struct apk_package *pkg)
|
|||
|
||||
static void print_result(struct search_ctx *ctx, struct apk_name *name)
|
||||
{
|
||||
int i;
|
||||
struct apk_provider *p;
|
||||
struct apk_package *pkg = NULL;
|
||||
apk_blob_t *version = NULL;
|
||||
|
||||
if (ctx->show_all) {
|
||||
for (i = 0; i < name->providers->num; i++)
|
||||
print_result_pkg(ctx, name->providers->item[i].pkg);
|
||||
foreach_array_item(p, name->providers)
|
||||
print_result_pkg(ctx, p->pkg);
|
||||
} else {
|
||||
struct apk_package *pkg = NULL;
|
||||
struct apk_provider *p;
|
||||
apk_blob_t *version = NULL;
|
||||
|
||||
foreach_array_item(p, name->providers) {
|
||||
if (version == NULL ||
|
||||
apk_version_compare_blob(*p->version, *version) == APK_VERSION_GREATER)
|
||||
|
|
|
@ -89,8 +89,9 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
|
|||
{
|
||||
struct upgrade_ctx *uctx = (struct upgrade_ctx *) ctx;
|
||||
unsigned short solver_flags;
|
||||
struct apk_dependency *dep;
|
||||
struct apk_dependency_array *world = NULL;
|
||||
int i, r;
|
||||
int r;
|
||||
|
||||
if (apk_db_check_world(db, db->world) != 0) {
|
||||
apk_error("Not continuing with upgrade due to missing repository tags. Use --force to override.");
|
||||
|
@ -106,8 +107,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
|
|||
|
||||
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
||||
apk_dependency_array_copy(&world, db->world);
|
||||
for (i = 0; i < world->num; i++) {
|
||||
struct apk_dependency *dep = &world->item[i];
|
||||
foreach_array_item(dep, world) {
|
||||
if (dep->result_mask == APK_DEPMASK_CHECKSUM) {
|
||||
dep->result_mask = APK_DEPMASK_ANY;
|
||||
dep->version = apk_blob_atomize(APK_BLOB_NULL);
|
||||
|
|
Loading…
Reference in New Issue