From 2ede1a405f5bf472ba03fe4285fb0b43f5d3c137 Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Sat, 24 Jan 2009 18:03:48 +0000 Subject: Hope this is the last fix for the slightly corrupted output issue whenever a packet ended with "\r ". --- call/call.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'call') diff --git a/call/call.c b/call/call.c index 8016722..a098562 100644 --- a/call/call.c +++ b/call/call.c @@ -1586,10 +1586,10 @@ int cmd_call(char *call[], int mode) static int last_line_was_cr = 1; int this_line_has_cr = 0; char buf2[MAX_BUFLEN]; - unsigned long buf2_len = 0L; + int buf2_len = 0L; int i; /* bytes = read(fd, buf, 511); */ - bytes = read(fd, buf, paclen); + bytes = read(fd, buf, sizeof(buf)); if (bytes == 0) { /* read EOF on stdin */ /* cause program to terminate */ @@ -1633,7 +1633,7 @@ next_read_line_from_fd: * then searche_key_words misinterprets " go_7+. " * as start of a line. */ - if (last_line_was_cr) { + if (last_line_was_cr && this_line_has_cr) { com_num = searche_key_words(buf, &bytes, parms, &parmsbytes, restbuf, &restbytes); } else { com_num = -1; @@ -2079,6 +2079,7 @@ next_read_line_from_fd: if (bytes > 0) { unsigned long offset = 0L; sevenplus = FALSE; + int err = 0; if (uploadfile != -1) { statline(mode, "Ignored. Type ~s to stop upload"); @@ -2087,15 +2088,20 @@ next_read_line_from_fd: convert_lf_cr(buf, bytes); while (offset != bytes) { - int ret = write(fd, buf+offset, bytes-offset); + int len = (bytes-offset > paclen) ? paclen : bytes-offset; + int ret = write(fd, buf+offset, len); if (ret == -1) { + if (errno == EWOULDBLOCK || errno == EAGAIN) { + usleep(100000); + continue; + } perror("write"); - offset=-1; + err = 1; break; } offset += ret; } - if (offset == -1) + if (err) break; } } -- cgit v1.2.3