diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-12-28 18:33:57 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-12-28 18:33:57 +0100 |
commit | c5fb28bcf6d0515239ea4b626aee80d99bb41e90 (patch) | |
tree | 8a7df8412c8f7aa772bd6382adeacddca23317c8 | |
parent | a3c93511fc08385d9d07930476c0b70e4549aeec (diff) |
Make pcquery work (kind of)
-rw-r--r-- | cbs.h | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -5,6 +5,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include <ctype.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> @@ -148,7 +149,7 @@ enum pkg_config_flags { PKGC_LIBS = 1 << 0, PKGC_CFLAGS = 1 << 1, }; -static bool pcquery(struct cmd *, char *, enum pkg_config_flags); +static bool pcquery(struct cmd *, char *, int); ATTR_FMT noreturn static void die(const char *, ...); @@ -404,13 +405,15 @@ __rebuild(char *src) } bool -pcquery(struct cmd *cmd, char *lib, enum pkg_config_flags flags) +pcquery(struct cmd *cmd, char *lib, int flags) { - char *p = NULL; + char *p, *q, *s; size_t n; bool ret = false; struct cmd c = {0}; + p = NULL; + if (!cmdadd(&c, "pkg-config")) goto out; if ((flags & PKGC_LIBS) && !cmdadd(&c, "--libs")) @@ -422,7 +425,13 @@ pcquery(struct cmd *cmd, char *lib, enum pkg_config_flags flags) if (cmdexecb(c, &p, &n) != EXIT_SUCCESS) goto out; - printf("%.*s", (int)n, p); + + for (q = strtok(p, " \n\r\t\v"); q; q = strtok(NULL, " \n\r\t\v")) { + if (!(s = strdup(q))) + goto out; + if (!cmdadd(cmd, s)) + goto out; + } ret = true; out: |