eel

formatter for ii(1) logs
Log | Files | Refs | README

commit 4e601916901d5bd3a6e8e66107498dddbd9c5570
parent b45750de7236dd40c0a76fdf4ebab9a7f25faca3
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed,  6 Jun 2018 04:48:40 +0200

do not bufferize input

Diffstat:
Mmplex.c | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/mplex.c b/mplex.c @@ -119,17 +119,17 @@ top: void display_line(void) { - int c; - - fputs("\r\033[K", stderr); - do { - if ((c = fgetc(stdin)) == EOF) - die("fgetc stdin"); - if (fputc(c, stderr) == -1) - perror("fputc tty"), exit(1); - } while (c !='\n'); - if (fflush(stderr) == -1) - perror("fflush tty"); + ssize_t n; + char c; + + write(STDERR_FILENO, "\r\033[K", 4); + while ((n = read(STDIN_FILENO, &c, 1)) == 1) { + write(STDERR_FILENO, &c, 1); + if (c == '\n') + break; + } + if (n == -1) + die("read stdin"); } void