aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpkgconf/client.c37
-rw-r--r--libpkgconf/pkg.c105
2 files changed, 75 insertions, 67 deletions
diff --git a/libpkgconf/client.c b/libpkgconf/client.c
index bcb6ae8..6529dbd 100644
--- a/libpkgconf/client.c
+++ b/libpkgconf/client.c
@@ -141,12 +141,11 @@ pkgconf_client_deinit(pkgconf_client_t *client)
pkgconf_path_free(&client->dir_list);
pkgconf_cache_free(client);
- /*
- * Added to the original leaking code (reported issue #130).
- */
- pkgconf_path_free(&client->filter_libdirs);
- pkgconf_path_free(&client->filter_includedirs);
-
+ /*
+ * Fix the leak (issue #130 is reported).
+ */
+ pkgconf_path_free(&client->filter_libdirs);
+ pkgconf_path_free(&client->filter_includedirs);
}
/*
@@ -326,23 +325,17 @@ pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t linen
size_t len;
va_list va;
- // Workaround MinGW bug which doesn't recognize 'z' length modifier
- // (despite the presence of -std=C99 option) which leads to crash.
- //
- // This indeed is an issue with an outdated Windows run-time
- // (msvcrt.dll) where MinGW delegates the function call. The modifier
- // isn't mentioned in the documentation for Visual Studio 2015, but is
- // for the later one.
- //
- // Note that the issue is already reported to pkgconf developers
- // (issue #125) and hopefully will be workarounded.
- //
- // The original line:
- //
- // len = snprintf(errbuf, sizeof errbuf, "%s:%zu [%s]: ", filename, lineno, funcname);
- //
+ /*
+ * Workaround MinGW bug which doesn't recognize 'z' length modifier (despite
+ * the presence of -std=C99 option) which leads to crash (issue #125 is
+ * reported).
+ *
+ * This indeed is an issue with an outdated Windows run-time (msvcrt.dll)
+ * where MinGW delegates the function call. The modifier isn't mentioned in
+ * the documentation for Visual Studio 2015, but is for the later one.
+ */
len = snprintf(errbuf, sizeof errbuf, "%s:%lu [%s]: ",
- filename, (unsigned long)lineno, funcname);
+ filename, (unsigned long)lineno, funcname);
va_start(va, format);
vsnprintf(errbuf + len, sizeof(errbuf) - len, format, va);
diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c
index 46d562b..fe4592a 100644
--- a/libpkgconf/pkg.c
+++ b/libpkgconf/pkg.c
@@ -301,10 +301,10 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE *
lineno++;
- // Workaround MinGW/msvcrt issue (see the comment in client.c
- // for details).
- //
- PKGCONF_TRACE(client, "%s:%lu > [%s]", filename, (unsigned long)lineno, readbuf);
+ /*
+ * Workaround MinGW/msvcrt issue (see the comment in client.c for details).
+ */
+ PKGCONF_TRACE(client, "%s:%lu > [%s]", filename, (unsigned long)lineno, readbuf);
p = readbuf;
while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.'))
@@ -318,12 +318,14 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE *
{
if (!warned_key_whitespace)
{
- // Workaround MinGW/msvcrt issue (see the comment in
- // client.c for details).
- //
- pkgconf_warn(client, "%s:%lu: warning: whitespace encountered while parsing key section\n",
- pkg->filename, (unsigned long)lineno);
- warned_key_whitespace = true;
+ /*
+ * Workaround MinGW/msvcrt issue (see the comment in client.c for
+ * details).
+ */
+ pkgconf_warn(client, "%s:%lu: warning: whitespace encountered while parsing key section\n",
+ pkg->filename, (unsigned long)lineno);
+
+ warned_key_whitespace = true;
}
/* set to null to avoid trailing spaces in key */
@@ -344,12 +346,13 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE *
{
if (!warned_value_whitespace && op == '=')
{
- // Workaround MinGW/msvcrt issue (see the comment in
- // client.c for details).
- //
- pkgconf_warn(client, "%s:%lu: warning: trailing whitespace encountered while parsing value section\n",
- pkg->filename, (unsigned long)lineno);
- warned_value_whitespace = true;
+ /*
+ * Workaround MinGW/msvcrt issue (see the comment in client.c for
+ * details).
+ */
+ pkgconf_warn(client, "%s:%lu: warning: trailing whitespace encountered while parsing value section\n",
+ pkg->filename, (unsigned long)lineno);
+ warned_value_whitespace = true;
}
*p = '\0';
@@ -420,35 +423,35 @@ pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_STATIC)
return;
- /*
- * Note that if a package is loaded by the file path it is not cached
- * (see pkgconf_pkg_find() for details). Trying to remove such a
- * package from the cache just breaks the cache (issue #133 is
- * reported). So let's first check if the package in the cache.
- *
- * Generally it's quite murky that the function that frees the
- * reference-countable object also removes it's pointer from cache that
- * must own a reference to it (see how pkgconf_cache_add() increments
- * the reference count). It sounds that by the time the object is
- * freed the reference count should be zero and so nobody, including
- * cache, can contain a reference to the object.
- *
- * While probably nothing should surprise in the world, where
- * pkgconf_pkg_free() and pkgconf_pkg_unref() are both available to the
- * client (quite widelly used both in the library's code) and where
- * pkgconf_pkg_unref() assumes the reference count can be negative.
- */
+ /*
+ * Note that if a package is loaded by the file path it is not cached (see
+ * pkgconf_pkg_find() for details). Trying to remove such a package from the
+ * cache just breaks the cache (issue #133 is reported). So let's first check
+ * if the package in the cache.
+ *
+ * Generally it's quite murky that the function that frees the
+ * reference-countable object also removes it's pointer from cache that must
+ * own a reference to it (see how pkgconf_cache_add() increments the
+ * reference count). It sounds that by the time the object is freed the
+ * reference count should be zero and so nobody, including cache, can contain
+ * a reference to the object.
+ *
+ * While probably nothing should surprise in the world, where
+ * pkgconf_pkg_free() and pkgconf_pkg_unref() are both available to the
+ * client (quite widelly used both in the library's code) and where
+ * pkgconf_pkg_unref() assumes the reference count can be negative.
+ */
pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(client->pkg_cache.head, node)
{
- pkgconf_pkg_t *p = node->data;
+ pkgconf_pkg_t *p = node->data;
- if (p == pkg)
- {
- pkgconf_cache_remove(client, pkg);
- break;
- }
- }
+ if (p == pkg)
+ {
+ pkgconf_cache_remove(client, pkg);
+ break;
+ }
+ }
pkgconf_dependency_free(&pkg->requires);
pkgconf_dependency_free(&pkg->requires_private);
@@ -1342,7 +1345,7 @@ pkgconf_pkg_report_graph_error(pkgconf_client_t *client, pkgconf_pkg_t *parent,
if (eflags & PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND)
{
- if (!(client->flags & PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS) & !already_sent_notice)
+ if (!(client->flags & PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS) && !already_sent_notice)
{
pkgconf_error(client, "Package %s was not found in the pkg-config search path.\n", node->package);
pkgconf_error(client, "Perhaps you should add the directory containing `%s.pc'\n", node->package);
@@ -1358,7 +1361,11 @@ pkgconf_pkg_report_graph_error(pkgconf_client_t *client, pkgconf_pkg_t *parent,
pkgconf_error(client, "Package dependency requirement '%s %s %s' could not be satisfied.\n",
node->package, pkgconf_pkg_get_comparator(node), node->version);
- if (pkg != NULL)
+ /*
+ * Add support for PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS flag (issue #134 is
+ * reported).
+ */
+ if (pkg != NULL && !(client->flags & PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS))
pkgconf_error(client, "Package '%s' has version '%s', required version is '%s %s'\n",
node->package, pkg->version, pkgconf_pkg_get_comparator(node), node->version);
}
@@ -1445,8 +1452,16 @@ pkgconf_pkg_walk_conflicts_list(pkgconf_client_t *client,
pkgconf_error(client, "Version '%s' of '%s' conflicts with '%s' due to satisfying conflict rule '%s %s%s%s'.\n",
pkgdep->version, pkgdep->realname, root->realname, parentnode->package, pkgconf_pkg_get_comparator(parentnode),
parentnode->version != NULL ? " " : "", parentnode->version != NULL ? parentnode->version : "");
- pkgconf_error(client, "It may be possible to ignore this conflict and continue, try the\n");
- pkgconf_error(client, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
+
+ /*
+ * Add support for PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS flag (issue #134 is
+ * reported).
+ */
+ if (!(client->flags & PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS))
+ {
+ pkgconf_error(client, "It may be possible to ignore this conflict and continue, try the\n");
+ pkgconf_error(client, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
+ }
pkgconf_pkg_unref(client, pkgdep);