forked from ariadne/pkgconf
fragment: add pkgconf_fragment_should_munge() to simplify the munging logic a bit (#94)
parent
0a592689b6
commit
f6c96fc3d1
|
@ -38,6 +38,26 @@ pkgconf_fragment_is_unmergeable(const char *string)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
pkgconf_fragment_should_munge(const char *string, const char *sysroot_dir)
|
||||||
|
{
|
||||||
|
static struct pkgconf_fragment_check check_fragments[] = {
|
||||||
|
{"-isystem", 8},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (*string != '/')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (sysroot_dir != NULL && strncmp(sysroot_dir, string, strlen(sysroot_dir)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < PKGCONF_ARRAY_SIZE(check_fragments); i++)
|
||||||
|
if (!strncmp(string, check_fragments[i].token, check_fragments[i].len))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
pkgconf_fragment_is_special(const char *string)
|
pkgconf_fragment_is_special(const char *string)
|
||||||
{
|
{
|
||||||
|
@ -61,8 +81,7 @@ pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
|
||||||
|
|
||||||
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir");
|
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir");
|
||||||
|
|
||||||
if (*source != '/' ||
|
if (!pkgconf_fragment_should_munge(source, sysroot_dir))
|
||||||
(sysroot_dir != NULL && !strncmp(sysroot_dir, source, strlen(sysroot_dir))))
|
|
||||||
return strdup(source);
|
return strdup(source);
|
||||||
|
|
||||||
strlcpy(mungebuf, sysroot_dir, sizeof mungebuf);
|
strlcpy(mungebuf, sysroot_dir, sizeof mungebuf);
|
||||||
|
|
Loading…
Reference in New Issue