libpkgconf: migrate pkgconf client fragment_is_system_dir() to a libpkgconf API

pull/109/head
William Pitcock 2016-12-21 20:06:17 -06:00
parent b26e3cf6c7
commit 6ef4a853b5
4 changed files with 46 additions and 22 deletions

View File

@ -15,6 +15,16 @@ which is composable, mergeable and reorderable.
:param char* string: The string of text to add as a fragment to the fragment list. :param char* string: The string of text to add as a fragment to the fragment list.
:return: nothing :return: nothing
.. c:function:: bool pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag)
Checks if a `fragment` contains a `system path`. System paths are detected at compile time and optionally overridden by
the ``PKG_CONFIG_SYSTEM_INCLUDE_PATH`` and ``PKG_CONFIG_SYSTEM_LIBRARY_PATH`` environment variables.
:param pkgconf_client_t* client: The pkgconf client object the fragment belongs to.
:param pkgconf_fragment_t* frag: The fragment being checked.
:return: true if the fragment contains a system path, else false
:rtype: bool
.. c:function:: void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private) .. c:function:: void pkgconf_fragment_copy(pkgconf_list_t *list, const pkgconf_fragment_t *base, unsigned int flags, bool is_private)
Copies a `fragment` to another `fragment list`, possibly removing a previous copy of the `fragment` Copies a `fragment` to another `fragment list`, possibly removing a previous copy of the `fragment`

View File

@ -238,6 +238,39 @@ 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);
} }
/*
* !doc
*
* .. c:function:: bool pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag)
*
* Checks if a `fragment` contains a `system path`. System paths are detected at compile time and optionally overridden by
* the ``PKG_CONFIG_SYSTEM_INCLUDE_PATH`` and ``PKG_CONFIG_SYSTEM_LIBRARY_PATH`` environment variables.
*
* :param pkgconf_client_t* client: The pkgconf client object the fragment belongs to.
* :param pkgconf_fragment_t* frag: The fragment being checked.
* :return: true if the fragment contains a system path, else false
* :rtype: bool
*/
bool
pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag)
{
const pkgconf_list_t *check_paths = NULL;
switch (frag->type)
{
case 'L':
check_paths = &client->filter_libdirs;
break;
case 'I':
check_paths = &client->filter_includedirs;
break;
default:
return false;
}
return pkgconf_path_match_list(frag->data, check_paths);
}
/* /*
* !doc * !doc
* *

View File

@ -235,6 +235,7 @@ void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *des
size_t pkgconf_fragment_render_len(const pkgconf_list_t *list); size_t pkgconf_fragment_render_len(const pkgconf_list_t *list);
void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len); void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len);
char *pkgconf_fragment_render(const pkgconf_list_t *list); char *pkgconf_fragment_render(const pkgconf_list_t *list);
bool pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag);
/* fileio.c */ /* fileio.c */
char *pkgconf_fgetline(char *line, size_t size, FILE *stream); char *pkgconf_fgetline(char *line, size_t size, FILE *stream);

24
main.c
View File

@ -72,26 +72,6 @@ error_handler(const char *msg, const pkgconf_client_t *client, const void *data)
return true; return true;
} }
static bool
fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag)
{
const pkgconf_list_t *check_paths = NULL;
switch (frag->type)
{
case 'L':
check_paths = &client->filter_libdirs;
break;
case 'I':
check_paths = &client->filter_includedirs;
break;
default:
return false;
}
return pkgconf_path_match_list(frag->data, check_paths);
}
static bool static bool
print_list_entry(const pkgconf_pkg_t *entry, void *data) print_list_entry(const pkgconf_pkg_t *entry, void *data)
{ {
@ -125,7 +105,7 @@ filter_cflags(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, un
(void) client; (void) client;
(void) flags; (void) flags;
if (fragment_has_system_dir(client, frag)) if (pkgconf_fragment_has_system_dir(client, frag))
return false; return false;
if (frag->type == 'I') if (frag->type == 'I')
@ -143,7 +123,7 @@ filter_libs(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, unsi
(void) client; (void) client;
(void) flags; (void) flags;
if (fragment_has_system_dir(client, frag)) if (pkgconf_fragment_has_system_dir(client, frag))
return false; return false;
switch (frag->type) switch (frag->type)