1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 16:33:03 +03:00

Read data with getline.

This commit is contained in:
Rob Rix 2015-10-27 11:27:17 -04:00
parent ef121e4bb1
commit f2b52a0620

View File

@ -9,9 +9,9 @@ extension TSInput {
self.init(
payload: file,
read_fn: { (payload: UnsafeMutablePointer<Void>, bytesRead: UnsafeMutablePointer<Int>) -> UnsafePointer<Int8> in
let result = UnsafePointer<Int8>(fgets(nil, 100, UnsafeMutablePointer<FILE>(payload)))
bytesRead.memory = Int(strlen(result))
return result
var string: UnsafeMutablePointer<Int8> = nil
bytesRead.memory = getline(&string, nil, UnsafeMutablePointer<FILE>(payload))
return UnsafePointer<Int8>(string)
},
seek_fn: { (payload: UnsafeMutablePointer<Void>, position: TSLength) -> Int32 in
fseek(UnsafeMutablePointer<FILE>(payload), position.bytes, SEEK_CUR)