diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/pkgver/mod.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its
arguments or fields, or cited the design docs (§n, I-n, m-n, decision n).
2247 comments down to 83.
What survives: the section dividers that segment the large modules, the
secret-handling warnings, the agent wire-frame directions, and the few notes
without which the code they attach to reads as redundant, reorderable, or
unsound.
Diffstat (limited to 'src/pkgver/mod.rs')
| -rw-r--r-- | src/pkgver/mod.rs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/pkgver/mod.rs b/src/pkgver/mod.rs index bd77a01..450d70f 100644 --- a/src/pkgver/mod.rs +++ b/src/pkgver/mod.rs @@ -1,7 +1,6 @@ use std::cmp::Ordering; use std::fmt; -/// `epoch:pkgver-pkgrel` as pacman displays it, with the epoch omitted when 0. pub fn full_version(epoch: &str, pkgver: &str, pkgrel: &str) -> String { let e = epoch.trim(); if e.is_empty() || e == "0" { @@ -11,7 +10,6 @@ pub fn full_version(epoch: &str, pkgver: &str, pkgrel: &str) -> String { } } -/// Parse a full `epoch:pkgver-pkgrel` string back into its parts. pub fn split_full_version(v: &str) -> (String, String, String) { let (epoch, rest) = match v.split_once(':') { Some((e, r)) => (e.to_string(), r.to_string()), @@ -52,7 +50,6 @@ impl Version { } } -/// Compare `epoch:pkgver-pkgrel` triples the way pacman does. pub fn compare( epoch_a: i64, pkgver_a: &str, @@ -71,7 +68,6 @@ pub fn compare( } } -/// Compare two full version strings (`1.2.3-1`, `1:2-3`). pub fn vercmp(a: &str, b: &str) -> Ordering { let va = Version::parse(a); let vb = Version::parse(b); @@ -82,7 +78,6 @@ fn is_alnum(c: u8) -> bool { c.is_ascii_alphanumeric() } -/// The chunk starting at `k`, and the index just past it. enum Chunk<'a> { Num(u128), Alpha(&'a str), @@ -98,7 +93,6 @@ fn read_chunk(s: &[u8], k: usize) -> (Chunk<'_>, usize) { while i < s.len() && s[i].is_ascii_digit() { i += 1; } - // Leading zeros are not significant. let digits = std::str::from_utf8(&s[k..i]).unwrap_or("0").trim_start_matches('0'); (Chunk::Num(digits.parse::<u128>().unwrap_or(0)), i) } else if s[k].is_ascii_alphabetic() { @@ -112,25 +106,10 @@ fn read_chunk(s: &[u8], k: usize) -> (Chunk<'_>, usize) { } } -/// Was the character before `k` a separator? A chunk at the very start of a -/// version counts as attached. 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: -/// -/// 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`), 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. 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); @@ -195,7 +174,6 @@ pub fn vercmp_string(a: &str, b: &str) -> Ordering { return x.cmp(y); } } - // A numeric chunk is always newer than an alphabetic one. (Chunk::Num(_), Chunk::Alpha(_)) => return Ordering::Greater, (Chunk::Alpha(_), Chunk::Num(_)) => return Ordering::Less, _ => {} @@ -205,12 +183,10 @@ pub fn vercmp_string(a: &str, b: &str) -> Ordering { } } -/// True if `new` is a downgrade relative to `current` (§16: maintainer reverted). pub fn is_downgrade(current: &str, new: &str) -> bool { vercmp(current, new) == Ordering::Greater } -/// True if `new` is exactly equal to `current` in the pacman sense. pub fn same_version(current: &str, new: &str) -> bool { vercmp(current, new) == Ordering::Equal } @@ -219,17 +195,11 @@ pub fn same_version(current: &str, new: &str) -> bool { #[derive(Debug, Clone, PartialEq, Eq)] pub enum DepOp { - /// `foo` Any, - /// `foo=1.2` Eq, - /// `foo>=1.2` Ge, - /// `foo<=1.2` Le, - /// `foo>1.2` Gt, - /// `foo<1.2` Lt, } @@ -254,16 +224,11 @@ pub struct Dep { } impl Dep { - /// Parse one dependency string, e.g. `python>=3.11`, `gcc`, `foo=1.2-3`. - /// - /// Returns `None` for an empty or malformed string rather than failing the - /// whole recipe: a weird `optdepends` line must not break detection. pub fn parse(s: &str) -> Option<Dep> { let s = s.trim(); if s.is_empty() { return None; } - // optdepends carry a `: description` suffix. let s = match s.split_once(':') { Some((head, _desc)) if !head.contains(['>', '<', '=']) => head, _ => s, @@ -290,12 +255,10 @@ impl Dep { Some(Dep { name: s.trim().to_string(), op: DepOp::Any, version: None }) } - /// The bare package name, which is what we resolve against our index. pub fn name(&self) -> &str { &self.name } - /// Does a candidate version satisfy this constraint? pub fn satisfied_by(&self, version: &str) -> bool { match self.op { DepOp::Any => true, @@ -317,12 +280,10 @@ impl fmt::Display for Dep { } } -/// Parse a whole `depends=()` style list, dropping unparseable entries. pub fn parse_deps(list: &[String]) -> Vec<Dep> { list.iter().filter_map(|s| Dep::parse(s)).collect() } -/// Strip a `name=version` constraint down to the name, for index resolution. pub fn dep_names(list: &[String]) -> Vec<String> { parse_deps(list).into_iter().map(|d| d.name).collect() } @@ -337,7 +298,6 @@ mod tests { #[test] fn alpm_version_ordering() { - // The classic ALPM test vectors. assert_eq!(ord("1.0-1", "1.0-1"), Ordering::Equal); assert_eq!(ord("1.0-1", "1.0-2"), Ordering::Less); assert_eq!(ord("1.1-1", "1.0-1"), Ordering::Greater); @@ -361,7 +321,6 @@ mod tests { #[test] fn pkgrel_reset_is_a_new_version() { - // §3: a pkgrel reset is a major signal. assert_eq!(ord("1.0-7", "1.0-1"), Ordering::Greater); assert!(is_downgrade("1.0-7", "1.0-1")); } |
