Commit Graph

162 Commits (a7c29fec18b67386d09373d785a19faca2a45e4d)

Author SHA1 Message Date
Colin Gillespie 5aeb469b81 libpkgconf: fix memory leak
ci/woodpecker/push/woodpecker Pipeline was successful Details
Signed-off-by: Colin Gillespie <colin@cgillespie.xyz>
2023-10-08 22:46:53 +00:00
Ariadne Conill ee702658cd use PRIu64 format specifiers for some uint64 identifiers in trace logging
ci/woodpecker/push/woodpecker Pipeline was successful Details
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
2023-09-02 21:05:03 -07:00
Colin Gillespie 66994f1533 cli: fix --modversion not showing version in various cases
ci/woodpecker/push/woodpecker Pipeline was successful Details
There are numerous edge cases where version is wrong or missing when
matching the dependency queue to resolved packages. This adds the
dependency name as it appears in the dependency queue to each package as
it is resolved, allowing for a simple and correct comparison when
printing.

Signed-off-by: Colin Gillespie <colin@cgillespie.xyz>
2023-09-02 20:57:46 -07:00
Ariadne Conill a265f8a42b libpkgconf: pkg: fix long-standing bug where -uninstalled pkg-config files would have the wrong identifier
ci/woodpecker/push/woodpecker Pipeline was successful Details
2023-08-17 11:53:07 -07:00
Ariadne Conill 5d0e2f5092 Track packages using a lifetime unique identifier
Use that identifier to cancel graph edges rather than the number of hits,
which biases the earliest edge rather than the latest.
2023-08-04 08:19:42 +00:00
Taylor R Campbell 212c85863a Avoid undefined behaviour with the ctype(3) functions.
ci/woodpecker/push/woodpecker Pipeline was successful Details
fix https://github.com/pkgconf/pkgconf/issues/291

As defined in the C standard:

        In all cases the argument is an int, the value of which shall
        be representable as an unsigned char or shall equal the value
        of the macro EOF.  If the argument has any other value, the
        behavior is undefined.

This is because they're designed to work with the int values returned
by getc or fgetc; they need extra work to handle a char value.

If EOF is -1 (as it almost always is), with 8-bit bytes, the allowed
inputs to the ctype(3) functions are:

        {-1, 0, 1, 2, 3, ..., 255}.

However, on platforms where char is signed, such as x86 with the
usual ABI, code like

        char *ptr = ...;
        ... isspace(*ptr) ...

may pass in values in the range:

        {-128, -127, -126, ..., -2, -1, 0, 1, ..., 127}.

This has two problems:

1. Inputs in the set {-128, -127, -126, ..., -2} are forbidden.

2. The non-EOF byte 0xff is conflated with the value EOF = -1, so
   even though the input is not forbidden, it may give the wrong
   answer.

Casting char to unsigned int first before passing the result to
ctype(3) doesn't help: inputs like -128 are unchanged by this cast,
because (on a two's-complement machine with 32-bit int and unsigned
int), converting the signed char with integer value -128 to unsigned
int gives integer value 2^32 - 128 = 0xffffff80, which is out of
range, and which is converted in int back to -128, which is also out
of range.

It is necessary to cast char inputs to unsigned char first; you can
then cast to unsigned int if you like but there's no need because the
functions will always convert the argument to int by definition.  So
the above fragment needs to be:

        char *ptr = ...;
        ... isspace((unsigned char)*ptr) ...

This patch changes unsigned int casts to unsigned char casts, and
adds unsigned char casts where they are missing.
2023-05-02 11:43:56 -07:00
Ariadne Conill d9e507cc6e pkg: do not do serial checks for flattened solutions, as they are already flattened 2023-01-21 21:31:38 +00:00
Ariadne Conill e2a12fd4c2 main: reset solver when solving for library groups
ci/woodpecker/push/woodpecker Pipeline was successful Details
2023-01-21 20:39:53 +00:00
Doug Freed 08db74c474 pkg: make pkgconf_compare_version consistent
The code taken from rpmvercmp in pkg-config returns -1 if a is less than
b, 0 if a is equal to b, and 1 if a is greater than b. This matches the
expectations of the comparison operators that use this function.
However, the tilde handling, the NULL handling, and the docstring all do
the opposite.

This fixes the tilde handling, the NULL handling, and the docstring to
match the behavior of the rpmvercmp code and the expectations of the
comparison operators.
2023-01-20 22:21:31 +00:00
Ariadne Conill ced9bee613 pkg: remove dead store in pkgconf_compare_version
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-08-16 18:51:11 +00:00
Ariadne Conill 696124b608 pkg: add support for parsing the URL from pc files 2022-08-12 12:36:21 +00:00
Ariadne Conill aa99ddf789 pkg: add Copyright and Maintainer fields
ci/woodpecker/push/woodpecker Pipeline was successful Details
These are helpful pieces of information for BOM documents
generated by pkgconf.
2022-08-11 15:52:33 +00:00
Ariadne Conill 28b5d57b98 pkg: free SPDX license tags when a package is destroyed
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-08-08 10:25:24 +00:00
Ariadne Conill 7e9aa7e1fc pkg: do not break cycles across dependency lists
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-08-08 09:56:28 +00:00
Ariadne Conill 69f630aadc pkg: only advance serial if we are actually traversing from a root 2022-08-08 09:34:45 +00:00
Ariadne Conill 0e05308f9c pkg: add SPDX license assertion to pkgconf builtin 2022-08-07 04:35:29 +00:00
Ariadne Conill 1389aa05ba pkg: add pkgconf_pkg_t.license field
ci/woodpecker/push/woodpecker Pipeline was successful Details
The pkgconf_pkg_t.license field maps to the new License keyword, and
should be an SPDX license expression.
2022-08-07 04:21:22 +00:00
Ariadne Conill 7edfdbff0b pkg: upgrade circular reference trace to a warning
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-08-07 01:29:21 +00:00
Ariadne Conill 662668d082 pkg: add trace log when breaking a circular reference
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-08-07 01:09:07 +00:00
Dylan Baker 1cfa2d1e20 pkg: prevent circular ownership
Otherwise in a case where A references B, and B references A, A and B
will have mutual ownership of each other and prevent each other from
being free'd.
2022-08-04 15:52:10 -07:00
Dylan Baker 4934205737 pkg: add name of pkg being refed/unrefed to debug outpu 2022-08-04 15:52:10 -07:00
Dylan Baker a391f9b650 pkg: use goto cleanup idiom 2022-08-04 15:52:10 -07:00
Dylan Baker 4a1119aa2a dependency: Fix reference counting of dependency_addraw
We only want a reference to be added for the value inserted into the
list, not the one returned. The returned one is unowned until it reaches
the public dependency_add function, which returns an owned pointer
instead. This makes things semantically more correct.

Unfortunately, this means in a few cases we have to write some ugly
code like:
```c
pkgconf_dependency_t *dep = pkgcond_dependency_add("args");
pkgconf_dependency_unref(dep->owner, dep);
```
2022-08-04 15:52:10 -07:00
Ariadne Conill f8aefea7ec pkg: add flags argument to pkgconf_pkg_new_from_file 2022-07-26 17:13:15 +00:00
Ariadne Conill 297e18f2c8 tuple: add flags parameter to pkgconf_tuple_parse 2022-07-26 17:08:48 +00:00
Ariadne Conill b0802cb3d1 Revert "pkgconf_pkg_parser_value_set(): fix code-path ordering bug."
ci/woodpecker/push/woodpecker Pipeline was successful Details
This reverts commit 13fe4c8c58.
2022-06-26 19:41:31 +00:00
Ariadne Conill a61193c723 pkg: fix sysroot_dir logic for github 213
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-26 19:16:00 +00:00
Ariadne Conill 5817e8848f pkg: track the number of hits a package has gotten while solving for dependencies
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-26 07:22:56 +00:00
Ariadne Conill 6ae17bd0ef pkg: split pkgconf_pkg_traverse into a serial-modifying version 2022-06-26 06:05:40 +00:00
Ariadne Conill 2b82a4f63e use a serial instead of PKGCONF_PKG_PROPF_SEEN 2021-10-07 00:27:32 -06:00
Ariadne Conill c547edd07f deconst the client on pkgconf_dependency_add() 2021-10-06 11:52:18 -06:00
Ariadne Conill ceece2c195 pkg: fix up comment about issue #213 workaround 2021-07-24 19:47:33 -06:00
Sandro Mani ed86f2dda3 Don't prepend sysroot_dir if pkg-config file lies outside of sysroot_dir 2021-07-24 20:43:58 -05:00
midipix 13fe4c8c58 pkgconf_pkg_parser_value_set(): fix code-path ordering bug.
Prior to this commit, the code path responsible for prefix redefinition
(motivated by --define-prefix or otherwise) was visited more than
once, specifically since the check ignored pkg->owner->prefix_varname.
2021-06-18 14:42:41 -05:00
Christoph Reiter 4f73f6a1d6 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
2021-03-20 06:59:38 -08:00
Ryan Scott ab404bc25b Fix #209
This commit fixes #209 by applying the suggestion from
https://github.com/pkgconf/pkgconf/issues/209#issuecomment-771609136.
2021-02-05 23:57:10 -07:00
Christoph Reiter 869f2a84d6 pkgconf_pkg_parser_version_func: fix whitespace detection
In case the version string has no whitespace then strcspn() returns
strlen() of the input, so whitespace is only found if len != strlen.

This fixes invalid warnings when parsing version fields.
2020-11-28 19:17:03 -07:00
Tobias Stoeckmann f818a69b3d libpkgconf: pkg: fix out ouf boundary access
If a file with a matching "uninstalled" name exists but cannot be
parsed, an invalid memory area is accessed.

How to reproduce:
$ touch poc-uninstalled.pc
$ PKG_CONFIG_PATH=. pkgconf poc
2020-06-10 00:20:36 -06:00
Ariadne Conill c613eb5cce libpkgconf: pkg: use a second pointer for demunging windows paths 2020-05-26 13:42:39 -06:00
Ariadne Conill e70b536ea3 libpkgconf: pkg: when generating a search path, use the correct path separator
Before, this could result in generated paths like C:\foo\pkgconfig/bar.pc on Windows.
2020-05-26 11:01:46 -06:00
Ariadne Conill 0253fddc1d libpkgconf: pkg: fix computation of pkgconf_pkg_t.id on Windows.
Windows allows both \ and / as valid path characters.  A computed path
such as C:\development\libfoo\pkgconfig/foo.pc will result in a computed
pkgconf_pkg_t.id of "pkgconfig/foo".

Accordingly, correct the path normalization for checking for / after
the \ path has been dealt with in all cases.
2020-05-26 07:41:16 -06:00
Ben 011db1bb88 Do not complain about malformed whitespace from \n on Version line
Every version line has a newline at the end; the malformed whitespace checker
should just check for trailing spaces and tabs.

Resolves https://todo.sr.ht/~kaniini/pkgconf/15
2020-05-24 14:36:46 -06:00
Ariadne Conill 382a89c173 pkg: pkgconf_compare_version(): do not return levenshtein distance in strcmp() case 2020-05-24 14:18:16 -06:00
Ariadne Conill c10f69994b libpkgconf: pkg: generate diagnostic for and trim malformed versions 2019-07-12 06:35:48 -05:00
Alexander Tsoy db9c1e96a1
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
2019-06-08 04:55:52 +03:00
William Pitcock 6854265f28 libpkgconf: pkg: use pkgconf_fragment_copy_list() to clean up cflags gathering logic (closes #20) 2019-01-14 13:48:23 -06:00
William Pitcock 0ae52182c9 libpkgconf: pkg: clean up pkgconf_parser interactions (closes #13) 2019-01-14 13:11:59 -06:00
Ignacio Casal Quinteiro 2c05971029 Canonicalize paths before using them
This fixes a problem where on Windows the prefix would
not match if the prefix is generated with backslashes
and the rest of the variables use normal slashes
2018-09-17 16:31:25 +02:00
Ignacio Casal Quinteiro 9f17da92d2 On Windows the path prefix should be checked caseless 2018-09-17 15:41:27 +02:00
William Pitcock 6f05fec4b5 pkg: give a correctly sized vtable to the parser 2018-06-16 16:35:44 -05:00