diff options
Diffstat (limited to 'cli/bomtool/main.c')
| -rw-r--r-- | cli/bomtool/main.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/cli/bomtool/main.c b/cli/bomtool/main.c index a41502e5a0cf..3a6f81aeb0bf 100644 --- a/cli/bomtool/main.c +++ b/cli/bomtool/main.c @@ -450,37 +450,25 @@ main(int argc, char *argv[]) if ((want_flags & PKG_HELP) == PKG_HELP) return usage(); - while (1) - { - const char *package = argv[pkg_optind]; - - if (package == NULL) - break; - - while (isspace((unsigned char)package[0])) - package++; + /* Join the remaining arguments into a single query string, as the main + * pkgconf CLI does, and let the dependency parser handle module names, + * comparison operators and versions. + */ + pkgconf_buffer_t queryparams = PKGCONF_BUFFER_INITIALIZER; - /* skip empty packages */ - if (package[0] == '\0') { - pkg_optind++; - continue; - } + while (pkg_optind < argc && argv[pkg_optind] != NULL) + { + if (pkgconf_buffer_len(&queryparams) > 0) + pkgconf_buffer_push_byte(&queryparams, ' '); - if (argv[pkg_optind + 1] == NULL || !PKGCONF_IS_OPERATOR_CHAR(*(argv[pkg_optind + 1]))) - { - pkgconf_queue_push(&pkgq, package); - pkg_optind++; - } - else - { - char packagebuf[PKGCONF_BUFSIZE]; + pkgconf_buffer_append(&queryparams, argv[pkg_optind]); + pkg_optind++; + } - snprintf(packagebuf, sizeof packagebuf, "%s %s %s", package, argv[pkg_optind + 1], argv[pkg_optind + 2]); - pkg_optind += 3; + if (pkgconf_buffer_len(&queryparams) > 0) + pkgconf_queue_push(&pkgq, pkgconf_buffer_str(&queryparams)); - pkgconf_queue_push(&pkgq, packagebuf); - } - } + pkgconf_buffer_finalize(&queryparams); if (pkgq.head == NULL) { |
