1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-03 09:03:02 +00:00

Add some library functions and add newline character to reading line

from file.
This commit is contained in:
bakpakin
2018-02-06 10:31:42 -05:00
parent c76b08cecc
commit 7bfb3145cb
2 changed files with 32 additions and 4 deletions

View File

@@ -187,10 +187,8 @@ static int dst_io_fread(DstArgs args) {
} else if (!dst_cstrcmp(sym, ":line")) {
for (;;) {
int x = fgetc(iof->file);
if (x == EOF || x == '\n') {
break;
}
if (dst_buffer_push_u8(b, (uint8_t)x)) return dst_throw(args, "buffer overflow");
if (x != EOF && dst_buffer_push_u8(b, (uint8_t)x)) return dst_throw(args, "buffer overflow");
if (x == EOF || x == '\n') break;
}
return dst_return(args, dst_wrap_buffer(b));
} else {