forked from gentoo-utils/gentoo-utils
allow slot to be only :* := :slot/sub= or :slot
This commit is contained in:
@@ -79,11 +79,17 @@ pub enum SlotOperator {
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
||||||
pub struct SlotName(#[get(method = "name", kind = "deref")] String);
|
pub struct SlotName(#[get(method = "name", kind = "deref")] String);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct Slot {
|
pub enum Slot {
|
||||||
|
Wildcard,
|
||||||
|
Equal {
|
||||||
primary: Option<SlotName>,
|
primary: Option<SlotName>,
|
||||||
sub: Option<SlotName>,
|
sub: Option<SlotName>,
|
||||||
operator: Option<SlotOperator>,
|
},
|
||||||
|
Name {
|
||||||
|
primary: SlotName,
|
||||||
|
sub: Option<SlotName>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
@@ -575,21 +581,31 @@ impl fmt::Display for SlotName {
|
|||||||
|
|
||||||
impl fmt::Display for Slot {
|
impl fmt::Display for Slot {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if let Some(slot) = self.primary.as_ref() {
|
match self {
|
||||||
write!(f, "{slot}")?;
|
Self::Wildcard => write!(f, "*"),
|
||||||
|
Self::Equal { primary, sub } => {
|
||||||
|
if let Some(primary) = primary {
|
||||||
|
write!(f, "{primary}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(sub) = self.sub.as_ref() {
|
if let Some(sub) = sub {
|
||||||
write!(f, "/{sub}")?;
|
write!(f, "/{sub}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(operator) = self.operator.as_ref() {
|
write!(f, "=")
|
||||||
write!(f, "{operator}")?;
|
}
|
||||||
|
Self::Name { primary, sub } => {
|
||||||
|
write!(f, "{primary}")?;
|
||||||
|
|
||||||
|
if let Some(sub) = sub {
|
||||||
|
write!(f, "/{sub}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for UseDepNegate {
|
impl fmt::Display for UseDepNegate {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
|||||||
@@ -186,21 +186,17 @@ impl<'a> Parseable<'a, &'a str> for Slot {
|
|||||||
type Parser = impl Parser<&'a str, Output = Self>;
|
type Parser = impl Parser<&'a str, Output = Self>;
|
||||||
|
|
||||||
fn parser() -> Self::Parser {
|
fn parser() -> Self::Parser {
|
||||||
SlotName::parser()
|
let wildcard = tag("*").map(|_| Slot::Wildcard);
|
||||||
|
let equals = SlotName::parser()
|
||||||
.opt()
|
.opt()
|
||||||
.and(SlotName::parser().preceded_by(tag("/")).opt())
|
.and(SlotName::parser().preceded_by(tag("/")).opt())
|
||||||
.and(SlotOperator::parser().opt())
|
.followed_by(tag("="))
|
||||||
.map(|((primary, sub), operator)| Slot {
|
.map(|(primary, sub)| Slot::Equal { primary, sub });
|
||||||
primary,
|
let name = SlotName::parser()
|
||||||
sub,
|
.and(SlotName::parser().preceded_by(tag("/")).opt())
|
||||||
operator,
|
.map(|(primary, sub)| Slot::Name { primary, sub });
|
||||||
})
|
|
||||||
.verify_output(|slot| {
|
wildcard.or(equals).or(name)
|
||||||
matches!(
|
|
||||||
(&slot.primary(), &slot.operator()),
|
|
||||||
(Some(_) | None, Some(_)) | (Some(_), None)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,6 +552,7 @@ mod test {
|
|||||||
"=dev-ml/stdio-0.17*t:=[ocamlopt?]",
|
"=dev-ml/stdio-0.17*t:=[ocamlopt?]",
|
||||||
">=dev-libs/libgee-0-8.5:0..8=",
|
">=dev-libs/libgee-0-8.5:0..8=",
|
||||||
"<dev-haskell/wai-3.3:=[]",
|
"<dev-haskell/wai-3.3:=[]",
|
||||||
|
">=kde-frameworks/kcrash-2.16.0:6*",
|
||||||
];
|
];
|
||||||
|
|
||||||
for atom in atoms {
|
for atom in atoms {
|
||||||
|
|||||||
Reference in New Issue
Block a user