Skip to content

Commit 57169d3

Browse files
samdeanekovpas
authored andcommitted
Fixed warnings caused by Swift 4 string changes. (#13)
1 parent 0425bb9 commit 57169d3

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

DocoptTests/DocoptTestCaseParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct DocoptTestCaseParser {
2626

2727
private func removeComments(string: String) -> String {
2828
let removeCommentsRegEx = try! NSRegularExpression(pattern: "(?m)#.*$", options: [])
29-
let fullRange: NSRange = NSMakeRange(0, string.characters.count)
29+
let fullRange: NSRange = NSMakeRange(0, string.count)
3030
return removeCommentsRegEx.stringByReplacingMatches(in: string, options: [], range: fullRange, withTemplate: "")
3131
}
3232

Sources/Docopt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ open class Docopt : NSObject {
177177
let short = "-" + left[0..<1]
178178
let similar = options.filter {$0.short == short}
179179
var o: Option
180-
left = left[1..<left.characters.count]
180+
left = left[1..<left.count]
181181

182182
if similar.count > 1 {
183183
tokens.error.raise("\(short) is specified ambiguously \(similar.count) times")

Sources/String.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ internal extension String {
2323

2424
func findAll(_ regex: String, flags: NSRegularExpression.Options) -> [String] {
2525
let re = try! NSRegularExpression(pattern: regex, options: flags)
26-
let all = NSMakeRange(0, self.characters.count)
26+
let all = NSMakeRange(0, self.count)
2727
let matches = re.matches(in: self, options: [], range: all)
2828
return matches.map {self[$0.range(at: 1)].strip()}
2929
}
3030

3131
func split() -> [String] {
32-
return self.characters.split(whereSeparator: {$0 == " " || $0 == "\n"}).map(String.init)
32+
return self.split(whereSeparator: {$0 == " " || $0 == "\n"}).map(String.init)
3333
}
3434

3535
func split(_ regex: String) -> [String] {
3636
let re = try! NSRegularExpression(pattern: regex, options: .dotMatchesLineSeparators)
37-
let all = NSMakeRange(0, self.characters.count)
37+
let all = NSMakeRange(0, self.count)
3838
var result = [String]()
3939
let matches = re.matches(in: self, options: [], range: all)
4040
if matches.count > 0 {
@@ -52,7 +52,7 @@ internal extension String {
5252

5353
result.append(self[range])
5454
lastEnd = range.location + range.length
55-
if lastEnd == self.characters.count {
55+
if lastEnd == self.count {
5656
// from python docs: If there are capturing groups in the separator and it matches at the start of the string,
5757
// the result will start with an empty string. The same holds for the end of the string:
5858
result.append("")
@@ -62,8 +62,8 @@ internal extension String {
6262
lastEnd = match.range.location + match.range.length
6363
}
6464
}
65-
if lastEnd != self.characters.count {
66-
result.append(self[lastEnd..<self.characters.count])
65+
if lastEnd != self.count {
66+
result.append(self[lastEnd..<self.count])
6767
}
6868
return result
6969
}
@@ -77,7 +77,7 @@ internal extension String {
7777
}
7878

7979
subscript(range: Range<Int>) -> String {
80-
return String(self[characters.index(startIndex, offsetBy: range.lowerBound)..<characters.index(startIndex, offsetBy: range.upperBound)])
80+
return String(self[self.index(startIndex, offsetBy: range.lowerBound)..<self.index(startIndex, offsetBy: range.upperBound)])
8181
}
8282

8383
subscript(range: NSRange) -> String {

0 commit comments

Comments
 (0)