mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Issue #216 - read-line remove trailing newlines
This commit is contained in:
parent
59d98aeb8c
commit
eac30107d3
2 changed files with 14 additions and 3 deletions
|
@ -7,6 +7,10 @@ Features
|
|||
- Allow the compiler to optimize calls to `+`, `-`, `*`, and `/` that accept more than 2 arguments.
|
||||
- Added support for bignums to `bitwise-if` from SRFI 60.
|
||||
|
||||
Bug Fixes
|
||||
|
||||
- Fix `read-line` to remove trailing newlines. Thanks to wasamasa for the bug report!
|
||||
|
||||
## 0.6.2 - August 25, 2017
|
||||
|
||||
Features
|
||||
|
|
13
runtime.c
13
runtime.c
|
@ -6174,7 +6174,7 @@ object Cyc_io_read_line(void *data, object cont, object port)
|
|||
{
|
||||
FILE *stream = ((port_type *) port)->fp;
|
||||
char buf[1024];
|
||||
//int i = 0, c;
|
||||
int len;
|
||||
|
||||
Cyc_check_port(data, port);
|
||||
if (stream == NULL) {
|
||||
|
@ -6183,8 +6183,15 @@ object Cyc_io_read_line(void *data, object cont, object port)
|
|||
set_thread_blocked(data, cont);
|
||||
errno = 0;
|
||||
if (fgets(buf, 1023, stream) != NULL) {
|
||||
make_string(s, buf);
|
||||
return_thread_runnable(data, &s);
|
||||
len = strlen(buf);
|
||||
{
|
||||
// Remove trailing newline
|
||||
if (len > 0 && buf[len - 1] == '\n') {
|
||||
buf[len - 1] = '\0';
|
||||
}
|
||||
make_string_noalloc(s, buf, len);
|
||||
return_thread_runnable(data, &s);
|
||||
}
|
||||
} else {
|
||||
if (feof(stream)) {
|
||||
return_thread_runnable(data, Cyc_EOF);
|
||||
|
|
Loading…
Add table
Reference in a new issue