summaryrefslogtreecommitdiffstats
path: root/src/pkgver
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkgver')
-rw-r--r--src/pkgver/mod.rs27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/pkgver/mod.rs b/src/pkgver/mod.rs
index e968256..bd77a01 100644
--- a/src/pkgver/mod.rs
+++ b/src/pkgver/mod.rs
@@ -1,12 +1,3 @@
-//! Version comparison and dependency-string parsing.
-//!
-//! Hand-written rather than bound to libalpm (DESIGN.md ยง4). The algorithm is
-//! the ALPM one and is fully specified: compare epoch numerically, then compare
-//! `pkgver` chunk-wise, then `pkgrel` chunk-wise. A chunk is a maximal run of
-//! digits or a maximal run of non-digits; non-alphanumeric characters are
-//! ignored. A numeric chunk always sorts before an alphabetic chunk, so `1.5`
-//! < `1.5a` and `1.1` < `1.a`.
-
use std::cmp::Ordering;
use std::fmt;
@@ -127,25 +118,19 @@ fn preceded_by_separator(s: &[u8], k: usize) -> bool {
k > 0 && !is_alnum(s[k - 1])
}
-/// ALPM's `vercmp`, character-wise.
-///
-/// Three rules do all the work, and each one is surprising the first time:
+/// ALPM's `vercmp`, character-wise. Three rules do all the work:
///
/// 1. A numeric chunk is newer than an alphabetic chunk at the same position, so
/// `1.0.1` > `1.0.a`.
/// 2. When one string runs out, the other side decides by its *next raw
/// character*: a letter there makes the exhausted string newer (`1.0` >
-/// `1.0a`, the `1.0rc1 < 1.0` rule), anything else makes it older
-/// (`1.0` < `1.0.1`).
-/// 3. Separators are not merely skipped. An alphabetic chunk that follows a
-/// separator is newer than one glued to the previous chunk, whatever the
-/// letters are: `1.0.a` > `1.0z`. Two versions that differ only in where the
-/// dot sits are *not* equal, which is the part a chunk-splitting
-/// implementation gets wrong.
+/// `1.0a`), anything else makes it older (`1.0` < `1.0.1`).
+/// 3. An alphabetic chunk following a separator is newer than one glued to the
+/// previous chunk, whatever the letters are: `1.0.a` > `1.0z`. Versions
+/// differing only in where the dot sits are *not* equal.
///
/// The cross-product test in `tests/versions.rs` checks this against pacman's own
-/// `vercmp` over ~1100 pairs, which is the only reason anyone can be confident
-/// about rule 3.
+/// `vercmp` over ~1100 pairs.
pub fn vercmp_string(a: &str, b: &str) -> Ordering {
let (a, b) = (a.as_bytes(), b.as_bytes());
let (mut i, mut j) = (0usize, 0usize);