mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-03 23:49:38 +00:00 
			
		
		
		
	Fix version conflict parsing
This commit is contained in:
		@ -38,10 +38,7 @@ internal struct ApkVersionRequirement: Hashable {
 | 
			
		||||
      }
 | 
			
		||||
      (nameEnd, versionStart) = (range.lowerBound, range.upperBound)
 | 
			
		||||
    } else {
 | 
			
		||||
      // Lack of conflict flag indicates any version
 | 
			
		||||
      if !comparer.contains(.conflict) {
 | 
			
		||||
      comparer.formUnion(.any)
 | 
			
		||||
      }
 | 
			
		||||
      (nameEnd, versionStart) = (dependStr.endIndex, dependStr.endIndex)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -54,9 +51,10 @@ internal struct ApkVersionRequirement: Hashable {
 | 
			
		||||
extension ApkVersionRequirement: CustomStringConvertible {
 | 
			
		||||
  var description: String {
 | 
			
		||||
    switch self.versionSpec {
 | 
			
		||||
    case .any: self.name
 | 
			
		||||
    case .conflict: "!\(self.name)"
 | 
			
		||||
    case .constraint(let op, let version): "\(self.name)\(op)\(version)"
 | 
			
		||||
    case .any(let invert):
 | 
			
		||||
      "\(invert ? "!" : "")\(self.name)"
 | 
			
		||||
    case .constraint(let invert, let op, let version):
 | 
			
		||||
      "\(invert ? "!" : "")\(self.name)\(op)\(version)"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -92,16 +90,11 @@ fileprivate extension ApkVersionRequirement {
 | 
			
		||||
 | 
			
		||||
fileprivate extension ApkVersionSpecification {
 | 
			
		||||
  init(_ bits: ApkVersionRequirement.ComparatorBits, version: Substring) throws(ApkVersionRequirement.ParseError) {
 | 
			
		||||
    if bits == [ .conflict ] {
 | 
			
		||||
      self = .conflict
 | 
			
		||||
    let invert = bits.contains(.conflict)
 | 
			
		||||
    self = if bits.subtracting(.conflict) == [ .any ] {
 | 
			
		||||
      .any(invert: invert)
 | 
			
		||||
    } else {
 | 
			
		||||
      if bits.contains(.conflict) {
 | 
			
		||||
        throw .brokenSpec
 | 
			
		||||
      } else if bits == [ .any ] {
 | 
			
		||||
        self = .any
 | 
			
		||||
      } else {
 | 
			
		||||
        self = .constraint(op: try .init(bits), version: String(version))
 | 
			
		||||
      }
 | 
			
		||||
      .constraint(invert: invert, op: try .init(bits), version: String(version))
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,9 +4,8 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
enum ApkVersionSpecification: Equatable, Hashable {
 | 
			
		||||
  case any
 | 
			
		||||
  case constraint(op: Operator, version: String)
 | 
			
		||||
  case conflict
 | 
			
		||||
  case any(invert: Bool)
 | 
			
		||||
  case constraint(invert: Bool, op: Operator, version: String)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extension ApkVersionSpecification {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user