Skip to content

Commit c9dac68

Browse files
committed
Allow '--stdin' to work properly with pipes, see #77
1 parent c14c2a8 commit c9dac68

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

render.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <math.h>
88
#include <time.h>
99

10+
#include <sys/ioctl.h>
1011
#include <sys/mman.h>
1112
#include <sys/types.h>
1213
#include <sys/stat.h>
@@ -1542,7 +1543,7 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
15421543
break;
15431544
if (c != EOF && c != '\n')
15441545
stdin_buf[stdin_idx++] = c;
1545-
else if (c != EOF) {
1546+
else {
15461547
stdin_buf[stdin_idx] = '\0';
15471548
switch (gl->stdin_type) {
15481549
case STDIN_TYPE_BOOL:
@@ -1602,10 +1603,11 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
16021603
stdin_buf[0] = '\0';
16031604
stdin_idx = 0;
16041605
break;
1605-
} else {
1606-
fprintf(stderr, "scanf() returned EOF, ignoring input\n");
1607-
gl->stdin_type = STDIN_TYPE_NONE;
1608-
break;
1606+
1607+
if (c == EOF) {
1608+
gl->stdin_type = STDIN_TYPE_NONE;
1609+
break;
1610+
}
16091611
};
16101612
}
16111613
}

0 commit comments

Comments
 (0)