aboutsummaryrefslogtreecommitdiff
path: root/libpkgconf/pkg.c
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-09-13 12:24:44 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-09-13 12:24:44 +0300
commit06bcbc7a504a41612e766b7c791cd8a788b24cfa (patch)
treebc6d6f4a6bc284ea560dca986481323197fc6919 /libpkgconf/pkg.c
parent71086c66cee3e6ad1c7a601677ebeead39d64bf7 (diff)
Add support for PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS flag
Diffstat (limited to 'libpkgconf/pkg.c')
-rw-r--r--libpkgconf/pkg.c105
1 files changed, 60 insertions, 45 deletions
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);