From 912d1d9013c0df4da91618784dd73972ff0d9cf1 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 7 Jun 2014 20:11:06 +0000 Subject: [PATCH] main: fix --with-system-includedir and --with-system-libdir behaviour (closes #63) --- main.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 59d6d53..0df1407 100644 --- a/main.c +++ b/main.c @@ -59,18 +59,32 @@ FILE *error_msgout = NULL; static bool fragment_has_system_dir(pkg_fragment_t *frag) { + int check_flags = 0; + char *check_paths = NULL; + char *save, *chunk; + switch (frag->type) { case 'L': - if ((want_flags & PKG_KEEP_SYSTEM_LIBS) == 0 && !strcasecmp(SYSTEM_LIBDIR, frag->data)) - return true; - case 'I': - if ((want_flags & PKG_KEEP_SYSTEM_CFLAGS) == 0 && !strcasecmp(SYSTEM_INCLUDEDIR, frag->data)) - return true; - default: + check_flags = PKG_KEEP_SYSTEM_LIBS; + check_paths = strdup(SYSTEM_LIBDIR); break; + case 'I': + check_flags = PKG_KEEP_SYSTEM_CFLAGS; + check_paths = strdup(SYSTEM_INCLUDEDIR); + break; + default: + return false; } + for (chunk = strtok_r(check_paths, ":", &save); chunk != NULL; chunk = strtok_r(NULL, ":", &save)) + { + if ((want_flags & check_flags) == 0 && !strcmp(chunk, frag->data)) + return true; + } + + free(check_paths); + return false; }