Skip to content

Commit 0972885

Browse files
committed
Update to Xcode 9.1
Squash new warnings for use of String.characters
1 parent e047d6b commit 0972885

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Sources/FileCheck/CheckString.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private func diagnoseFailedCheck(
336336

337337
// Note any variables used by the pattern
338338
for (varName, _) in pattern.variableUses {
339-
if varName.characters.first == "@" {
339+
if varName.first == "@" {
340340
// If we failed with a builtin variable like @LINE, try to report
341341
// what it is bound to.
342342
if let value = pattern.evaluateExpression(varName) {
@@ -374,7 +374,7 @@ private func diagnoseFailedCheck(
374374
var BestLine : Int? = nil
375375
var BestQuality = 0.0
376376

377-
for i in 0..<min(buffer.characters.count, 4096) {
377+
for i in 0..<min(buffer.count, 4096) {
378378
let exampleString : String
379379
if pattern.fixedString.isEmpty {
380380
exampleString = pattern.regExPattern
@@ -400,7 +400,7 @@ private func diagnoseFailedCheck(
400400
// Compute the "quality" of this match as an arbitrary combination of
401401
// the match distance and the number of lines skipped to get to this
402402
// match.
403-
let distance = editDistance(from: Array(buffer.characters), to: Array(exampleString.characters))
403+
let distance = editDistance(from: buffer.map{$0}, to: exampleString.map{$0})
404404
let quality = Double(distance) + (Double(NumLinesForward) / 100.0)
405405
if quality < BestQuality || BestLine == nil {
406406
BestLine = i

Sources/FileCheck/FileCheck.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ private func findFirstMatch(in inbuffer : UnsafeBufferPointer<CChar>, among pref
356356
let bd = Data(buffer: buffer)
357357
let range = bd.range(of: prefixStr.data(using: .utf8)!)!
358358
buffer = buffer.dropFront(range.lowerBound)
359-
lineNumber += (skippedPrefix.characters.filter({ c in c == "\n" }) as [Character]).count
359+
lineNumber += (skippedPrefix.filter({ c in c == "\n" }) as [Character]).count
360360
// Check that the matched prefix isn't a suffix of some other check-like
361361
// word.
362362
// FIXME: This is a very ad-hoc check. it would be better handled in some
363363
// other way. Among other things it seems hard to distinguish between
364364
// intentional and unintentional uses of this feature.
365-
if skippedPrefix.isEmpty || !skippedPrefix.characters.last!.isPartOfWord {
365+
if skippedPrefix.isEmpty || !skippedPrefix.last!.isPartOfWord {
366366
// Now extract the type.
367367
let checkTy = findCheckType(in: buffer, with: prefixStr)
368368

Sources/FileCheck/Pattern.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ final class Pattern {
185185
// is relaxed, more strict check is performed in \c EvaluateExpression.
186186
var isExpression = false
187187
let diagLoc = CheckLocation.inBuffer(pattern.baseAddress!, buf)
188-
for (i, c) in name.characters.enumerated() {
188+
for (i, c) in name.enumerated() {
189189
if i == 0 && c == "@" {
190190
if nameEnd != nil {
191191
diagnose(.error, at: diagLoc, with: "invalid name in named regex definition", options: options)
@@ -217,7 +217,7 @@ final class Pattern {
217217
}
218218
self.addBackrefToRegEx(varParenNum)
219219
} else {
220-
variableUses.append((name, self.regExPattern.characters.count))
220+
variableUses.append((name, self.regExPattern.count))
221221
}
222222
continue
223223
}
@@ -270,7 +270,7 @@ final class Pattern {
270270
return nil
271271
}
272272
expr = String(expr[expr.index(expr.startIndex, offsetBy: "@LINE".utf8.count)...])
273-
guard let firstC = expr.characters.first else {
273+
guard let firstC = expr.first else {
274274
return "\(self.lineNumber)"
275275
}
276276

@@ -295,7 +295,7 @@ final class Pattern {
295295
for (v, offset) in self.variableUses {
296296
var value : String = ""
297297

298-
if let c = v.characters.first, c == "@" {
298+
if let c = v.first, c == "@" {
299299
guard let v = self.evaluateExpression(v) else {
300300
return nil
301301
}
@@ -310,7 +310,7 @@ final class Pattern {
310310
}
311311

312312
// Plop it into the regex at the adjusted offset.
313-
regExToMatch.insert(contentsOf: value.characters, at: regExToMatch.index(regExToMatch.startIndex, offsetBy: offset + insertOffset))
313+
regExToMatch.insert(contentsOf: value, at: regExToMatch.index(regExToMatch.startIndex, offsetBy: offset + insertOffset))
314314
insertOffset += value.utf8.count
315315
}
316316
}
@@ -385,7 +385,7 @@ final class Pattern {
385385
// [...] Nesting depth
386386
var bracketDepth = 0
387387

388-
while let firstChar = string.characters.first {
388+
while let firstChar = string.first {
389389
if string.hasPrefix(terminator) && bracketDepth == 0 {
390390
return offset
391391
}

0 commit comments

Comments
 (0)