Skip to content

Commit

Permalink
Fix for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
drmohundro committed Mar 10, 2018
1 parent b6e9636 commit 0483ffe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/SWXMLHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,16 @@ class FullXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
}

func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) {
#if os(Linux)
if let err = parseError as? NSError {
parsingError = ParsingError(line: err.userInfo["NSXMLParserErrorLineNumber"] as? Int ?? 0,
column: err.userInfo["NSXMLParserErrorColumn"] as? Int ?? 0)
}
#else
let err = parseError as NSError
parsingError = ParsingError(line: err.userInfo["NSXMLParserErrorLineNumber"] as? Int ?? 0,
column: err.userInfo["NSXMLParserErrorColumn"] as? Int ?? 0)
#endif
}
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/SWXMLHashTests/XMLParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ class XMLParsingTests: XCTestCase {

XCTAssertNotNil(err)

#if !os(Linux)
if err != nil {
XCTAssert(err!.line == 1)
}
#endif
}
}

Expand Down

0 comments on commit 0483ffe

Please sign in to comment.