diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-09-19 21:04:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-09-19 21:04:30 +0300 |
commit | 54fae3a9ca0af5ab29cc02d9c91fc2c63c6bc872 (patch) | |
tree | 300def013e8b61ee260bca3ca8f3ff96d59b7290 | |
parent | df3f033ad8586bb28503d204eac4e02990f64a44 (diff) |
Merge with latest original package version (master branch)
-rw-r--r-- | libpkgconf/argvsplit.c | 1 | ||||
-rw-r--r-- | libpkgconf/argvsplit.c.orig | 1 | ||||
-rw-r--r-- | libpkgconf/bsdstubs.h | 8 | ||||
-rw-r--r-- | libpkgconf/cache.c | 7 | ||||
-rw-r--r-- | libpkgconf/client.c | 23 | ||||
-rw-r--r-- | libpkgconf/client.c.orig | 554 | ||||
-rw-r--r-- | libpkgconf/dependency.c | 33 | ||||
-rw-r--r-- | libpkgconf/fileio.c | 1 | ||||
-rw-r--r-- | libpkgconf/fileio.c.orig | 1 | ||||
-rw-r--r-- | libpkgconf/fragment.c | 5 | ||||
-rw-r--r-- | libpkgconf/iter.h | 8 | ||||
-rw-r--r-- | libpkgconf/libpkgconf.h | 22 | ||||
-rw-r--r-- | libpkgconf/libpkgconf.h.orig | 319 | ||||
-rw-r--r-- | libpkgconf/path.c | 3 | ||||
-rw-r--r-- | libpkgconf/pkg.c | 126 | ||||
-rw-r--r-- | libpkgconf/pkg.c.orig | 72 | ||||
-rw-r--r-- | libpkgconf/queue.c | 1 | ||||
-rw-r--r-- | libpkgconf/stdinc.h | 23 | ||||
-rw-r--r-- | libpkgconf/stdinc.h.orig | 54 | ||||
-rw-r--r-- | libpkgconf/tuple.c | 3 |
20 files changed, 153 insertions, 1112 deletions
diff --git a/libpkgconf/argvsplit.c b/libpkgconf/argvsplit.c index cb5844a..fdc4dc9 100644 --- a/libpkgconf/argvsplit.c +++ b/libpkgconf/argvsplit.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* diff --git a/libpkgconf/argvsplit.c.orig b/libpkgconf/argvsplit.c.orig index 85f7f57..81a2ec1 100644 --- a/libpkgconf/argvsplit.c.orig +++ b/libpkgconf/argvsplit.c.orig @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* diff --git a/libpkgconf/bsdstubs.h b/libpkgconf/bsdstubs.h index 2e0fb5c..8f37b70 100644 --- a/libpkgconf/bsdstubs.h +++ b/libpkgconf/bsdstubs.h @@ -18,8 +18,16 @@ #include <libpkgconf/libpkgconf-api.h> +#ifdef __cplusplus +extern "C" { +#endif + PKGCONF_API extern size_t pkgconf_strlcpy(char *dst, const char *src, size_t siz); PKGCONF_API extern size_t pkgconf_strlcat(char *dst, const char *src, size_t siz); PKGCONF_API extern char *pkgconf_strndup(const char *src, size_t len); +#ifdef __cplusplus +} +#endif + #endif diff --git a/libpkgconf/cache.c b/libpkgconf/cache.c index 986eba5..1662ce5 100644 --- a/libpkgconf/cache.c +++ b/libpkgconf/cache.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* @@ -84,6 +85,9 @@ pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg) pkgconf_node_insert(&pkg->cache_iter, pkg, &client->pkg_cache); PKGCONF_TRACE(client, "added @%p to cache", pkg); + + /* mark package as cached */ + pkg->flags |= PKGCONF_PKG_PROPF_CACHED; } /* @@ -103,6 +107,9 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg) if (pkg == NULL) return; + if (!(pkg->flags & PKGCONF_PKG_PROPF_CACHED)) + return; + PKGCONF_TRACE(client, "removed @%p from cache", pkg); pkgconf_node_delete(&pkg->cache_iter, &client->pkg_cache); diff --git a/libpkgconf/client.c b/libpkgconf/client.c index 6529dbd..f5f4717 100644 --- a/libpkgconf/client.c +++ b/libpkgconf/client.c @@ -13,8 +13,10 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> #include <libpkgconf/config.h> + /* * !doc * @@ -137,15 +139,12 @@ pkgconf_client_deinit(pkgconf_client_t *client) if (client->buildroot_dir != NULL) free(client->buildroot_dir); + pkgconf_path_free(&client->filter_libdirs); + pkgconf_path_free(&client->filter_includedirs); + pkgconf_tuple_free_global(client); pkgconf_path_free(&client->dir_list); pkgconf_cache_free(client); - - /* - * Fix the leak (issue #130 is reported). - */ - pkgconf_path_free(&client->filter_libdirs); - pkgconf_path_free(&client->filter_includedirs); } /* @@ -325,17 +324,7 @@ 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 (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); + len = snprintf(errbuf, sizeof errbuf, "%s:" SIZE_FMT_SPECIFIER " [%s]: ", filename, lineno, funcname); va_start(va, format); vsnprintf(errbuf + len, sizeof(errbuf) - len, format, va); diff --git a/libpkgconf/client.c.orig b/libpkgconf/client.c.orig deleted file mode 100644 index 1203ffe..0000000 --- a/libpkgconf/client.c.orig +++ /dev/null @@ -1,554 +0,0 @@ -/* - * client.c - * libpkgconf consumer lifecycle management - * - * Copyright (c) 2016 pkgconf authors (see AUTHORS). - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * This software is provided 'as is' and without any warranty, express or - * implied. In no event shall the authors be liable for any damages arising - * from the use of this software. - */ - -#include <libpkgconf/libpkgconf.h> -#include <libpkgconf/config.h> -/* - * !doc - * - * libpkgconf `client` module - * ========================== - * - * The libpkgconf `client` module implements the `pkgconf_client_t` "client" object. - * Client objects store all necessary state for libpkgconf allowing for multiple instances to run - * in parallel. - * - * Client objects are not thread safe, in other words, a client object should not be shared across - * thread boundaries. - */ - -static void -trace_path_list(const pkgconf_client_t *client, const char *desc, pkgconf_list_t *list) -{ - const pkgconf_node_t *n; - - PKGCONF_TRACE(client, "%s:", desc); - PKGCONF_FOREACH_LIST_ENTRY(list->head, n) - { - const pkgconf_path_t *p = n->data; - - PKGCONF_TRACE(client, " - '%s'", p->path); - } -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler) - * - * Initialise a pkgconf client object. - * - * :param pkgconf_client_t* client: The client to initialise. - * :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors. - * :param void* error_handler_data: user data passed to optional error handler - * :return: nothing - */ -void -pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data) -{ - client->error_handler_data = error_handler_data; - client->error_handler = error_handler; - client->auditf = NULL; - - if (client->trace_handler == NULL) - pkgconf_client_set_trace_handler(client, NULL, NULL); - - pkgconf_client_set_error_handler(client, error_handler, error_handler_data); - pkgconf_client_set_warn_handler(client, NULL, NULL); - - pkgconf_client_set_sysroot_dir(client, NULL); - pkgconf_client_set_buildroot_dir(client, NULL); - pkgconf_client_set_prefix_varname(client, NULL); - - pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &client->filter_libdirs, false); - pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &client->filter_includedirs, false); - - /* GCC uses these environment variables to define system include paths, so we should check them. */ - pkgconf_path_build_from_environ("LIBRARY_PATH", NULL, &client->filter_libdirs, false); - pkgconf_path_build_from_environ("CPATH", NULL, &client->filter_includedirs, false); - pkgconf_path_build_from_environ("C_INCLUDE_PATH", NULL, &client->filter_includedirs, false); - pkgconf_path_build_from_environ("CPLUS_INCLUDE_PATH", NULL, &client->filter_includedirs, false); - pkgconf_path_build_from_environ("OBJC_INCLUDE_PATH", NULL, &client->filter_includedirs, false); - -#ifdef _WIN32 - /* also use the path lists that MSVC uses on windows */ - pkgconf_path_build_from_environ("INCLUDE", NULL, &client->filter_includedirs, false); -#endif - - PKGCONF_TRACE(client, "initialized client @%p", client); - - trace_path_list(client, "filtered library paths", &client->filter_libdirs); - trace_path_list(client, "filtered include paths", &client->filter_includedirs); -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler) - * - * Allocate and initialise a pkgconf client object. - * - * :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors. - * :param void* error_handler_data: user data passed to optional error handler - * :return: A pkgconf client object. - * :rtype: pkgconf_client_t* - */ -pkgconf_client_t * -pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data) -{ - pkgconf_client_t *out = calloc(sizeof(pkgconf_client_t), 1); - pkgconf_client_init(out, error_handler, error_handler_data); - return out; -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_deinit(pkgconf_client_t *client) - * - * Release resources belonging to a pkgconf client object. - * - * :param pkgconf_client_t* client: The client to deinitialise. - * :return: nothing - */ -void -pkgconf_client_deinit(pkgconf_client_t *client) -{ - PKGCONF_TRACE(client, "deinit @%p", client); - - if (client->prefix_varname != NULL) - free(client->prefix_varname); - - if (client->sysroot_dir != NULL) - free(client->sysroot_dir); - - if (client->buildroot_dir != NULL) - free(client->buildroot_dir); - - pkgconf_tuple_free_global(client); - pkgconf_path_free(&client->dir_list); - pkgconf_cache_free(client); -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_free(pkgconf_client_t *client) - * - * Release resources belonging to a pkgconf client object and then free the client object itself. - * - * :param pkgconf_client_t* client: The client to deinitialise and free. - * :return: nothing - */ -void -pkgconf_client_free(pkgconf_client_t *client) -{ - pkgconf_client_deinit(client); - free(client); -} - -/* - * !doc - * - * .. c:function:: const char *pkgconf_client_get_sysroot_dir(const pkgconf_client_t *client) - * - * Retrieves the client's sysroot directory (if any). - * - * :param pkgconf_client_t* client: The client object being accessed. - * :return: A string containing the sysroot directory or NULL. - * :rtype: const char * - */ -const char * -pkgconf_client_get_sysroot_dir(const pkgconf_client_t *client) -{ - return client->sysroot_dir; -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_set_sysroot_dir(pkgconf_client_t *client, const char *sysroot_dir) - * - * Sets or clears the sysroot directory on a client object. Any previous sysroot directory setting is - * automatically released if one was previously set. - * - * Additionally, the global tuple ``$(pc_sysrootdir)`` is set as appropriate based on the new setting. - * - * :param pkgconf_client_t* client: The client object being modified. - * :param char* sysroot_dir: The sysroot directory to set or NULL to unset. - * :return: nothing - */ -void -pkgconf_client_set_sysroot_dir(pkgconf_client_t *client, const char *sysroot_dir) -{ - if (client->sysroot_dir != NULL) - free(client->sysroot_dir); - - client->sysroot_dir = sysroot_dir != NULL ? strdup(sysroot_dir) : NULL; - - PKGCONF_TRACE(client, "set sysroot_dir to: %s", client->sysroot_dir != NULL ? client->sysroot_dir : "<default>"); - - pkgconf_tuple_add_global(client, "pc_sysrootdir", client->sysroot_dir != NULL ? client->sysroot_dir : "/"); -} - -/* - * !doc - * - * .. c:function:: const char *pkgconf_client_get_buildroot_dir(const pkgconf_client_t *client) - * - * Retrieves the client's buildroot directory (if any). - * - * :param pkgconf_client_t* client: The client object being accessed. - * :return: A string containing the buildroot directory or NULL. - * :rtype: const char * - */ -const char * -pkgconf_client_get_buildroot_dir(const pkgconf_client_t *client) -{ - return client->buildroot_dir; -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_set_buildroot_dir(pkgconf_client_t *client, const char *buildroot_dir) - * - * Sets or clears the buildroot directory on a client object. Any previous buildroot directory setting is - * automatically released if one was previously set. - * - * Additionally, the global tuple ``$(pc_top_builddir)`` is set as appropriate based on the new setting. - * - * :param pkgconf_client_t* client: The client object being modified. - * :param char* buildroot_dir: The buildroot directory to set or NULL to unset. - * :return: nothing - */ -void -pkgconf_client_set_buildroot_dir(pkgconf_client_t *client, const char *buildroot_dir) -{ - if (client->buildroot_dir != NULL) - free(client->buildroot_dir); - - client->buildroot_dir = buildroot_dir != NULL ? strdup(buildroot_dir) : NULL; - - PKGCONF_TRACE(client, "set buildroot_dir to: %s", client->buildroot_dir != NULL ? client->buildroot_dir : "<default>"); - - pkgconf_tuple_add_global(client, "pc_top_builddir", client->buildroot_dir != NULL ? client->buildroot_dir : "$(top_builddir)"); -} - -/* - * !doc - * - * .. c:function:: bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) - * - * Report an error to a client-registered error handler. - * - * :param pkgconf_client_t* client: The pkgconf client object to report the error to. - * :param char* format: A printf-style format string to use for formatting the error message. - * :return: true if the error handler processed the message, else false. - * :rtype: bool - */ -bool -pkgconf_error(const pkgconf_client_t *client, const char *format, ...) -{ - char errbuf[PKGCONF_BUFSIZE]; - va_list va; - - va_start(va, format); - vsnprintf(errbuf, sizeof errbuf, format, va); - va_end(va); - - return client->error_handler(errbuf, client, client->error_handler_data); -} - -/* - * !doc - * - * .. c:function:: bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) - * - * Report an error to a client-registered warn handler. - * - * :param pkgconf_client_t* client: The pkgconf client object to report the error to. - * :param char* format: A printf-style format string to use for formatting the warning message. - * :return: true if the warn handler processed the message, else false. - * :rtype: bool - */ -bool -pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) -{ - char errbuf[PKGCONF_BUFSIZE]; - va_list va; - - va_start(va, format); - vsnprintf(errbuf, sizeof errbuf, format, va); - va_end(va); - - return client->warn_handler(errbuf, client, client->warn_handler_data); -} - -/* - * !doc - * - * .. c:function:: bool pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t len, const char *funcname, const char *format, ...) - * - * Report a message to a client-registered trace handler. - * - * :param pkgconf_client_t* client: The pkgconf client object to report the trace message to. - * :param char* filename: The file the function is in. - * :param size_t lineno: The line number currently being executed. - * :param char* funcname: The function name to use. - * :param char* format: A printf-style format string to use for formatting the trace message. - * :return: true if the trace handler processed the message, else false. - * :rtype: bool - */ -bool -pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t lineno, const char *funcname, const char *format, ...) -{ - char errbuf[PKGCONF_BUFSIZE]; - size_t len; - va_list va; - - len = snprintf(errbuf, sizeof errbuf, "%s:%zu [%s]: ", filename, lineno, funcname); - - va_start(va, format); - vsnprintf(errbuf + len, sizeof(errbuf) - len, format, va); - va_end(va); - - pkgconf_strlcat(errbuf, "\n", sizeof errbuf); - - return client->trace_handler(errbuf, client, client->trace_handler_data); -} - -/* - * !doc - * - * .. c:function:: bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data) - * - * The default pkgconf error handler. - * - * :param char* msg: The error message to handle. - * :param pkgconf_client_t* client: The client object the error originated from. - * :param void* data: An opaque pointer to extra data associated with the client for error handling. - * :return: true (the function does nothing to process the message) - * :rtype: bool - */ -bool -pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data) -{ - (void) msg; - (void) client; - (void) data; - - return true; -} - -/* - * !doc - * - * .. c:function:: unsigned int pkgconf_client_get_flags(const pkgconf_client_t *client) - * - * Retrieves resolver-specific flags associated with a client object. - * - * :param pkgconf_client_t* client: The client object to retrieve the resolver-specific flags from. - * :return: a bitfield of resolver-specific flags - * :rtype: uint - */ -unsigned int -pkgconf_client_get_flags(const pkgconf_client_t *client) -{ - return client->flags; -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_set_flags(pkgconf_client_t *client, unsigned int flags) - * - * Sets resolver-specific flags associated with a client object. - * - * :param pkgconf_client_t* client: The client object to set the resolver-specific flags on. - * :return: nothing - */ -void -pkgconf_client_set_flags(pkgconf_client_t *client, unsigned int flags) -{ - client->flags = flags; -} - -/* - * !doc - * - * .. c:function:: const char *pkgconf_client_get_prefix_varname(const pkgconf_client_t *client) - * - * Retrieves the name of the variable that should contain a module's prefix. - * In some cases, it is necessary to override this variable to allow proper path relocation. - * - * :param pkgconf_client_t* client: The client object to retrieve the prefix variable name from. - * :return: the prefix variable name as a string - * :rtype: const char * - */ -const char * -pkgconf_client_get_prefix_varname(const pkgconf_client_t *client) -{ - return client->prefix_varname; -} - -/* - * !doc - * - * .. c:function:: void pkgconf_client_set_prefix_varname(pkgconf_client_t *client, const char *prefix_varname) - * - * Sets the name of the variable that should contain a module's prefix. - * If the variable name is ``NULL``, then the default variable name (``prefix``) is used. - * - * :param pkgconf_client_t* client: The client object to set the prefix variable name on. - * :param char* prefix_varname: The prefix variable name to set. - * :return: nothing - */ -void -pkgconf_client_set_prefix_varname(pkgconf_client_t *client, const char *prefix_varname) -{ - if (prefix_varname == NULL) - prefix_varname = "prefix"; - - if (client->prefix_varname != NULL) - free(client->prefix_varname); - - client->prefix_varname = strdup(prefix_varname); - - PKGCONF_TRACE(client, "set prefix_varname to: %s", client->prefix_varname); -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_get_warn_handler(const pkgconf_client_t *client) - * - * Returns the warning handler if one is set, else ``NULL``. - * - * :param pkgconf_client_t* client: The client object to get the warn handler from. - * :return: a function pointer to the warn handler or ``NULL`` - */ -pkgconf_error_handler_func_t -pkgconf_client_get_warn_handler(const pkgconf_client_t *client) -{ - return client->warn_handler; -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler, void *warn_handler_data) - * - * Sets a warn handler on a client object or uninstalls one if set to ``NULL``. - * - * :param pkgconf_client_t* client: The client object to set the warn handler on. - * :param pkgconf_error_handler_func_t warn_handler: The warn handler to set. - * :param void* warn_handler_data: Optional data to associate with the warn handler. - * :return: nothing - */ -void -pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler, void *warn_handler_data) -{ - client->warn_handler = warn_handler; - client->warn_handler_data = warn_handler_data; - - if (client->warn_handler == NULL) - { - PKGCONF_TRACE(client, "installing default warn handler"); - client->warn_handler = pkgconf_default_error_handler; - } -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_get_error_handler(const pkgconf_client_t *client) - * - * Returns the error handler if one is set, else ``NULL``. - * - * :param pkgconf_client_t* client: The client object to get the error handler from. - * :return: a function pointer to the error handler or ``NULL`` - */ -pkgconf_error_handler_func_t -pkgconf_client_get_error_handler(const pkgconf_client_t *client) -{ - return client->error_handler; -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data) - * - * Sets a warn handler on a client object or uninstalls one if set to ``NULL``. - * - * :param pkgconf_client_t* client: The client object to set the error handler on. - * :param pkgconf_error_handler_func_t error_handler: The error handler to set. - * :param void* error_handler_data: Optional data to associate with the error handler. - * :return: nothing - */ -void -pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data) -{ - client->error_handler = error_handler; - client->error_handler_data = error_handler_data; - - if (client->error_handler == NULL) - { - PKGCONF_TRACE(client, "installing default error handler"); - client->error_handler = pkgconf_default_error_handler; - } -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_get_trace_handler(const pkgconf_client_t *client) - * - * Returns the error handler if one is set, else ``NULL``. - * - * :param pkgconf_client_t* client: The client object to get the error handler from. - * :return: a function pointer to the error handler or ``NULL`` - */ -pkgconf_error_handler_func_t -pkgconf_client_get_trace_handler(const pkgconf_client_t *client) -{ - return client->trace_handler; -} - -/* - * !doc - * - * .. c:function:: pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t trace_handler, void *trace_handler_data) - * - * Sets a warn handler on a client object or uninstalls one if set to ``NULL``. - * - * :param pkgconf_client_t* client: The client object to set the error handler on. - * :param pkgconf_error_handler_func_t trace_handler: The error handler to set. - * :param void* trace_handler_data: Optional data to associate with the error handler. - * :return: nothing - */ -void -pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t trace_handler, void *trace_handler_data) -{ - client->trace_handler = trace_handler; - client->trace_handler_data = trace_handler_data; - - if (client->trace_handler == NULL) - { - client->trace_handler = pkgconf_default_error_handler; - PKGCONF_TRACE(client, "installing default trace handler"); - } -} diff --git a/libpkgconf/dependency.c b/libpkgconf/dependency.c index 3b1503c..3078102 100644 --- a/libpkgconf/dependency.c +++ b/libpkgconf/dependency.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* @@ -36,38 +37,26 @@ typedef enum { #define DEBUG_PARSE 0 -/* - * !doc - * - * .. c:function:: const char *pkgconf_dependency_to_str(const pkgconf_dependency_t *dep) - * - * Renders a dependency to a string. - * - * :param pkgconf_dependency_t* dep: The dependency to render. - * :return: The dependency rendered as a string. - * :rtype: const char * - */ -const char * -pkgconf_dependency_to_str(const pkgconf_dependency_t *dep) +static const char * +dependency_to_str(const pkgconf_dependency_t *dep, char *buf, size_t buflen) { - static char outbuf[PKGCONF_BUFSIZE]; - - pkgconf_strlcpy(outbuf, dep->package, sizeof outbuf); + pkgconf_strlcpy(buf, dep->package, buflen); if (dep->version != NULL) { - pkgconf_strlcat(outbuf, " ", sizeof outbuf); - pkgconf_strlcat(outbuf, pkgconf_pkg_get_comparator(dep), sizeof outbuf); - pkgconf_strlcat(outbuf, " ", sizeof outbuf); - pkgconf_strlcat(outbuf, dep->version, sizeof outbuf); + pkgconf_strlcat(buf, " ", buflen); + pkgconf_strlcat(buf, pkgconf_pkg_get_comparator(dep), buflen); + pkgconf_strlcat(buf, " ", buflen); + pkgconf_strlcat(buf, dep->version, buflen); } - return outbuf; + return buf; } static inline pkgconf_dependency_t * pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare) { pkgconf_dependency_t *dep; + char depbuf[PKGCONF_BUFSIZE]; dep = calloc(sizeof(pkgconf_dependency_t), 1); dep->package = pkgconf_strndup(package, package_sz); @@ -77,7 +66,7 @@ pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, dep->compare = compare; - PKGCONF_TRACE(client, "added dependency [%s] to list @%p", pkgconf_dependency_to_str(dep), list); + PKGCONF_TRACE(client, "added dependency [%s] to list @%p", dependency_to_str(dep, depbuf, sizeof depbuf), list); pkgconf_node_insert_tail(&dep->iter, dep, list); return dep; diff --git a/libpkgconf/fileio.c b/libpkgconf/fileio.c index bcc9c50..7411dc3 100644 --- a/libpkgconf/fileio.c +++ b/libpkgconf/fileio.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> char * diff --git a/libpkgconf/fileio.c.orig b/libpkgconf/fileio.c.orig index d1c848f..eb073d5 100644 --- a/libpkgconf/fileio.c.orig +++ b/libpkgconf/fileio.c.orig @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> char * diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index 9a4bc31..b405631 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* @@ -34,7 +35,7 @@ struct pkgconf_fragment_check { static inline bool pkgconf_fragment_is_unmergeable(const char *string) { - static struct pkgconf_fragment_check check_fragments[] = { + static const struct pkgconf_fragment_check check_fragments[] = { {"-framework", 10}, {"-isystem", 8}, {"-idirafter", 10}, @@ -70,7 +71,7 @@ pkgconf_fragment_is_unmergeable(const char *string) static inline bool pkgconf_fragment_should_munge(const char *string, const char *sysroot_dir) { - static struct pkgconf_fragment_check check_fragments[] = { + static const struct pkgconf_fragment_check check_fragments[] = { {"-isystem", 8}, {"-idirafter", 10}, {"-include", 8}, diff --git a/libpkgconf/iter.h b/libpkgconf/iter.h index 59cfac3..d90b402 100644 --- a/libpkgconf/iter.h +++ b/libpkgconf/iter.h @@ -16,6 +16,10 @@ #ifndef PKGCONF__ITER_H #define PKGCONF__ITER_H +#ifdef __cplusplus +extern "C" { +#endif + typedef struct pkgconf_node_ pkgconf_node_t; struct pkgconf_node_ { @@ -94,4 +98,8 @@ pkgconf_node_delete(pkgconf_node_t *node, pkgconf_list_t *list) node->next->prev = node->prev; } +#ifdef __cplusplus +} +#endif + #endif diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 096d92b..d7fe911 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -16,19 +16,18 @@ #ifndef LIBPKGCONF__LIBPKGCONF_H #define LIBPKGCONF__LIBPKGCONF_H -/* - * Wrap the header content into the 'extern "C"' block, so C++ compiler can - * handle it properly (issue #136 is reported). - */ -#ifdef __cplusplus -extern "C" { -#endif - -#include <libpkgconf/stdinc.h> +#include <stdio.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdbool.h> #include <libpkgconf/iter.h> #include <libpkgconf/bsdstubs.h> #include <libpkgconf/libpkgconf-api.h> +#ifdef __cplusplus +extern "C" { +#endif + /* pkg-config uses ';' on win32 as ':' is part of path */ #ifdef _WIN32 #define PKG_CONFIG_PATH_SEP_S ";" @@ -169,6 +168,8 @@ struct pkgconf_client_ { unsigned int flags; char *prefix_varname; + + bool already_sent_notice; }; /* client.c */ @@ -264,7 +265,6 @@ PKGCONF_API void pkgconf_dependency_parse_str(const pkgconf_client_t *client, pk PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends); PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail); PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list); -PKGCONF_API const char *pkgconf_dependency_to_str(const pkgconf_dependency_t *dep); PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare); /* argvsplit.c */ @@ -325,7 +325,7 @@ PKGCONF_API void pkgconf_path_free(pkgconf_list_t *dirlist); PKGCONF_API bool pkgconf_path_relocate(char *buf, size_t buflen); #ifdef __cplusplus -} /* end of the 'extern "C"' block */ +} #endif #endif diff --git a/libpkgconf/libpkgconf.h.orig b/libpkgconf/libpkgconf.h.orig deleted file mode 100644 index 8a0031e..0000000 --- a/libpkgconf/libpkgconf.h.orig +++ /dev/null @@ -1,319 +0,0 @@ -/* - * libpkgconf.h - * Global include file for everything in libpkgconf. - * - * Copyright (c) 2011, 2015 pkgconf authors (see AUTHORS). - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * This software is provided 'as is' and without any warranty, express or - * implied. In no event shall the authors be liable for any damages arising - * from the use of this software. - */ - -#ifndef LIBPKGCONF__LIBPKGCONF_H -#define LIBPKGCONF__LIBPKGCONF_H - -#include <libpkgconf/stdinc.h> -#include <libpkgconf/iter.h> -#include <libpkgconf/bsdstubs.h> -#include <libpkgconf/libpkgconf-api.h> - -/* pkg-config uses ';' on win32 as ':' is part of path */ -#ifdef _WIN32 -#define PKG_CONFIG_PATH_SEP_S ";" -#else -#define PKG_CONFIG_PATH_SEP_S ":" -#endif - -#ifdef _WIN32 -#define PKG_DIR_SEP_S '\\' -#else -#define PKG_DIR_SEP_S '/' -#endif - -#define PKGCONF_BUFSIZE (65535) - -typedef enum { - PKGCONF_CMP_NOT_EQUAL, - PKGCONF_CMP_ANY, - PKGCONF_CMP_LESS_THAN, - PKGCONF_CMP_LESS_THAN_EQUAL, - PKGCONF_CMP_EQUAL, - PKGCONF_CMP_GREATER_THAN, - PKGCONF_CMP_GREATER_THAN_EQUAL -} pkgconf_pkg_comparator_t; - -#define PKGCONF_CMP_COUNT 7 - -typedef struct pkgconf_pkg_ pkgconf_pkg_t; -typedef struct pkgconf_dependency_ pkgconf_dependency_t; -typedef struct pkgconf_tuple_ pkgconf_tuple_t; -typedef struct pkgconf_fragment_ pkgconf_fragment_t; -typedef struct pkgconf_path_ pkgconf_path_t; -typedef struct pkgconf_client_ pkgconf_client_t; - -#define PKGCONF_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) - -#define PKGCONF_FOREACH_LIST_ENTRY(head, value) \ - for ((value) = (head); (value) != NULL; (value) = (value)->next) - -#define PKGCONF_FOREACH_LIST_ENTRY_SAFE(head, nextiter, value) \ - for ((value) = (head), (nextiter) = (head) != NULL ? (head)->next : NULL; (value) != NULL; (value) = (nextiter), (nextiter) = (nextiter) != NULL ? (nextiter)->next : NULL) - -#define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \ - for ((value) = (tail); (value) != NULL; (value) = (value)->prev) - -struct pkgconf_fragment_ { - pkgconf_node_t iter; - - char type; - char *data; -}; - -struct pkgconf_dependency_ { - pkgconf_node_t iter; - - char *package; - pkgconf_pkg_comparator_t compare; - char *version; - pkgconf_pkg_t *parent; -}; - -struct pkgconf_tuple_ { - pkgconf_node_t iter; - - char *key; - char *value; -}; - -struct pkgconf_path_ { - pkgconf_node_t lnode; - - char *path; - void *handle_path; - void *handle_device; -}; - -#define PKGCONF_PKG_PROPF_NONE 0x00 -#define PKGCONF_PKG_PROPF_STATIC 0x01 -#define PKGCONF_PKG_PROPF_CACHED 0x02 -#define PKGCONF_PKG_PROPF_SEEN 0x04 -#define PKGCONF_PKG_PROPF_UNINSTALLED 0x08 -#define PKGCONF_PKG_PROPF_VIRTUAL 0x10 - -struct pkgconf_pkg_ { - pkgconf_node_t cache_iter; - - int refcount; - char *id; - char *filename; - char *realname; - char *version; - char *description; - char *url; - char *pc_filedir; - - pkgconf_list_t libs; - pkgconf_list_t libs_private; - pkgconf_list_t cflags; - pkgconf_list_t cflags_private; - - pkgconf_list_t requires; - pkgconf_list_t requires_private; - pkgconf_list_t conflicts; - pkgconf_list_t provides; - - pkgconf_list_t vars; - - unsigned int flags; -}; - -typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data); -typedef void (*pkgconf_pkg_traverse_func_t)(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data); -typedef bool (*pkgconf_queue_apply_func_t)(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth); -typedef bool (*pkgconf_error_handler_func_t)(const char *msg, const pkgconf_client_t *client, const void *data); - -struct pkgconf_client_ { - pkgconf_list_t dir_list; - pkgconf_list_t pkg_cache; - - pkgconf_list_t filter_libdirs; - pkgconf_list_t filter_includedirs; - - pkgconf_list_t global_vars; - - void *error_handler_data; - void *warn_handler_data; - void *trace_handler_data; - - pkgconf_error_handler_func_t error_handler; - pkgconf_error_handler_func_t warn_handler; - pkgconf_error_handler_func_t trace_handler; - - FILE *auditf; - - char *sysroot_dir; - char *buildroot_dir; - - unsigned int flags; - - char *prefix_varname; -}; - -/* client.c */ -PKGCONF_API void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data); -PKGCONF_API pkgconf_client_t * pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data); -PKGCONF_API void pkgconf_client_deinit(pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_free(pkgconf_client_t *client); -PKGCONF_API const char *pkgconf_client_get_sysroot_dir(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_sysroot_dir(pkgconf_client_t *client, const char *sysroot_dir); -PKGCONF_API const char *pkgconf_client_get_buildroot_dir(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_buildroot_dir(pkgconf_client_t *client, const char *buildroot_dir); -PKGCONF_API unsigned int pkgconf_client_get_flags(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_flags(pkgconf_client_t *client, unsigned int flags); -PKGCONF_API const char *pkgconf_client_get_prefix_varname(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_prefix_varname(pkgconf_client_t *client, const char *prefix_varname); -PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_warn_handler(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler, void *warn_handler_data); -PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_error_handler(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data); -PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_trace_handler(const pkgconf_client_t *client); -PKGCONF_API void pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t trace_handler, void *trace_handler_data); - -#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c))) -#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=') - -#define PKGCONF_PKG_PKGF_NONE 0x0000 -#define PKGCONF_PKG_PKGF_SEARCH_PRIVATE 0x0001 -#define PKGCONF_PKG_PKGF_ENV_ONLY 0x0002 -#define PKGCONF_PKG_PKGF_NO_UNINSTALLED 0x0004 -#define PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL 0x0008 -#define PKGCONF_PKG_PKGF_MERGE_PRIVATE_FRAGMENTS 0x0010 -#define PKGCONF_PKG_PKGF_SKIP_CONFLICTS 0x0020 -#define PKGCONF_PKG_PKGF_NO_CACHE 0x0040 -#define PKGCONF_PKG_PKGF_SKIP_ERRORS 0x0080 -#define PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE 0x0100 -#define PKGCONF_PKG_PKGF_SKIP_PROVIDES 0x0200 -#define PKGCONF_PKG_PKGF_REDEFINE_PREFIX 0x0400 -#define PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS 0x0800 -#define PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS 0x1000 - -#define PKGCONF_PKG_ERRF_OK 0x0 -#define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1 -#define PKGCONF_PKG_ERRF_PACKAGE_VER_MISMATCH 0x2 -#define PKGCONF_PKG_ERRF_PACKAGE_CONFLICT 0x4 -#define PKGCONF_PKG_ERRF_DEPGRAPH_BREAK 0x8 - -/* pkg.c */ -#if defined(__GNUC__) || defined(__INTEL_COMPILER) -#define PRINTFLIKE(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf__, fmtarg, firstvararg))) -#define DEPRECATED \ - __attribute__((deprecated)) -#else -#define PRINTFLIKE(fmtarg, firstvararg) -#define DEPRECATED -#endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */ - -PKGCONF_API bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3); -PKGCONF_API bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3); -PKGCONF_API bool pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t lineno, const char *funcname, const char *format, ...) PRINTFLIKE(5, 6); -PKGCONF_API bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data); - -#if defined(__GNUC__) || defined(__INTEL_COMPILER) -#define PKGCONF_TRACE(client, ...) do { \ - pkgconf_trace(client, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__); \ - } while (0); -#else -#define PKGCONF_TRACE(client, ...) do { \ - pkgconf_trace(client, __FILE__, __LINE__, __func__, __VA_ARGS__); \ - } while (0); -#endif - -PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_ref(const pkgconf_client_t *client, pkgconf_pkg_t *pkg); -PKGCONF_API void pkgconf_pkg_unref(pkgconf_client_t *client, pkgconf_pkg_t *pkg); -PKGCONF_API void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg); -PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_find(pkgconf_client_t *client, const char *name); -PKGCONF_API unsigned int pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth); -PKGCONF_API unsigned int pkgconf_pkg_verify_graph(pkgconf_client_t *client, pkgconf_pkg_t *root, int depth); -PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_verify_dependency(pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int *eflags); -PKGCONF_API const char *pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep); -PKGCONF_API unsigned int pkgconf_pkg_cflags(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth); -PKGCONF_API unsigned int pkgconf_pkg_libs(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth); -PKGCONF_API pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name); -PKGCONF_API pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name); - -PKGCONF_API int pkgconf_compare_version(const char *a, const char *b); -PKGCONF_API pkgconf_pkg_t *pkgconf_scan_all(pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func); -PKGCONF_API void pkgconf_pkg_dir_list_build(pkgconf_client_t *client); - -/* parse.c */ -PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *path, FILE *f); -PKGCONF_API void pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends); -PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends); -PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail); -PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list); -PKGCONF_API const char *pkgconf_dependency_to_str(const pkgconf_dependency_t *dep); -PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare); - -/* argvsplit.c */ -PKGCONF_API int pkgconf_argv_split(const char *src, int *argc, char ***argv); -PKGCONF_API void pkgconf_argv_free(char **argv); - -/* fragment.c */ -typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data); -PKGCONF_API void pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value); -PKGCONF_API void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string); -PKGCONF_API void pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private); -PKGCONF_API void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node); -PKGCONF_API void pkgconf_fragment_free(pkgconf_list_t *list); -PKGCONF_API void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data); -PKGCONF_API size_t pkgconf_fragment_render_len(const pkgconf_list_t *list, bool escape); -PKGCONF_API void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t len, bool escape); -PKGCONF_API char *pkgconf_fragment_render(const pkgconf_list_t *list, bool escape); -PKGCONF_API bool pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag); - -/* fileio.c */ -PKGCONF_API char *pkgconf_fgetline(char *line, size_t size, FILE *stream); - -/* tuple.c */ -PKGCONF_API pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *parent, const char *key, const char *value, bool parse); -PKGCONF_API char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key); -PKGCONF_API char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *list, const char *value); -PKGCONF_API void pkgconf_tuple_free(pkgconf_list_t *list); -PKGCONF_API void pkgconf_tuple_free_entry(pkgconf_tuple_t *tuple, pkgconf_list_t *list); -PKGCONF_API void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value); -PKGCONF_API char *pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key); -PKGCONF_API void pkgconf_tuple_free_global(pkgconf_client_t *client); -PKGCONF_API void pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv); - -/* queue.c */ -PKGCONF_API void pkgconf_queue_push(pkgconf_list_t *list, const char *package); -PKGCONF_API bool pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list); -PKGCONF_API void pkgconf_queue_free(pkgconf_list_t *list); -PKGCONF_API bool pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, void *data); -PKGCONF_API bool pkgconf_queue_validate(pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth); - -/* cache.c */ -PKGCONF_API pkgconf_pkg_t *pkgconf_cache_lookup(const pkgconf_client_t *client, const char *id); -PKGCONF_API void pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg); -PKGCONF_API void pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg); -PKGCONF_API void pkgconf_cache_free(pkgconf_client_t *client); - -/* audit.c */ -PKGCONF_API void pkgconf_audit_set_log(pkgconf_client_t *client, FILE *auditf); -PKGCONF_API void pkgconf_audit_log(pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3); -PKGCONF_API void pkgconf_audit_log_dependency(pkgconf_client_t *client, const pkgconf_pkg_t *dep, const pkgconf_dependency_t *depnode); - -/* path.c */ -PKGCONF_API void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter); -PKGCONF_API size_t pkgconf_path_split(const char *text, pkgconf_list_t *dirlist, bool filter); -PKGCONF_API size_t pkgconf_path_build_from_environ(const char *envvarname, const char *fallback, pkgconf_list_t *dirlist, bool filter); -PKGCONF_API bool pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist); -PKGCONF_API void pkgconf_path_free(pkgconf_list_t *dirlist); -PKGCONF_API bool pkgconf_path_relocate(char *buf, size_t buflen); - -#endif diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 59e003e..5b7aa1c 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> #include <libpkgconf/config.h> @@ -205,7 +206,7 @@ pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist) pkgconf_strlcpy(relocated, path, sizeof relocated); if (pkgconf_path_relocate(relocated, sizeof relocated)) - cpath = path; + cpath = relocated; PKGCONF_FOREACH_LIST_ENTRY(dirlist->head, n) { diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index fe4592a..92acdb2 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -13,11 +13,10 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/config.h> #include <libpkgconf/libpkgconf.h> -#include <assert.h> - /* * !doc * @@ -52,10 +51,9 @@ str_has_suffix(const char *str, const char *suffix) } static inline const char * -get_default_pkgconfig_path(void) +get_default_pkgconfig_path(char *outbuf, size_t outlen) { #ifdef _WIN32 - static char outbuf[MAX_PATH]; char namebuf[MAX_PATH]; char *p; @@ -71,27 +69,29 @@ get_default_pkgconfig_path(void) return PKG_DEFAULT_PATH; *p = '\0'; - pkgconf_strlcpy(outbuf, namebuf, sizeof outbuf); - pkgconf_strlcat(outbuf, "/", sizeof outbuf); - pkgconf_strlcat(outbuf, "../lib/pkgconfig", sizeof outbuf); - pkgconf_strlcat(outbuf, ";", sizeof outbuf); - pkgconf_strlcat(outbuf, namebuf, sizeof outbuf); - pkgconf_strlcat(outbuf, "/", sizeof outbuf); - pkgconf_strlcat(outbuf, "../share/pkgconfig", sizeof outbuf); + pkgconf_strlcpy(outbuf, namebuf, outlen); + pkgconf_strlcat(outbuf, "/", outlen); + pkgconf_strlcat(outbuf, "../lib/pkgconfig", outlen); + pkgconf_strlcat(outbuf, ";", outlen); + pkgconf_strlcat(outbuf, namebuf, outlen); + pkgconf_strlcat(outbuf, "/", outlen); + pkgconf_strlcat(outbuf, "../share/pkgconfig", outlen); return outbuf; +#else + (void) outbuf; + (void) outlen; #endif return PKG_DEFAULT_PATH; } static const char * -pkg_get_parent_dir(pkgconf_pkg_t *pkg) +pkg_get_parent_dir(pkgconf_pkg_t *pkg, char *buf, size_t buflen) { - static char buf[PKGCONF_BUFSIZE]; char *pathbuf; - pkgconf_strlcpy(buf, pkg->filename, sizeof buf); + pkgconf_strlcpy(buf, pkg->filename, buflen); pathbuf = strrchr(buf, PKG_DIR_SEP_S); if (pathbuf == NULL) pathbuf = strrchr(buf, '/'); @@ -119,7 +119,11 @@ pkgconf_pkg_dir_list_build(pkgconf_client_t *client) pkgconf_path_build_from_environ("PKG_CONFIG_PATH", NULL, &client->dir_list, true); if (!(client->flags & PKGCONF_PKG_PKGF_ENV_ONLY)) - pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", get_default_pkgconfig_path(), &client->dir_list, true); + { + char pathbuf[PKGCONF_BUFSIZE]; + + pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", get_default_pkgconfig_path(pathbuf, sizeof pathbuf), &client->dir_list, true); + } } typedef void (*pkgconf_pkg_parser_keyword_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value); @@ -186,13 +190,12 @@ pkgconf_pkg_parser_keyword_set(const pkgconf_client_t *client, pkgconf_pkg_t *pk } static const char * -determine_prefix(const pkgconf_pkg_t *pkg) +determine_prefix(const pkgconf_pkg_t *pkg, char *buf, size_t buflen) { - static char buf[PKGCONF_BUFSIZE]; char *pathiter; - pkgconf_strlcpy(buf, pkg->filename, sizeof buf); - pkgconf_path_relocate(buf, sizeof buf); + pkgconf_strlcpy(buf, pkg->filename, buflen); + pkgconf_path_relocate(buf, buflen); pathiter = strrchr(buf, PKG_DIR_SEP_S); if (pathiter == NULL) @@ -272,12 +275,14 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * { pkgconf_pkg_t *pkg; char readbuf[PKGCONF_BUFSIZE]; + char pathbuf[PKGCONF_BUFSIZE]; + char prefixbuf[PKGCONF_BUFSIZE]; char *idptr; size_t lineno = 0; pkg = calloc(sizeof(pkgconf_pkg_t), 1); pkg->filename = strdup(filename); - pkgconf_tuple_add(client, &pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg), true); + pkgconf_tuple_add(client, &pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg, pathbuf, sizeof pathbuf), true); /* make module id */ if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL) @@ -301,10 +306,7 @@ 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); + PKGCONF_TRACE(client, "%s:" SIZE_FMT_SPECIFIER " > [%s]", filename, lineno, readbuf); p = readbuf; while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.')) @@ -318,13 +320,8 @@ 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); - + pkgconf_warn(client, "%s:" SIZE_FMT_SPECIFIER ": warning: whitespace encountered while parsing key section\n", + pkg->filename, lineno); warned_key_whitespace = true; } @@ -346,12 +343,8 @@ 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); + pkgconf_warn(client, "%s:" SIZE_FMT_SPECIFIER ": warning: trailing whitespace encountered while parsing value section\n", + pkg->filename, lineno); warned_value_whitespace = true; } @@ -369,7 +362,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * pkgconf_tuple_add(client, &pkg->vars, key, value, true); else { - const char *relvalue = determine_prefix(pkg); + const char *relvalue = determine_prefix(pkg, prefixbuf, sizeof prefixbuf); if (relvalue != NULL) { pkgconf_tuple_add(client, &pkg->vars, "orig_prefix", value, true); @@ -412,46 +405,13 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg) { - /* - * The function leaks (issue #132 is reported). The whole concept of "static" - * packages is quite murky, so it's better just not to use it, at least - * until fixed by the library owners. In particular don't use - * pkgconf_queue_* functions. - */ - assert (pkg == NULL || (pkg->flags & PKGCONF_PKG_PROPF_STATIC) == 0); - - if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_STATIC) + if (pkg == NULL) 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. - */ - pkgconf_node_t *node; - PKGCONF_FOREACH_LIST_ENTRY(client->pkg_cache.head, node) - { - pkgconf_pkg_t *p = node->data; + if (pkg->flags & PKGCONF_PKG_PROPF_STATIC && !(pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL)) + return; - if (p == pkg) - { - pkgconf_cache_remove(client, pkg); - break; - } - } + pkgconf_cache_remove(client, pkg); pkgconf_dependency_free(&pkg->requires); pkgconf_dependency_free(&pkg->requires_private); @@ -465,6 +425,9 @@ pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg) pkgconf_tuple_free(&pkg->vars); + if (pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL) + return; + if (pkg->id != NULL) free(pkg->id); @@ -572,7 +535,7 @@ pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkg for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir)) { - static char filebuf[PKGCONF_BUFSIZE]; + char filebuf[PKGCONF_BUFSIZE]; pkgconf_pkg_t *pkg; FILE *f; @@ -694,6 +657,7 @@ pkgconf_pkg_find_in_registry_key(pkgconf_client_t *client, HKEY hkey, const char pkgconf_pkg_t * pkgconf_pkg_find(pkgconf_client_t *client, const char *name) { + char pathbuf[PKGCONF_BUFSIZE]; pkgconf_pkg_t *pkg = NULL; pkgconf_node_t *n; FILE *f; @@ -712,7 +676,7 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) pkg = pkgconf_pkg_new_from_file(client, name, f); if (pkg != NULL) { - pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); + pkgconf_path_add(pkg_get_parent_dir(pkg, pathbuf, sizeof pathbuf), &client->dir_list, true); return pkg; } } @@ -731,8 +695,6 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) if ((pkg = pkgconf_cache_lookup(client, name)) != NULL) { PKGCONF_TRACE(client, "%s is cached", name); - - pkg->flags |= PKGCONF_PKG_PROPF_CACHED; return pkg; } } @@ -1341,16 +1303,14 @@ pkgconf_pkg_verify_graph(pkgconf_client_t *client, pkgconf_pkg_t *root, int dept static unsigned int pkgconf_pkg_report_graph_error(pkgconf_client_t *client, pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgconf_dependency_t *node, unsigned int eflags) { - static bool already_sent_notice = false; - 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) & !client->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); pkgconf_error(client, "to the PKG_CONFIG_PATH environment variable\n"); - already_sent_notice = true; + client->already_sent_notice = true; } pkgconf_error(client, "Package '%s', required by '%s', not found\n", node->package, parent->id); diff --git a/libpkgconf/pkg.c.orig b/libpkgconf/pkg.c.orig index 27bc3c7..1a2f6b4 100644 --- a/libpkgconf/pkg.c.orig +++ b/libpkgconf/pkg.c.orig @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/config.h> #include <libpkgconf/libpkgconf.h> @@ -50,10 +51,9 @@ str_has_suffix(const char *str, const char *suffix) } static inline const char * -get_default_pkgconfig_path(void) +get_default_pkgconfig_path(char *outbuf, size_t outlen) { #ifdef _WIN32 - static char outbuf[MAX_PATH]; char namebuf[MAX_PATH]; char *p; @@ -69,27 +69,29 @@ get_default_pkgconfig_path(void) return PKG_DEFAULT_PATH; *p = '\0'; - pkgconf_strlcpy(outbuf, namebuf, sizeof outbuf); - pkgconf_strlcat(outbuf, "/", sizeof outbuf); - pkgconf_strlcat(outbuf, "../lib/pkgconfig", sizeof outbuf); - pkgconf_strlcat(outbuf, ";", sizeof outbuf); - pkgconf_strlcat(outbuf, namebuf, sizeof outbuf); - pkgconf_strlcat(outbuf, "/", sizeof outbuf); - pkgconf_strlcat(outbuf, "../share/pkgconfig", sizeof outbuf); + pkgconf_strlcpy(outbuf, namebuf, outlen); + pkgconf_strlcat(outbuf, "/", outlen); + pkgconf_strlcat(outbuf, "../lib/pkgconfig", outlen); + pkgconf_strlcat(outbuf, ";", outlen); + pkgconf_strlcat(outbuf, namebuf, outlen); + pkgconf_strlcat(outbuf, "/", outlen); + pkgconf_strlcat(outbuf, "../share/pkgconfig", outlen); return outbuf; +#else + (void) outbuf; + (void) outlen; #endif return PKG_DEFAULT_PATH; } static const char * -pkg_get_parent_dir(pkgconf_pkg_t *pkg) +pkg_get_parent_dir(pkgconf_pkg_t *pkg, char *buf, size_t buflen) { - static char buf[PKGCONF_BUFSIZE]; char *pathbuf; - pkgconf_strlcpy(buf, pkg->filename, sizeof buf); + pkgconf_strlcpy(buf, pkg->filename, buflen); pathbuf = strrchr(buf, PKG_DIR_SEP_S); if (pathbuf == NULL) pathbuf = strrchr(buf, '/'); @@ -117,7 +119,11 @@ pkgconf_pkg_dir_list_build(pkgconf_client_t *client) pkgconf_path_build_from_environ("PKG_CONFIG_PATH", NULL, &client->dir_list, true); if (!(client->flags & PKGCONF_PKG_PKGF_ENV_ONLY)) - pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", get_default_pkgconfig_path(), &client->dir_list, true); + { + char pathbuf[PKGCONF_BUFSIZE]; + + pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", get_default_pkgconfig_path(pathbuf, sizeof pathbuf), &client->dir_list, true); + } } typedef void (*pkgconf_pkg_parser_keyword_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, const ptrdiff_t offset, char *value); @@ -184,13 +190,12 @@ pkgconf_pkg_parser_keyword_set(const pkgconf_client_t *client, pkgconf_pkg_t *pk } static const char * -determine_prefix(const pkgconf_pkg_t *pkg) +determine_prefix(const pkgconf_pkg_t *pkg, char *buf, size_t buflen) { - static char buf[PKGCONF_BUFSIZE]; char *pathiter; - pkgconf_strlcpy(buf, pkg->filename, sizeof buf); - pkgconf_path_relocate(buf, sizeof buf); + pkgconf_strlcpy(buf, pkg->filename, buflen); + pkgconf_path_relocate(buf, buflen); pathiter = strrchr(buf, PKG_DIR_SEP_S); if (pathiter == NULL) @@ -270,12 +275,14 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * { pkgconf_pkg_t *pkg; char readbuf[PKGCONF_BUFSIZE]; + char pathbuf[PKGCONF_BUFSIZE]; + char prefixbuf[PKGCONF_BUFSIZE]; char *idptr; size_t lineno = 0; pkg = calloc(sizeof(pkgconf_pkg_t), 1); pkg->filename = strdup(filename); - pkgconf_tuple_add(client, &pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg), true); + pkgconf_tuple_add(client, &pkg->vars, "pcfiledir", pkg_get_parent_dir(pkg, pathbuf, sizeof pathbuf), true); /* make module id */ if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL) @@ -299,7 +306,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * lineno++; - PKGCONF_TRACE(client, "%s:%zu > [%s]", filename, lineno, readbuf); + PKGCONF_TRACE(client, "%s:" SIZE_FMT_SPECIFIER " > [%s]", filename, lineno, readbuf); p = readbuf; while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.')) @@ -313,7 +320,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * { if (!warned_key_whitespace) { - pkgconf_warn(client, "%s:%zu: warning: whitespace encountered while parsing key section\n", + pkgconf_warn(client, "%s:" SIZE_FMT_SPECIFIER ": warning: whitespace encountered while parsing key section\n", pkg->filename, lineno); warned_key_whitespace = true; } @@ -336,7 +343,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * { if (!warned_value_whitespace && op == '=') { - pkgconf_warn(client, "%s:%zu: warning: trailing whitespace encountered while parsing value section\n", + pkgconf_warn(client, "%s:" SIZE_FMT_SPECIFIER ": warning: trailing whitespace encountered while parsing value section\n", pkg->filename, lineno); warned_value_whitespace = true; } @@ -355,7 +362,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * pkgconf_tuple_add(client, &pkg->vars, key, value, true); else { - const char *relvalue = determine_prefix(pkg); + const char *relvalue = determine_prefix(pkg, prefixbuf, sizeof prefixbuf); if (relvalue != NULL) { pkgconf_tuple_add(client, &pkg->vars, "orig_prefix", value, true); @@ -398,7 +405,10 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg) { - if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_STATIC) + if (pkg == NULL) + return; + + if (pkg->flags & PKGCONF_PKG_PROPF_STATIC && !(pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL)) return; pkgconf_cache_remove(client, pkg); @@ -415,6 +425,9 @@ pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg) pkgconf_tuple_free(&pkg->vars); + if (pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL) + return; + if (pkg->id != NULL) free(pkg->id); @@ -522,7 +535,7 @@ pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkg for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir)) { - static char filebuf[PKGCONF_BUFSIZE]; + char filebuf[PKGCONF_BUFSIZE]; pkgconf_pkg_t *pkg; FILE *f; @@ -644,6 +657,7 @@ pkgconf_pkg_find_in_registry_key(pkgconf_client_t *client, HKEY hkey, const char pkgconf_pkg_t * pkgconf_pkg_find(pkgconf_client_t *client, const char *name) { + char pathbuf[PKGCONF_BUFSIZE]; pkgconf_pkg_t *pkg = NULL; pkgconf_node_t *n; FILE *f; @@ -662,7 +676,7 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) pkg = pkgconf_pkg_new_from_file(client, name, f); if (pkg != NULL) { - pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); + pkgconf_path_add(pkg_get_parent_dir(pkg, pathbuf, sizeof pathbuf), &client->dir_list, true); return pkg; } } @@ -681,8 +695,6 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) if ((pkg = pkgconf_cache_lookup(client, name)) != NULL) { PKGCONF_TRACE(client, "%s is cached", name); - - pkg->flags |= PKGCONF_PKG_PROPF_CACHED; return pkg; } } @@ -1291,16 +1303,14 @@ pkgconf_pkg_verify_graph(pkgconf_client_t *client, pkgconf_pkg_t *root, int dept static unsigned int pkgconf_pkg_report_graph_error(pkgconf_client_t *client, pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgconf_dependency_t *node, unsigned int eflags) { - static bool already_sent_notice = false; - 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) & !client->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); pkgconf_error(client, "to the PKG_CONFIG_PATH environment variable\n"); - already_sent_notice = true; + client->already_sent_notice = true; } pkgconf_error(client, "Package '%s', required by '%s', not found\n", node->package, parent->id); diff --git a/libpkgconf/queue.c b/libpkgconf/queue.c index 227b160..73507fa 100644 --- a/libpkgconf/queue.c +++ b/libpkgconf/queue.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* diff --git a/libpkgconf/stdinc.h b/libpkgconf/stdinc.h index c373a9a..43d7eeb 100644 --- a/libpkgconf/stdinc.h +++ b/libpkgconf/stdinc.h @@ -16,14 +16,6 @@ #ifndef __STDINC_H #define __STDINC_H -/* - * The problem is that g++ defines this macro by default (in contrast to gcc) - * causing the "redefined macro" warning when this header is (implicitly) - * included into the C++ source file (issue #135 is reported). So we move this - * definition into the buildfile, - */ -/* #define _GNU_SOURCE */ - #include <ctype.h> #include <stdio.h> #include <stdlib.h> @@ -36,18 +28,14 @@ #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN - -/* - * Add to avoid clashing of min/max macros with C++ min/max functions (issue - * #137 is reported). - */ -# ifndef NOMINMAX -# define NOMINMAX /* No min and max macros. */ -# endif - # include <windows.h> # include <malloc.h> # define PATH_DEV_NULL "nul" +# ifdef _WIN64 +# define SIZE_FMT_SPECIFIER "%llu" +# else +# define SIZE_FMT_SPECIFIER "%lu" +# endif # ifndef ssize_t # ifndef __MINGW32__ # include <BaseTsd.h> @@ -63,6 +51,7 @@ # endif #else # define PATH_DEV_NULL "/dev/null" +# define SIZE_FMT_SPECIFIER "%zu" # include <dirent.h> # include <unistd.h> #endif diff --git a/libpkgconf/stdinc.h.orig b/libpkgconf/stdinc.h.orig deleted file mode 100644 index d8efcf5..0000000 --- a/libpkgconf/stdinc.h.orig +++ /dev/null @@ -1,54 +0,0 @@ -/* - * stdinc.h - * pull in standard headers (including portability hacks) - * - * Copyright (c) 2012 pkgconf authors (see AUTHORS). - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * This software is provided 'as is' and without any warranty, express or - * implied. In no event shall the authors be liable for any damages arising - * from the use of this software. - */ - -#ifndef __STDINC_H -#define __STDINC_H - -#define _GNU_SOURCE -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <stdbool.h> -#include <stdarg.h> -#include <string.h> -#include <sys/types.h> -#include <stdint.h> - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include <windows.h> -# include <malloc.h> -# define PATH_DEV_NULL "nul" -# ifndef ssize_t -# ifndef __MINGW32__ -# include <BaseTsd.h> -# else -# include <basetsd.h> -# endif -# define ssize_t SSIZE_T -# endif -# ifndef __MINGW32__ -# include "win-dirent.h" -# else -# include <dirent.h> -# endif -#else -# define PATH_DEV_NULL "/dev/null" -# include <dirent.h> -# include <unistd.h> -#endif - -#endif diff --git a/libpkgconf/tuple.c b/libpkgconf/tuple.c index e105adc..b0cda45 100644 --- a/libpkgconf/tuple.c +++ b/libpkgconf/tuple.c @@ -13,6 +13,7 @@ * from the use of this software. */ +#include <libpkgconf/stdinc.h> #include <libpkgconf/libpkgconf.h> /* @@ -230,7 +231,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const *bptr++ = *ptr; else if (*(ptr + 1) == '{') { - static char varname[PKGCONF_BUFSIZE]; + char varname[PKGCONF_BUFSIZE]; char *vptr = varname; const char *pptr; char *kv, *parsekv; |