Change IO.read to return null on EOF

This commit is contained in:
Michel Martens
2015-03-07 09:10:18 +00:00
parent 7aacf02a00
commit 542a783cb4
2 changed files with 3 additions and 4 deletions

View File

@ -120,11 +120,9 @@ static void ioRead(WrenVM* vm)
char buffer[MAX_READ_LEN];
char* result = fgets(buffer, MAX_READ_LEN, stdin);
if (result == NULL) {
// TODO: handle error.
if (result != NULL) {
wrenReturnString(vm, buffer, (int)strlen(buffer));
}
wrenReturnString(vm, buffer, (int)strlen(buffer));
}
static void ioClock(WrenVM* vm)

1
test/io/read_eof.wren Normal file
View File

@ -0,0 +1 @@
IO.write(IO.read) // expect: null