HaxeFoundation / HaxeFoundation/haxe
FileInput.readLine() fails if last line is empty
Open
feature-filesystem
Hacktoberfest
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
The following code fails on all sys targets with an EOF exception, but shouldn't because before invoking readLine the EOF status is tested.
``` haxe
class Test {
static function main() {
sys.io.File.saveContent("test.txt", "line1\nline2\n");
var is = sys.io.File.read("test.txt", false);
while (!is.eof()) {
trace(is.readLine());
}
is.close();
}
}
```
The example works if
``` haxe
sys.io.File.saveContent("test.txt", "line1\nline2\n");
```
is replaced by
``` haxe
sys.io.File.saveContent("test.txt", "line1\nline2");
```
Contributor guide
Assessment
This issue has not been assessed yet.