From 2e0e4b2ecec4a4ba4dd856b93612621d4623dbf5 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 27 Dec 2013 11:37:24 +0000 Subject: [PATCH] fragment: increase robustness with MacOS -framework (closes #56) --- fragment.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/fragment.c b/fragment.c index 6832e0d..ae794c9 100644 --- a/fragment.c +++ b/fragment.c @@ -21,15 +21,38 @@ pkg_fragment_add(pkg_list_t *list, const char *string) { pkg_fragment_t *frag; - frag = calloc(sizeof(pkg_fragment_t), 1); - if (*string == '-' && strncmp(string, "-lib:", 5) && strncmp(string, "-framework", 10)) { + frag = calloc(sizeof(pkg_fragment_t), 1); + frag->type = *(string + 1); frag->data = strdup(string + 2); } else { + if (list->tail != NULL && list->tail->data != NULL) + { + pkg_fragment_t *parent = list->tail->data; + + if (!strncmp(parent->data, "-framework", 10)) + { + size_t len = strlen(parent->data) + strlen(string) + 2; + char *newdata; + + newdata = malloc(len); + strlcpy(newdata, parent->data, len); + strlcat(newdata, " ", len); + strlcat(newdata, string, len); + + free(parent->data); + parent->data = newdata; + + return; + } + } + + frag = calloc(sizeof(pkg_fragment_t), 1); + frag->type = 0; frag->data = strdup(string); }