mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 14:07:34 +02:00
Issue #216
This commit is contained in:
parent
b9f461dbc5
commit
572a05307a
2 changed files with 5 additions and 4 deletions
|
@ -9,7 +9,7 @@ Features
|
||||||
|
|
||||||
Bug Fixes
|
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
|
## 0.6.2 - August 25, 2017
|
||||||
|
|
||||||
|
|
|
@ -6185,11 +6185,12 @@ object Cyc_io_read_line(void *data, object cont, object port)
|
||||||
if (fgets(buf, 1023, stream) != NULL) {
|
if (fgets(buf, 1023, stream) != NULL) {
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
{
|
{
|
||||||
// Remove trailing newline
|
// Remove any trailing CR / newline chars
|
||||||
if (len > 0 && buf[len - 1] == '\n') {
|
while (len > 0 && (buf[len - 1] == '\n' ||
|
||||||
|
buf[len - 1] == '\r')) {
|
||||||
len--;
|
len--;
|
||||||
buf[len] = '\0';
|
|
||||||
}
|
}
|
||||||
|
buf[len] = '\0';
|
||||||
make_string_noalloc(s, buf, len);
|
make_string_noalloc(s, buf, len);
|
||||||
return_thread_runnable(data, &s);
|
return_thread_runnable(data, &s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue