Skip to content

Commit

Permalink
Update Tools to support Swift 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkolb committed Jul 26, 2017
1 parent 41e0a32 commit f0874d1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Tools/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ extension OutputStream
func write(_ string:String) {
if string.isEmpty {return}
let encodedDataArray = [UInt8](string.utf8)
write(encodedDataArray, maxLength: encodedDataArray.count)
let result = write(encodedDataArray, maxLength: encodedDataArray.count)
if result == -1 {
fatalError("Error: \(streamError!)")
}
else if result < encodedDataArray.count {
fatalError("Unable to fully write string")
}
}
}

Expand Down Expand Up @@ -276,7 +282,12 @@ func chomper(delegate:XMLParserDelegate, _ filename:String)
assert(infile?.streamStatus == .open, "Unable to read \(filename)")
let xmlParser = XMLParser(stream: infile!)
xmlParser.delegate = delegate
xmlParser.parse()
let success = xmlParser.parse()

if (!success) {
fatalError("Error: \(xmlParser.parserError!)")
}

infile!.close()
}

Expand Down

0 comments on commit f0874d1

Please sign in to comment.