From 68df2df66857b597a2adbb29d27d709a5d59a5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 17 May 2022 13:26:47 +0200 Subject: [PATCH] Clean up the text in description of strverscmp_improved() --- docs/DISCOVERABLE_PARTITIONS.md | 10 +++++----- src/fundamental/string-util-fundamental.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/DISCOVERABLE_PARTITIONS.md b/docs/DISCOVERABLE_PARTITIONS.md index 85e858921fb..b7c9c1e2ebf 100644 --- a/docs/DISCOVERABLE_PARTITIONS.md +++ b/docs/DISCOVERABLE_PARTITIONS.md @@ -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 diff --git a/src/fundamental/string-util-fundamental.c b/src/fundamental/string-util-fundamental.c index 101d3f71962..c9b1b89b3e9 100644 --- a/src/fundamental/string-util-fundamental.c +++ b/src/fundamental/string-util-fundamental.c @@ -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