aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-05-14 13:51:52 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-05-14 13:51:52 +0000
commit44ffea62b3a6e0ed3d60cf817fb24df67e11ff81 (patch)
tree1ae792f61e0cf6438136939d217a324077d2b54f /socket.c
parentf62f19c0dea13f846fd633393f8dd13c33f10061 (diff)
downloadfetchmail-44ffea62b3a6e0ed3d60cf817fb24df67e11ff81.tar.gz
fetchmail-44ffea62b3a6e0ed3d60cf817fb24df67e11ff81.tar.bz2
fetchmail-44ffea62b3a6e0ed3d60cf817fb24df67e11ff81.zip
Cleaner version of SockRead.
svn path=/trunk/; revision=995
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/socket.c b/socket.c
index 1df8061f..71b7d543 100644
--- a/socket.c
+++ b/socket.c
@@ -129,22 +129,20 @@ int SockRead(int sock, char *buf, int len)
*/
readlen = 0;
- /* return value of 0 is EOF, < 0 is error */
if ((n = recv(sock, bp, len, MSG_PEEK)) <= 0)
return(-1);
if ((p = memchr(bp, '\n', n)) != NULL)
- {
- if ((n = read(sock, bp, ++p - bp)) == -1)
- return(-1);
- readlen += n;
- *p = '\0';
- return readlen;
- }
+ n = ++p - bp;
if ((n = read(sock, bp, n)) == -1)
return(-1);
readlen += n;
bp += n;
len -= n;
+ if (p)
+ {
+ *p = '\0';
+ break;
+ }
} while
(len);
*bp = '\0';