aboutsummaryrefslogtreecommitdiff
path: root/cli/bomtool/main.c
diff options
context:
space:
mode:
authorPierre Pronchery <khorben@FreeBSD.org>2026-06-26 17:34:10 +0000
committerPierre Pronchery <khorben@FreeBSD.org>2026-06-29 05:21:50 +0000
commit0cf7106da9f36671ef62142c27de98eee9d874d6 (patch)
tree48090361499358411adb1d0bb16ca768e7c226a1 /cli/bomtool/main.c
parentb0fc1b7a2fe8fcb18ee407227591bf25a86ffbaf (diff)
Vendor import of pkgconf 2.9.93vendor/pkgconf/2.9.93vendor/pkgconf
Obtained from https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.9.93.tar.gz SHA1: 6bcbedc97081e17ea58e0164adea2ab827acfe23 - SHA256: b9632d0d91321f56645de720fd8cd3584b0d0ca8ff13a3d9d5285888869fcc98 - SHA512: e014096f5486b7cdfa8c6410992b9143b63c7ef0ba540c7cad09923867c3924b951c1dfbd9a85f6d786b0deb30be1b7284f67317f4b261b6e0eca70b20ace1af - One test folder in tests/lib1 had to be removed to avoid UTF-8 filenames in the tree. (Breaks `make create-source-packages`) Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57890
Diffstat (limited to 'cli/bomtool/main.c')
-rw-r--r--cli/bomtool/main.c42
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)
{