Merge pull request #1439 from millenomi/cfrunloop-fix-linux
diff --git a/Foundation/NSPathUtilities.swift b/Foundation/NSPathUtilities.swift
index 92808ad..d4d617f 100755
--- a/Foundation/NSPathUtilities.swift
+++ b/Foundation/NSPathUtilities.swift
@@ -103,25 +103,23 @@
internal func _stringByFixingSlashes(compress : Bool = true, stripTrailing: Bool = true) -> String {
var result = self
if compress {
- result.withMutableCharacters { characterView in
- let startPos = characterView.startIndex
- var endPos = characterView.endIndex
- var curPos = startPos
-
- while curPos < endPos {
- if characterView[curPos] == "/" {
- var afterLastSlashPos = curPos
- while afterLastSlashPos < endPos && characterView[afterLastSlashPos] == "/" {
- afterLastSlashPos = characterView.index(after: afterLastSlashPos)
- }
- if afterLastSlashPos != characterView.index(after: curPos) {
- characterView.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
- endPos = characterView.endIndex
- }
- curPos = afterLastSlashPos
- } else {
- curPos = characterView.index(after: curPos)
+ let startPos = result.startIndex
+ var endPos = result.endIndex
+ var curPos = startPos
+
+ while curPos < endPos {
+ if result[curPos] == "/" {
+ var afterLastSlashPos = curPos
+ while afterLastSlashPos < endPos && result[afterLastSlashPos] == "/" {
+ afterLastSlashPos = result.index(after: afterLastSlashPos)
}
+ if afterLastSlashPos != result.index(after: curPos) {
+ result.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
+ endPos = result.endIndex
+ }
+ curPos = afterLastSlashPos
+ } else {
+ curPos = result.index(after: curPos)
}
}
}
@@ -214,25 +212,23 @@
var result = _swiftObject
if compress {
- result.withMutableCharacters { characterView in
- let startPos = characterView.startIndex
- var endPos = characterView.endIndex
- var curPos = startPos
-
- while curPos < endPos {
- if characterView[curPos] == "/" {
- var afterLastSlashPos = curPos
- while afterLastSlashPos < endPos && characterView[afterLastSlashPos] == "/" {
- afterLastSlashPos = characterView.index(after: afterLastSlashPos)
- }
- if afterLastSlashPos != characterView.index(after: curPos) {
- characterView.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
- endPos = characterView.endIndex
- }
- curPos = afterLastSlashPos
- } else {
- curPos = characterView.index(after: curPos)
+ let startPos = result.startIndex
+ var endPos = result.endIndex
+ var curPos = startPos
+
+ while curPos < endPos {
+ if result[curPos] == "/" {
+ var afterLastSlashPos = curPos
+ while afterLastSlashPos < endPos && result[afterLastSlashPos] == "/" {
+ afterLastSlashPos = result.index(after: afterLastSlashPos)
}
+ if afterLastSlashPos != result.index(after: curPos) {
+ result.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
+ endPos = result.endIndex
+ }
+ curPos = afterLastSlashPos
+ } else {
+ curPos = result.index(after: curPos)
}
}
}
diff --git a/Foundation/NSURL.swift b/Foundation/NSURL.swift
index 62f803e..fa094f2 100644
--- a/Foundation/NSURL.swift
+++ b/Foundation/NSURL.swift
@@ -719,25 +719,23 @@
var result = p
if compress {
- result.withMutableCharacters { characterView in
- let startPos = characterView.startIndex
- var endPos = characterView.endIndex
- var curPos = startPos
+ let startPos = result.startIndex
+ var endPos = result.endIndex
+ var curPos = startPos
- while curPos < endPos {
- if characterView[curPos] == "/" {
- var afterLastSlashPos = curPos
- while afterLastSlashPos < endPos && characterView[afterLastSlashPos] == "/" {
- afterLastSlashPos = characterView.index(after: afterLastSlashPos)
- }
- if afterLastSlashPos != characterView.index(after: curPos) {
- characterView.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
- endPos = characterView.endIndex
- }
- curPos = afterLastSlashPos
- } else {
- curPos = characterView.index(after: curPos)
+ while curPos < endPos {
+ if result[curPos] == "/" {
+ var afterLastSlashPos = curPos
+ while afterLastSlashPos < endPos && result[afterLastSlashPos] == "/" {
+ afterLastSlashPos = result.index(after: afterLastSlashPos)
}
+ if afterLastSlashPos != result.index(after: curPos) {
+ result.replaceSubrange(curPos ..< afterLastSlashPos, with: ["/"])
+ endPos = result.endIndex
+ }
+ curPos = afterLastSlashPos
+ } else {
+ curPos = result.index(after: curPos)
}
}
}
diff --git a/TestFoundation/TestNSString.swift b/TestFoundation/TestNSString.swift
index 0266819..71efa58 100755
--- a/TestFoundation/TestNSString.swift
+++ b/TestFoundation/TestNSString.swift
@@ -1238,14 +1238,7 @@
// ASCII cases
ComparisonTest("t", "tt"),
ComparisonTest("t", "Tt"),
- ComparisonTest("\u{0}", "",
- reason: {
-#if _runtime(_ObjC)
- return ""
-#else
- return "https://bugs.swift.org/browse/SR-332"
-#endif
- }()),
+ ComparisonTest("\u{0}", ""),
ComparisonTest("\u{0}", "\u{0}",
reason: "https://bugs.swift.org/browse/SR-332"),
ComparisonTest("\r\n", "t"),