mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-26 01:22:53 +01:00
34 lines
677 B
Swift
34 lines
677 B
Swift
//
|
||
// SAXUtilities.swift
|
||
//
|
||
//
|
||
// Created by Brent Simmons on 8/26/24.
|
||
//
|
||
|
||
import Foundation
|
||
import libxml2
|
||
|
||
public func SAXEqualTags(_ localName: XMLPointer, _ tag: ContiguousArray<Int8>) -> Bool {
|
||
|
||
return tag.withUnsafeBufferPointer { bufferPointer in
|
||
|
||
let tagCount = tag.count // includes 0 terminator
|
||
|
||
for i in 0..<tagCount - 1 {
|
||
|
||
let localNameCharacter = localName[i]
|
||
if localNameCharacter == 0 {
|
||
return false
|
||
}
|
||
|
||
let tagCharacter = UInt8(tag[i])
|
||
if localNameCharacter != tagCharacter {
|
||
return false
|
||
}
|
||
}
|
||
|
||
// localName might actually be longer — make sure it’s the same length as tag.
|
||
return localName[tagCount - 1] == 0
|
||
}
|
||
}
|