From: jsancho Date: Fri, 22 Apr 2011 12:03:36 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;ds=inline;h=a807d13b26724e7219b3e7e82915a43ff9d327cc;p=gacela.git --- diff --git a/gacela.c b/gacela.c index dee7659..0493d8f 100644 --- a/gacela.c +++ b/gacela.c @@ -2,6 +2,7 @@ #include #include #include +#include /* Read-Send-Print-Loop */ void rspl(int pin, int pout) @@ -42,13 +43,20 @@ int main (int argc, char *argv[]) } else { char buf; + static char *line = (char *)NULL; + + dup2(pfd[0], 0); + close(pfd[0]); while (1) { - while (read(pfd[0], &buf, 1) > 0) { - if (buf == '\n') - write(STDOUT_FILENO, "-\n", 2); - else - write(STDOUT_FILENO, &buf, 1); + if (line) { + free(line); + line = (char *)NULL; + } + + line = readline(""); + if (line && *line) { + printf("%s-\n", line); } } }