This commit is contained in:
Justin Ethier 2017-09-01 14:03:20 +00:00
parent b9f461dbc5
commit 572a05307a
2 changed files with 5 additions and 4 deletions

View file

@ -9,7 +9,7 @@ Features
Bug Fixes
- Fix `read-line` to remove trailing newlines. Thanks to wasamasa for the bug report!
- Fix `read-line` to remove trailing carriage return and/or newline characters. Thanks to wasamasa for the bug report!
## 0.6.2 - August 25, 2017

View file

@ -6185,11 +6185,12 @@ object Cyc_io_read_line(void *data, object cont, object port)
if (fgets(buf, 1023, stream) != NULL) {
len = strlen(buf);
{
// Remove trailing newline
if (len > 0 && buf[len - 1] == '\n') {
// Remove any trailing CR / newline chars
while (len > 0 && (buf[len - 1] == '\n' ||
buf[len - 1] == '\r')) {
len--;
buf[len] = '\0';
}
buf[len] = '\0';
make_string_noalloc(s, buf, len);
return_thread_runnable(data, &s);
}