fragment: handle oddball fragments like -framework more accurately

feature/tap-sh
William Pitcock 2017-01-07 15:04:34 -06:00
parent 3b3f1dc76e
commit 4ba414f74a
2 changed files with 17 additions and 4 deletions

View File

@ -47,6 +47,10 @@ pkgconf_fragment_is_unmergeable(const char *string)
if (!strncmp(string, check_fragments[i].token, check_fragments[i].len))
return true;
/* only one pair of {-flag, arg} may be merged together */
if (strchr(string, ' ') != NULL)
return false;
return false;
}
@ -145,7 +149,8 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
{
pkgconf_fragment_t *parent = list->tail->data;
if (pkgconf_fragment_is_unmergeable(parent->data))
/* only attempt to merge 'special' fragments together */
if (!parent->type && pkgconf_fragment_is_unmergeable(parent->data))
{
size_t len;
char *newdata;
@ -162,6 +167,14 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
free(parent->data);
parent->data = newdata;
/* use a copy operation to force a dedup */
pkgconf_node_delete(&parent->iter, list);
pkgconf_fragment_copy(list, parent, 0, false);
/* the fragment list now (maybe) has the copied node, so free the original */
free(parent->data);
free(parent);
return;
}
}
@ -261,7 +274,7 @@ pkgconf_fragment_should_merge(const pkgconf_fragment_t *base)
case 'I':
return true;
default:
return parent->type == base->type;
return !base->type || parent->type == base->type;
}
}

View File

@ -12,9 +12,9 @@ libs_body()
-o inline:"-F/test/lib -framework framework-1 \n" \
pkgconf --libs framework-1
atf_check \
-o inline:"-F/test/lib -framework framework-2 -F/test/lib -framework framework-1 \n" \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1 \n" \
pkgconf --libs framework-2
atf_check \
-o inline:"-F/test/lib -framework framework-1 -F/test/lib -framework framework-2 \n" \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1 \n" \
pkgconf --libs framework-1 framework-2
}