Skip to content

Commit 5835ceb

Browse files
committed
[android] Do not try to turn EOF into an UInt8
Android is one of those platforms that define the symbol EOF as a negative number. Trying to turn it into an UInt8 will only crash the test. Move the transformation after we have checked for EOF first. In my opinion, in other platforms, having the EOF attached to the getline result was also invalid, and that's probably why the two test that use EOF were sending an extra newline. Even with this, the tests do not pass on Android because it deadlocks waiting for input/output from the child process, which never happens. I haven't find why this happens, but only happens if the last test of the suite closes stdin. I will try to fix that in another PR.
1 parent 3bdb924 commit 5835ceb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

validation-test/StdlibUnittest/Stdin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ func simple_getline() -> [UInt8]? {
1818
var result = [UInt8]()
1919
while true {
2020
let c = getchar()
21-
result.append(UInt8(c))
2221
if c == EOF {
2322
if result.count == 0 {
2423
return nil
2524
}
2625
return result
2726
}
27+
result.append(UInt8(c))
2828
if c == CInt(UnicodeScalar("\n").value) {
2929
return result
3030
}

0 commit comments

Comments
 (0)