Skip to content

Commit

Permalink
Merge pull request #3 from trill-lang/ninety-one
Browse files Browse the repository at this point in the history
Update to Xcode 9.1
  • Loading branch information
CodaFi authored Nov 2, 2017
2 parents e047d6b + 0972885 commit 0830734
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Sources/FileCheck/CheckString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private func diagnoseFailedCheck(

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

for i in 0..<min(buffer.characters.count, 4096) {
for i in 0..<min(buffer.count, 4096) {
let exampleString : String
if pattern.fixedString.isEmpty {
exampleString = pattern.regExPattern
Expand All @@ -400,7 +400,7 @@ private func diagnoseFailedCheck(
// Compute the "quality" of this match as an arbitrary combination of
// the match distance and the number of lines skipped to get to this
// match.
let distance = editDistance(from: Array(buffer.characters), to: Array(exampleString.characters))
let distance = editDistance(from: buffer.map{$0}, to: exampleString.map{$0})
let quality = Double(distance) + (Double(NumLinesForward) / 100.0)
if quality < BestQuality || BestLine == nil {
BestLine = i
Expand Down
4 changes: 2 additions & 2 deletions Sources/FileCheck/FileCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ private func findFirstMatch(in inbuffer : UnsafeBufferPointer<CChar>, among pref
let bd = Data(buffer: buffer)
let range = bd.range(of: prefixStr.data(using: .utf8)!)!
buffer = buffer.dropFront(range.lowerBound)
lineNumber += (skippedPrefix.characters.filter({ c in c == "\n" }) as [Character]).count
lineNumber += (skippedPrefix.filter({ c in c == "\n" }) as [Character]).count
// Check that the matched prefix isn't a suffix of some other check-like
// word.
// FIXME: This is a very ad-hoc check. it would be better handled in some
// other way. Among other things it seems hard to distinguish between
// intentional and unintentional uses of this feature.
if skippedPrefix.isEmpty || !skippedPrefix.characters.last!.isPartOfWord {
if skippedPrefix.isEmpty || !skippedPrefix.last!.isPartOfWord {
// Now extract the type.
let checkTy = findCheckType(in: buffer, with: prefixStr)

Expand Down
12 changes: 6 additions & 6 deletions Sources/FileCheck/Pattern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ final class Pattern {
// is relaxed, more strict check is performed in \c EvaluateExpression.
var isExpression = false
let diagLoc = CheckLocation.inBuffer(pattern.baseAddress!, buf)
for (i, c) in name.characters.enumerated() {
for (i, c) in name.enumerated() {
if i == 0 && c == "@" {
if nameEnd != nil {
diagnose(.error, at: diagLoc, with: "invalid name in named regex definition", options: options)
Expand Down Expand Up @@ -217,7 +217,7 @@ final class Pattern {
}
self.addBackrefToRegEx(varParenNum)
} else {
variableUses.append((name, self.regExPattern.characters.count))
variableUses.append((name, self.regExPattern.count))
}
continue
}
Expand Down Expand Up @@ -270,7 +270,7 @@ final class Pattern {
return nil
}
expr = String(expr[expr.index(expr.startIndex, offsetBy: "@LINE".utf8.count)...])
guard let firstC = expr.characters.first else {
guard let firstC = expr.first else {
return "\(self.lineNumber)"
}

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

if let c = v.characters.first, c == "@" {
if let c = v.first, c == "@" {
guard let v = self.evaluateExpression(v) else {
return nil
}
Expand All @@ -310,7 +310,7 @@ final class Pattern {
}

// Plop it into the regex at the adjusted offset.
regExToMatch.insert(contentsOf: value.characters, at: regExToMatch.index(regExToMatch.startIndex, offsetBy: offset + insertOffset))
regExToMatch.insert(contentsOf: value, at: regExToMatch.index(regExToMatch.startIndex, offsetBy: offset + insertOffset))
insertOffset += value.utf8.count
}
}
Expand Down Expand Up @@ -385,7 +385,7 @@ final class Pattern {
// [...] Nesting depth
var bracketDepth = 0

while let firstChar = string.characters.first {
while let firstChar = string.first {
if string.hasPrefix(terminator) && bracketDepth == 0 {
return offset
}
Expand Down

0 comments on commit 0830734

Please sign in to comment.