NetNewsWire/Modules/Parser/Sources/SAX/SAXUtilities.swift

34 lines
636 B
Swift
Raw Normal View History

2024-08-27 05:03:35 +02:00
//
// File.swift
//
//
// Created by Brent Simmons on 8/26/24.
//
import Foundation
import libxml2
2024-08-27 07:39:46 +02:00
public func SAXEqualTags(_ localName: XMLPointer, _ tag: ContiguousArray<Int8>) -> Bool {
2024-08-27 05:03:35 +02:00
2024-08-27 07:39:46 +02:00
return tag.withUnsafeBufferPointer { bufferPointer in
let tagCount = tag.count
for i in 0..<tagCount {
let localNameCharacter = localName[i]
if localNameCharacter == 0 {
return false
}
2024-08-27 05:03:35 +02:00
2024-08-27 07:39:46 +02:00
let tagCharacter = UInt8(tag[i])
if localNameCharacter != tagCharacter {
return false
}
}
// localName might actually be longer  make sure its the same length as tag.
return localName[tagCount] == 0
}
2024-08-27 05:03:35 +02:00
}