diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Sources/Element.swift b/Sources/Element.swift index fe7bde7..a5e10f0 100644 --- a/Sources/Element.swift +++ b/Sources/Element.swift @@ -1107,7 +1107,9 @@ open class Element: Node { if (classAttr.charAt(i).isWhitespace) { if (inClass) { // white space ends a class name, compare it with the requested one, ignore case - if (i - start == wantLen && classAttr.regionMatches(true, start, className, 0, wantLen)) { + if (i - start == wantLen && classAttr.regionMatches(ignoreCase: true, selfOffset: start, + other: className, otherOffset: 0, + targetLength: wantLen)) { return true } inClass = false @@ -1123,7 +1125,8 @@ open class Element: Node { // check the last entry if (inClass && len - start == wantLen) { - return classAttr.regionMatches(true, start, className, 0, wantLen) + return classAttr.regionMatches(ignoreCase: true, selfOffset: start, + other: className, otherOffset: 0, targetLength: wantLen) } return false diff --git a/Sources/String.swift b/Sources/String.swift index 645d330..723638f 100644 --- a/Sources/String.swift +++ b/Sources/String.swift @@ -120,14 +120,15 @@ extension String { return String.split(self, beginIndex, count) } - func regionMatches(_ ignoreCase: Bool, _ selfOffset: Int, _ other: String, _ otherOffset: Int, _ length: Int ) -> Bool { + func regionMatches(ignoreCase: Bool, selfOffset: Int, + other: String, otherOffset: Int, targetLength: Int ) -> Bool { if ((otherOffset < 0) || (selfOffset < 0) - || (selfOffset > self.count - length) - || (otherOffset > other.count - length)) { + || (selfOffset > self.count - targetLength) + || (otherOffset > other.count - targetLength)) { return false } - for i in 0.. Bool { - return queue.regionMatches(true, pos, seq, 0, seq.count) + return queue.regionMatches(ignoreCase: true, selfOffset: pos, + other: seq, otherOffset: 0, targetLength: seq.count) } /**