summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app_search.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/app_search.c b/src/app_search.c
index 3651ec6..fd9bd40 100644
--- a/src/app_search.c
+++ b/src/app_search.c
@@ -92,7 +92,6 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt
break;
case OPT_SEARCH_description:
ictx->search_description = 1;
- ictx->search_exact = 1;
ictx->show_all = 1;
break;
case OPT_SEARCH_exact:
@@ -126,15 +125,16 @@ static void print_result_pkg(struct search_ctx *ctx, struct apk_package *pkg)
if (ctx->search_description) {
foreach_array_item(pmatch, ctx->filter) {
- if (strstr(pkg->description, *pmatch) != NULL ||
- strstr(pkg->name->name, *pmatch) != NULL)
+ if (fnmatch(*pmatch, pkg->description, 0) == 0 ||
+ fnmatch(*pmatch, pkg->name->name, 0) == 0)
goto match;
}
return;
}
if (ctx->search_origin) {
foreach_array_item(pmatch, ctx->filter) {
- if (pkg->origin && apk_blob_compare(APK_BLOB_STR(*pmatch), *pkg->origin) == 0)
+ if (!pkg->origin) continue;
+ if (apk_blob_compare(APK_BLOB_STR(*pmatch), *pkg->origin) == 0)
goto match;
}
return;
@@ -166,12 +166,6 @@ static int print_result(struct apk_database *db, const char *match, struct apk_n
return 0;
}
-static int print_pkg(apk_hash_item item, void *pctx)
-{
- print_result_pkg((struct search_ctx *) pctx, (struct apk_package *) item);
- return 0;
-}
-
static int search_main(void *pctx, struct apk_database *db, struct apk_string_array *args)
{
struct search_ctx *ctx = (struct search_ctx *) pctx;
@@ -184,8 +178,11 @@ static int search_main(void *pctx, struct apk_database *db, struct apk_string_ar
if (ctx->print_result == NULL)
ctx->print_result = ctx->print_package;
- if (ctx->search_description || ctx->search_origin)
- return apk_hash_foreach(&db->available.packages, print_pkg, ctx);
+ if (ctx->search_description || ctx->search_origin) {
+ // Just enumerate all names in sorted order, and do the
+ // filtering in the callback.
+ args = NULL;
+ }
if (!ctx->search_exact) {
foreach_array_item(pmatch, ctx->filter) {