summaryrefslogtreecommitdiff
path: root/src/shared/compare-operator.c
Commit message (Collapse)AuthorAgeFilesLines
* condition: change operator logic to use $= instead of =$ for glob comparisonsLennart Poettering2022-09-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | So this is a bit of a bikeshedding thing. But I think we should do this nonetheless, before this is released. Playing around with the glob matches I realized that "=$" is really hard to grep for, since in shell code it's an often seen construct. Also, when reading code I often found myself thinking first that the "$" belongs to the rvalue instead of the operator, in a variable expansion scheme. If we move the $ character to the left hand, I think we are on the safer side, since usually lvalues are much more restricted in character sets than rvalues (at least most programming languages do enforce limits on the character set for identifiers). It makes it much easier to grep for the new operator, and easier to read too. Example: before: ConditionOSRelease=ID=$fedora-* after: ConditionOSRelease=ID$=fedora-*
* compare: propagate errors of fnmatch() as errorsLennart Poettering2022-09-011-2/+7
|
* compare: support textual operators, and port analyze over to itLennart Poettering2022-09-011-0/+7
|
* compare: add two new operators "==" and "<>"Lennart Poettering2022-09-011-0/+2
| | | | | | | | These two operators always indicate ordering comparisons, as opposed to "=" and "!=" which depending on context mean literal string compares. This is useful for ConditionOSRelease= for example, as this means there's now always a way to do version compares.
* compare: rework table in parse_compare_operator() to be array of structsLennart Poettering2022-09-011-23/+22
| | | | | | | | Let's change the lookup table to contain pairs of operator/strings, instead of being indexed by operator. The table isn't dense anymore, and this allows us to add alias strings sooner or later.
* compare: add flag for parse_compare_operator() to do equality/inequality ↵Lennart Poettering2022-09-011-0/+17
| | | | | | | comparison via simple string compares This allows us to switch condition_test_osrelease() to use generic version_or_fnmatch_compare() for executing the comparison.
* compare: add a proper flags field for parse_compare_operator()Lennart Poettering2022-09-011-3/+4
|
* compare: drop use of FNM_EXTMATCH for nowLennart Poettering2022-09-011-2/+2
| | | | | | | | | None of our other fnmatch() calls make use of this, and the concept was new to me at least. Given that this is only used for the recently added SMBIOS field matches (and is not included in any release) let's disable "extended" matches for now. We can certainly revisit this, and enable it later if there is real demand, but if we do, we should probably add that all over the place, not just for smbios matches.
* comapre: add generic implementation for comapring with verscmp+fnmatchLennart Poettering2022-09-011-0/+23
|
* compare: move test_order() → compare-operator.[ch]Lennart Poettering2022-09-011-0/+27
|
* condition: split out order operator enumLennart Poettering2022-09-011-0/+38
Let's move the operator enum into its own .c/.h file, so that we can reuse it elsewhere, in particular systemd-analyze's compare-versions logic. Let's rename the concept CompareOperator, since it is nowadays genericlaly about both order *and* fnmatch comparisons, hence just naming it "order" is misleading.