forked from ariadne/pkgconf
fragment: try to apply munging to all path-only fragments (#94)
parent
f6c96fc3d1
commit
b835d74d80
|
@ -70,6 +70,20 @@ pkgconf_fragment_is_special(const char *string)
|
||||||
return pkgconf_fragment_is_unmergeable(string);
|
return pkgconf_fragment_is_unmergeable(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
pkgconf_fragment_munge(char *buf, size_t buflen, const char *source, const char *sysroot_dir)
|
||||||
|
{
|
||||||
|
*buf = '\0';
|
||||||
|
|
||||||
|
if (sysroot_dir == NULL)
|
||||||
|
sysroot_dir = pkgconf_tuple_find_global("pc_sysrootdir");
|
||||||
|
|
||||||
|
if (pkgconf_fragment_should_munge(source, sysroot_dir))
|
||||||
|
strlcat(buf, sysroot_dir, buflen);
|
||||||
|
|
||||||
|
strlcat(buf, source, buflen);
|
||||||
|
}
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
|
pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
@ -81,11 +95,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 (!pkgconf_fragment_should_munge(source, sysroot_dir))
|
pkgconf_fragment_munge(mungebuf, sizeof mungebuf, source, sysroot_dir);
|
||||||
return strdup(source);
|
|
||||||
|
|
||||||
strlcpy(mungebuf, sysroot_dir, sizeof mungebuf);
|
|
||||||
strlcat(mungebuf, source, sizeof mungebuf);
|
|
||||||
|
|
||||||
return strdup(mungebuf);
|
return strdup(mungebuf);
|
||||||
}
|
}
|
||||||
|
@ -104,19 +114,25 @@ pkgconf_fragment_add(pkgconf_list_t *list, const char *string, unsigned int flag
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
char mungebuf[PKGCONF_BUFSIZE];
|
||||||
|
|
||||||
if (list->tail != NULL && list->tail->data != NULL)
|
if (list->tail != NULL && list->tail->data != NULL)
|
||||||
{
|
{
|
||||||
pkgconf_fragment_t *parent = list->tail->data;
|
pkgconf_fragment_t *parent = list->tail->data;
|
||||||
|
|
||||||
if (pkgconf_fragment_is_unmergeable(parent->data))
|
if (pkgconf_fragment_is_unmergeable(parent->data))
|
||||||
{
|
{
|
||||||
size_t len = strlen(parent->data) + strlen(string) + 2;
|
size_t len;
|
||||||
char *newdata;
|
char *newdata;
|
||||||
|
|
||||||
|
pkgconf_fragment_munge(mungebuf, sizeof mungebuf, string, NULL);
|
||||||
|
|
||||||
|
len = strlen(parent->data) + strlen(mungebuf) + 2;
|
||||||
newdata = malloc(len);
|
newdata = malloc(len);
|
||||||
|
|
||||||
strlcpy(newdata, parent->data, len);
|
strlcpy(newdata, parent->data, len);
|
||||||
strlcat(newdata, " ", len);
|
strlcat(newdata, " ", len);
|
||||||
strlcat(newdata, string, len);
|
strlcat(newdata, mungebuf, len);
|
||||||
|
|
||||||
free(parent->data);
|
free(parent->data);
|
||||||
parent->data = newdata;
|
parent->data = newdata;
|
||||||
|
|
Loading…
Reference in New Issue