diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-05-14 13:51:52 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-05-14 13:51:52 +0000 |
commit | 44ffea62b3a6e0ed3d60cf817fb24df67e11ff81 (patch) | |
tree | 1ae792f61e0cf6438136939d217a324077d2b54f /socket.c | |
parent | f62f19c0dea13f846fd633393f8dd13c33f10061 (diff) | |
download | fetchmail-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.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -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'; |