From f0874d13ca885d348715b336e0e27ee1f53b8873 Mon Sep 17 00:00:00 2001 From: Justin Kolb Date: Tue, 25 Jul 2017 20:36:24 -0500 Subject: [PATCH] Update Tools to support Swift 3. --- Tools/main.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Tools/main.swift b/Tools/main.swift index a0304a7..d74ae95 100755 --- a/Tools/main.swift +++ b/Tools/main.swift @@ -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") + } } } @@ -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() }