libpkgconf: path: add naive path list filtering function
parent
54c3ca86a2
commit
aa041b415e
|
@ -8,7 +8,7 @@ variables.
|
||||||
|
|
||||||
.. c:function:: void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)
|
.. c:function:: void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)
|
||||||
|
|
||||||
Adds a path node to a path list.
|
Adds a path node to a path list. If the path is already in the list, do nothing.
|
||||||
|
|
||||||
:param char* text: The path text to add as a path node.
|
:param char* text: The path text to add as a path node.
|
||||||
:param pkgconf_list_t* dirlist: The path list to add the path node to.
|
:param pkgconf_list_t* dirlist: The path list to add the path node to.
|
||||||
|
|
|
@ -14,6 +14,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libpkgconf/libpkgconf.h>
|
#include <libpkgconf/libpkgconf.h>
|
||||||
|
#include <libpkgconf/config.h>
|
||||||
|
|
||||||
|
static bool
|
||||||
|
path_list_contains_entry(const char *text, pkgconf_list_t *dirlist)
|
||||||
|
{
|
||||||
|
pkgconf_node_t *n;
|
||||||
|
|
||||||
|
PKGCONF_FOREACH_LIST_ENTRY(dirlist->head, n)
|
||||||
|
{
|
||||||
|
pkgconf_path_t *pn = n->data;
|
||||||
|
|
||||||
|
if (!strcmp(text, pn->path))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
|
@ -31,7 +48,7 @@
|
||||||
*
|
*
|
||||||
* .. c:function:: void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)
|
* .. c:function:: void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)
|
||||||
*
|
*
|
||||||
* Adds a path node to a path list.
|
* Adds a path node to a path list. If the path is already in the list, do nothing.
|
||||||
*
|
*
|
||||||
* :param char* text: The path text to add as a path node.
|
* :param char* text: The path text to add as a path node.
|
||||||
* :param pkgconf_list_t* dirlist: The path list to add the path node to.
|
* :param pkgconf_list_t* dirlist: The path list to add the path node to.
|
||||||
|
@ -42,6 +59,9 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)
|
||||||
{
|
{
|
||||||
pkgconf_path_t *node;
|
pkgconf_path_t *node;
|
||||||
|
|
||||||
|
if (path_list_contains_entry(text, dirlist))
|
||||||
|
return;
|
||||||
|
|
||||||
node = calloc(sizeof(pkgconf_path_t), 1);
|
node = calloc(sizeof(pkgconf_path_t), 1);
|
||||||
node->path = strdup(text);
|
node->path = strdup(text);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue