Clean up the text in description of strverscmp_improved()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-05-17 13:26:47 +02:00
parent 9b7c8253f9
commit 68df2df668
2 changed files with 15 additions and 13 deletions

View file

@ -333,11 +333,11 @@ directory is found to be populated already in the root partition, the automatic
discovery _must not_ mount any discovered file system over it. Optionally, in
case of the root, `/usr/` and their Verity partitions instead of strictly
mounting the first suitable partition an OS might choose to mount the partition
whose label compares the highest according to `strverscmp()` or a similar
logic, in order to implement a simple partition-based A/B versioning
scheme. The precise rules are left for the implementation to decide, but when
in doubt earlier partitions (by their index) should always win over later
partitions if the label comparison is inconclusive.
whose label compares the highest according to `strverscmp()` or similar logic,
in order to implement a simple partition-based A/B versioning scheme. The
precise rules are left for the implementation to decide, but when in doubt
earlier partitions (by their index) should always win over later partitions if
the label comparison is inconclusive.
A *container* *manager* should automatically discover and mount the root,
`/usr/`, `/home/`, `/srv/`, `/var/`, `/var/tmp/` partitions inside a container

View file

@ -93,20 +93,22 @@ static sd_bool is_valid_version_char(sd_char a) {
}
sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
/* This is based on RPM's rpmvercmp(). But this explicitly handles '-' and '.', as we usually
* want to directly compare strings which contain both version and release; e.g.
* '247.2-3.1.fc33.x86_64' or '5.11.0-0.rc5.20210128git76c057c84d28.137.fc34'.
* Unlike rpmvercmp(), this distiguishes e.g. 123a and 123.a, and 123a is newer.
/* This function is similar to strverscmp(3), but it treats '-' and '.' as separators.
*
* This splits the input strings into segments. Each segment is numeric or alpha, and may be
* The logic is based on rpm's rpmvercmp(), but unlike rpmvercmp(), it distiguishes e.g.
* '123a' and '123.a', with '123a' being newer.
*
* It allows direct comparison of strings which contain both a version and a release; e.g.
* '247.2-3.1.fc33.x86_64' or '5.11.0-0.rc5.20210128git76c057c84d28.137.fc34'.
*
* The input string is split into segments. Each segment is numeric or alphabetic, and may be
* prefixed with the following:
* '~' : used for pre-releases, a segment prefixed with this is the oldest,
* '-' : used for the separator between version and release,
* '^' : used for patched releases, a segment with this is newer than one with '-'.
* '.' : used for point releases.
* Note, no prefix segment is the newest. All non-supported characters are dropped, and
* handled as a separator of segments, e.g., 123_a is equivalent to 123a.
* Note that no prefix segment is the newest. All non-supported characters are dropped, and
* handled as a separator of segments, e.g., '123_a' is equivalent to '123a'.
*
* By using this, version strings can be sorted like following:
* (older) 122.1