diff options
-rw-r--r-- | rtty.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -10,7 +10,7 @@ int main() { - char bufin[MAXBUF], bufout[MAXBUF]; + char bufin[MAXBUF], bufout[MAXBUF], *bi, *bo; fd_set rfds0, rfds1; int c, fdin, fdout, flags, i, nin, nout, state; struct timeval tv; @@ -31,15 +31,25 @@ main() FD_SET(fdout, &rfds1); if(select(fdout+1, &rfds1, NULL, NULL, &tv) > 0){ nout = read(fdout, bufout, MAXBUF); + if(!nout) continue; bufout[nout] = 0; /* Ignore repetition of typed command. */ - if(strcmp(bufout, bufin) == 0) - bufin[0] = 0; - else{ - printf("%s", bufout); - fflush(stdout); + for(bi = bufin, bo = bufout;;){ + if(*bo == '\n') + break; + if(*bo == 13){ + bo++; + continue; + } + if(*bi != *bo){ + printf("%s", bufout); + fflush(stdout); + break; + } + bi++; bo++; } + bufin[0] = 0; } /* Read from standard in and print on named pipe (in). */ |