libpkgconf/path.c


Log

Author Commit Date CI Message
Ariadne Conill aa5813ac 2025-05-31T00:06:57 libpkgconf: path: refactor windows registry PKG_CONFIG_PATH support Now we add to the search list rather than falling back to the registry after the search list fails to find a package. Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
Ariadne Conill 2983d311 2025-05-28T23:21:24 libpkgconf: path: gracefully handle memory alloc failures Found-by: GCC -fanalyzer Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
Ariadne Conill 7b8865d1 2025-05-08T13:07:30 libpkgconf: path: add pkgconf_path_prepend_list Previously when processing --with-path entries we were adding to the tail of the search list. In reality, we expect --with-path entries to be treated in an equivalent way to PKG_CONFIG_PATH. Accordingly, add a variant of pkgconf_path_copy_list which prepends instead. Related: https://github.com/pkgconf/pkgconf/issues/400 Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
Ariadne Conill 792e2c62 2025-02-04T17:00:30 libpkgconf: path: get rid of unused win32-specific variable Windows builder was warning about this. Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
Sam James d454f62c 2023-11-05T22:17:02 libpkgconf: fix -Walloc-size GCC 14 introduces a new -Walloc-size included in -Wextra which gives: ``` libpkgconf/personality.c:260:11: warning: allocation of insufficient size '1' for type 'pkgconf_cross_personality_t' {aka 'struct pkgconf_cross_personality_'} with size '48' [-Walloc-size] libpkgconf/queue.c:46:33: warning: allocation of insufficient size '1' for type 'pkgconf_queue_t' {aka'struct pkgconf_queue_'} with size '16' [-Walloc-size] libpkgconf/client.c:164:33: warning: allocation of insufficient size '1' for type 'pkgconf_client_t' {aka 'struct pkgconf_client_'} with size '120' [-Walloc-size] libpkgconf/path.c:105:14: warning: allocation of insufficient size '1' for type 'pkgconf_path_t' {aka 'struct pkgconf_path_'} with size '24' [-Walloc-size] libpkgconf/path.c:237:22: warning: allocation of insufficient size '1' for type 'pkgconf_path_t' {aka 'struct pkgconf_path_'} with size '24' [-Walloc-size] libpkgconf/tuple.c:239:34: warning: allocation of insufficient size '1' for type 'pkgconf_tuple_t' {aka 'struct pkgconf_tuple_'} with size '24' [-Walloc-size] libpkgconf/dependency.c:133:13: warning: allocation of insufficient size '1' for type 'pkgconf_dependency_t' {aka 'struct pkgconf_dependency_'} with size '44' [-Walloc-size] libpkgconf/dependency.c:472:17: warning: allocation of insufficient size '1' for type 'pkgconf_dependency_t' {aka 'struct pkgconf_dependency_'} with size '44' [-Walloc-size] libpkgconf/fragment.c:146:22: warning: allocation of insufficient size '1' for type 'pkgconf_fragment_t' {aka 'struct pkgconf_fragment_'} with size '24' [-Walloc-size] libpkgconf/fragment.c:195:22: warning: allocation of insufficient size '1' for type 'pkgconf_fragment_t' {aka 'struct pkgconf_fragment_'} with size '24' [-Walloc-size] libpkgconf/fragment.c:356:14: warning: allocation of insufficient size '1' for type 'pkgconf_fragment_t' {aka 'struct pkgconf_fragment_'} with size '24' [-Walloc-size] libpkgconf/pkg.c:422:13: warning: allocation of insufficient size '1' for type 'pkgconf_pkg_t' {aka 'struct pkgconf_pkg_'} with size '188' [-Walloc-size] libpkgconf/client.c:164:33: warning: allocation of insufficient size '1' for type 'pkgconf_client_t' {aka 'struct pkgconf_client_'} with size '224' [-Walloc-size] libpkgconf/personality.c:260:11: warning: allocation of insufficient size '1' for type 'pkgconf_cross_personality_t' {aka 'struct pkgconf_cross_personality_'} with size '96' [-Walloc-size] libpkgconf/dependency.c:133:13: warning: allocation of insufficient size '1' for type 'pkgconf_dependency_t' {aka 'struct pkgconf_dependency_'} with size '80' [-Walloc-size] libpkgconf/dependency.c:472:17: warning: allocation of insufficient size '1' for type 'pkgconf_dependency_t' {aka 'struct pkgconf_dependency_'} with size '80' [-Walloc-size] libpkgconf/path.c:105:14: warning: allocation of insufficient size '1' for type 'pkgconf_path_t' {aka 'struct pkgconf_path_'} with size '48' [-Walloc-size] libpkgconf/path.c:237:22: warning: allocation of insufficient size '1' for type 'pkgconf_path_t' {aka 'struct pkgconf_path_'} with size '48' [-Walloc-size] libpkgconf/queue.c:46:33: warning: allocation of insufficient size '1' for type 'pkgconf_queue_t' {aka 'struct pkgconf_queue_'} with size '32' [-Walloc-size] libpkgconf/tuple.c:239:34: warning: allocation of insufficient size '1' for type 'pkgconf_tuple_t' {aka 'struct pkgconf_tuple_'} with size '48' [-Walloc-size] libpkgconf/fragment.c:146:22: warning: allocation of insufficient size '1' for type 'pkgconf_fragment_t' {aka 'struct pkgconf_fragment_'} with size '48' [-Walloc-size] libpkgconf/fragment.c:195:22: warning: allocation of insufficient size '1' for type 'pkgconf_fragment_t' {aka 'struct pkgconf_fragment_'} with size '48' [-Walloc-size] libpkgconf/fragment.c:356:14: warning: allocation of insufficient size '1' for type 'pkgconf_fragment_t' {aka 'struct pkgconf_fragment_'} with size '48' [-Walloc-size] libpkgconf/pkg.c:422:13: warning: allocation of insufficient size '1' for type 'pkgconf_pkg_t' {aka 'struct pkgconf_pkg_'} with size '360' [-Walloc-size] ``` The calloc prototype is: ``` void *calloc(size_t nmemb, size_t size); ``` So, just swap the number of members and size arguments to match the prototype, as we're initialising 1 struct of size `sizeof(struct ...)`. GCC then sees we're not doing anything wrong. The only exception there is for argv which I fixed while at it. Signed-off-by: Sam James <sam@gentoo.org>
Ariadne Conill 652aff97 2023-10-08T22:27:56 path: add pkgconf_path_prepend API for --with-path Otherwise, PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR elements would be processed backwards. Fixes: 384ade5 (path: prepend paths rather than append paths when processing --with-path arguments) Closes: #250 Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
Ariadne Conill 384ade5f 2023-08-04T08:24:32 path: prepend paths rather than append paths when processing --with-path arguments
Dylan Baker c0fa7879 2022-04-01T14:15:43 libpkgconf: zero path lists after freeing This is required to make the pointer safely re-usable after being freed, otherwise the list still says that it has nodes, but they point nowhere. This is particularly important for libpkgconf, if a caller needs to re-enter the library after freeing a path in a static path (such as the default personality)
Christoph Reiter 4f73f6a1 2021-03-20T11:01:14 Rework path handling on native Windows The current approach was to parse the .pc and, detect the prefix, throw everything together and at the end replace all \ with / to not produce invalid escape sequences. This has the problem that escaping in .pc files is ignored and no longer possible. Also in case the prefix path has a space in it the result would be invalid because of missing escaping. This changes the following things: * We no longer normalize values at the end. Instead we assume .pc files use "/" as a directory separator or "\\", same format as under Unix. "\" alone no longer works. This shouldn't be a problem since most build tools produce .pc files with "/" like meson, cmake, autotools. * When injecting the prefix at runtime we convert the prefix to use "/" and escape spaces so that in combination with the .pc content the result is a valid escaped path value again. This patch has been used in MSYS2 for some months now. See #212
Christoph Reiter 4be39c59 2021-03-19T16:59:02 Remove usage of cygwin_conv_path() under cygwin/msys This converted Unix paths to Windows paths, but all cygwin tools work with Unix paths so this shouldn't be needed. There is one use case if you use a cygwin pkgconf with a non-cygwin toolchain, but pkgconf works reasonable well natively now so this shouldn't be needed anymore and more likely leads to problems and confusion. Both cygwin and msys have patched this out already: * https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/pkgconf.git;a=blob;f=pkgconf.cygport;h=e5d003f3f3dfc9e374b916974018022ad8d68852;hb=HEAD#l55 * https://github.com/msys2/MSYS2-packages/blob/a4bce0c2943109e7d06c8660d91b89065eb09bea/pkgconf/PKGBUILD#L26
Ariadne Conill dbb6a232 2021-03-18T06:56:55 path: don't use PATH_MAX, use PKGCONF_ITEM_SIZE * 4 for realpath buffer
Fabian Groffen 13a5d9a5 2021-01-08T10:56:41 libpkgconf: path: supply buffer to realpath To avoid a crash on some platforms (like Darwin 9) provide a buffer to realpath(3). Darwin 9 (last PPC target) documents realpath needs to be given a buffer to the resolved_path argument large enough to hold PATH_MAX bytes. With NULL argument it crashes. Solaris makes no mention of resolved_path to be allowed NULL, yet recent versions accept it and malloc(3) accordingly. Because the documentation explicitly mentions PATH_MAX being the limit to what realpath(3) would write in resolved_path, switching to a static buffer here doesn't limit resolution compared to dynamically allocating a buffer by realpath(3). While this change requires a bit more space on the stack, it avoids a malloc/free sequence, and allows successful operation on (older) platforms that lack support for dynamically allocating a return buffer in realpath(3). Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Ariadne Conill 2a8bebf2 2020-06-11T18:00:56 libpkgconf: path: rewrite DOS paths in non-cygwin case too
Ariadne Conill 7e0b0fad 2019-07-11T03:38:58 libpkgconf: path: fix memory leak when deduping paths (closes #39)
Alexander Tsoy db9c1e96 2019-06-07T19:19:28 fix the order of header includes config.h should be included before stdinc.h, otherwise large file support is not enabled. Downstream bug: https://bugs.gentoo.org/687548
William Pitcock 3afd14c4 2019-03-23T22:27:05 libpkgconf: path: use realpath(3) to deduplicate the search path closes #24
William Pitcock 43e8c7b4 2018-05-09T16:35:21 libpkgconf: path: add path list copying function
William Pitcock 4589274c 2017-10-16T12:56:19 libpkgconf: start to remove PKGCONF_BUFSIZE allocations from the stack. (closes #149) Patch by Karen Arutyunov.
William Pitcock 36551cca 2017-10-16T11:30:22 libpkgconf: path: relocate the path before doing dedup checks (closes #151)
William Pitcock 3bc2e21d 2017-10-16T11:25:52 libpkgconf: path: ensure entire buffer is zeroed before calling realpath() on it (closes #150)
William Pitcock e9fd43ca 2017-09-17T23:38:25 libpkgconf: clean up header includes (closes #137)
William Pitcock a6d6b88d 2017-09-08T18:27:04 libpkgconf: path: fix logic error in path relocation case when matching against a list (closes #129)
Dan Kegel 4d7b4d7c 2017-06-04T19:19:55 Minimal tweaks to compile with Visual C 2015
John Hein 9b255d46 2017-01-26T15:27:48 If PKG_CONFIG_PATH element is a sym link, use the link destination instead of the link for inode caching checks. See issue 112 & issue 110 (https://github.com/pkgconf/pkgconf/issues)
John Hein 76b8e0a2 2017-01-24T23:30:58 Normalize the path to remove duplicate / separators rather than possibly altering the path with realpath(3). Leave sym links as is in path components. This is also cheaper than realpath(3), and works on platforms that don't have realpath(3). Note: if this is accepted, the check for realpath in configure.ac can be removed, and some docs that mention realpath will be adjusted.
William Pitcock b06bbe75 2017-01-23T23:17:26 libpkgconf: path: only enable cygwin path relocation backend for msys (ref #72)
William Pitcock 1ee3c12f 2017-01-19T10:43:23 libpkgconf: path: use pkgconf_path_relocate() when matching paths
William Pitcock fa927fd3 2017-01-19T10:36:07 libpkgconf: path: pkgconf_path_relocate(): implement realpath backend
William Pitcock 03158322 2017-01-19T10:31:40 doc: document pkgconf_path_relocate()
William Pitcock 147fd807 2017-01-13T20:12:38 path: relocate system libdir/includedir if appropriate
William Pitcock 87a5a1f0 2017-01-13T20:08:22 path: when stubbing pkgconf_path_relocate(), suppress unused variables warnings
William Pitcock 1369f558 2017-01-13T20:04:38 path: add new pkgconf_path_relocate() API which is a stub when path relocation is not needed
Baptiste Daroussin 3b3f1dc7 2017-01-07T17:57:37 Fix gcc warnings
Baptiste Daroussin 2e855972 2017-01-07T17:52:44 inode cache: ensure we never use an unitilized struct stat
Graham Ollis 9c426b6f 2016-12-31T13:11:08 do not filter non-existent directories if filter is off
William Pitcock 92f566ff 2016-12-30T11:39:45 libpkgconf: path: check both device node and inode for dedup. pointed out by @plicease
William Pitcock 23050315 2016-12-30T11:13:04 libpkgconf: path: make the duplicate filtering opt-in. some path lists should not be deduped (compiler path lists, for example)
William Pitcock bad0da0c 2016-12-30T11:01:15 libpkgconf: path: filter out duplicate path entries by inode if possible (closes #102)
William Pitcock aa041b41 2016-12-30T10:44:01 libpkgconf: path: add naive path list filtering function
William Pitcock f6b074f2 2016-12-21T19:50:05 libpkgconf: path: make pkgconf_path_match_list() take a const list argument
William Pitcock 4cc0d017 2016-12-10T20:14:42 libpkgconf: document path module
William Pitcock e7f48465 2016-12-02T00:04:43 libpkgconf: path: add cleanup functions
William Pitcock 4bb46e20 2016-11-30T22:32:17 libpkgconf: add path matching and environment building functions
William Pitcock f4da1082 2016-11-30T22:15:13 libpkgconf: refactor some path operations