diff options
author | Timo Teräs <timo.teras@iki.fi> | 2023-03-04 13:54:54 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2023-03-06 21:39:48 +0200 |
commit | 65b46f7462e1acad19884da67a9a59996a642847 (patch) | |
tree | 1997054daa45211d97bc273f0a50ccdfe2084ff5 /src/app_version.c | |
parent | 5f84463a34bd8c63a3ff649ae550c68934adaa5b (diff) | |
download | apk-tools-65b46f7462e1acad19884da67a9a59996a642847.tar.gz apk-tools-65b46f7462e1acad19884da67a9a59996a642847.tar.bz2 apk-tools-65b46f7462e1acad19884da67a9a59996a642847.tar.xz apk-tools-65b46f7462e1acad19884da67a9a59996a642847.zip |
db, apps: sort display results based on package names
Diffstat (limited to 'src/app_version.c')
-rw-r--r-- | src/app_version.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/app_version.c b/src/app_version.c index a42ab63..9c80736 100644 --- a/src/app_version.c +++ b/src/app_version.c @@ -109,7 +109,7 @@ static const struct apk_option_group optgroup_applet = { .parse = option_parse_applet, }; -static void ver_print_package_status(struct apk_database *db, const char *match, struct apk_name *name, void *pctx) +static int ver_print_package_status(struct apk_database *db, const char *match, struct apk_name *name, void *pctx) { struct apk_out *out = &db->ctx->out; struct ver_ctx *ctx = (struct ver_ctx *) pctx; @@ -122,10 +122,10 @@ static void ver_print_package_status(struct apk_database *db, const char *match, int i, r = -1; unsigned short tag, allowed_repos; - if (!name) return; + if (!name) return 0; pkg = apk_pkg_get_installed(name); - if (!pkg) return; + if (!pkg) return 0; tag = pkg->ipkg->repository_tag; allowed_repos = db->repo_tags[tag].allowed_repos; @@ -151,10 +151,10 @@ static void ver_print_package_status(struct apk_database *db, const char *match, : APK_VERSION_UNKNOWN; opstr = apk_version_op_string(r); if ((ctx->limchars != NULL) && (strchr(ctx->limchars, *opstr) == NULL)) - return; + return 0; if (apk_out_verbosity(out) <= 0) { apk_out(out, "%s", pkg->name->name); - return; + return 0; } tag = APK_DEFAULT_REPOSITORY_TAG; @@ -170,6 +170,7 @@ static void ver_print_package_status(struct apk_database *db, const char *match, pkgname, opstr, BLOB_PRINTF(*latest), BLOB_PRINTF(db->repo_tags[tag].tag)); + return 0; } static int ver_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *args) @@ -190,10 +191,7 @@ static int ver_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *arg apk_msg(out, "%-42s%s", "Installed:", "Available:"); - apk_name_foreach_matching( - db, args, APK_FOREACH_NULL_MATCHES_ALL | apk_foreach_genid(), - ver_print_package_status, ctx); - + apk_db_foreach_sorted_name(db, args, ver_print_package_status, ctx); return 0; } |