libpkgconf: fragment: fix over-optimization of cflags/linker flags in edge cases involving non-standard options

feature/tap-sh
William Pitcock 2016-12-30 12:39:10 -06:00
parent 92f566ff38
commit 0c690dc891
1 changed files with 29 additions and 1 deletions

View File

@ -240,6 +240,31 @@ pkgconf_fragment_exists(pkgconf_list_t *list, const pkgconf_fragment_t *base, un
return pkgconf_fragment_lookup(list, base); return pkgconf_fragment_lookup(list, base);
} }
static inline bool
pkgconf_fragment_should_merge(const pkgconf_fragment_t *base)
{
const pkgconf_fragment_t *parent;
/* if we are the first fragment, that means the next fragment is the same, so it's always safe. */
if (base->iter.prev == NULL)
return true;
/* this really shouldn't ever happen, but handle it */
parent = base->iter.prev->data;
if (parent == NULL)
return true;
switch (parent->type)
{
case 'l':
case 'L':
case 'I':
return true;
default:
return parent->type == base->type;
}
}
/* /*
* !doc * !doc
* *
@ -293,7 +318,10 @@ pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsi
pkgconf_fragment_t *frag; pkgconf_fragment_t *frag;
if ((frag = pkgconf_fragment_exists(list, base, flags, is_private)) != NULL) if ((frag = pkgconf_fragment_exists(list, base, flags, is_private)) != NULL)
{
if (pkgconf_fragment_should_merge(frag))
pkgconf_fragment_delete(list, frag); pkgconf_fragment_delete(list, frag);
}
else if (!is_private && !pkgconf_fragment_can_merge_back(base, flags, is_private) && (pkgconf_fragment_lookup(list, base) != NULL)) else if (!is_private && !pkgconf_fragment_can_merge_back(base, flags, is_private) && (pkgconf_fragment_lookup(list, base) != NULL))
return; return;