From a807d13b26724e7219b3e7e82915a43ff9d327cc Mon Sep 17 00:00:00 2001 From: jsancho Date: Fri, 22 Apr 2011 12:03:36 +0000 Subject: [PATCH] --- gacela.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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); } } } -- 2.39.2