Remove trailing newline from stdin
This commit is contained in:
parent
bef80146e6
commit
6034eee647
|
@ -52,6 +52,8 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
|
||||||
n = read(fd, buffer + rec, buffer_len - rec);
|
n = read(fd, buffer + rec, buffer_len - rec);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
if (errno == EAGAIN) {
|
if (errno == EAGAIN) {
|
||||||
|
/* remove trailing newline and finish up */
|
||||||
|
buffer[rec-1] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("ERROR: read() failed!");
|
printf("ERROR: read() failed!");
|
||||||
|
@ -66,6 +68,8 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
|
||||||
buffer_len += STDIN_CHUNK_SIZE;
|
buffer_len += STDIN_CHUNK_SIZE;
|
||||||
FREE(tmp);
|
FREE(tmp);
|
||||||
} else {
|
} else {
|
||||||
|
/* remove trailing newline and finish up */
|
||||||
|
buffer[rec-1] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue