1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Simplify ftp_process_dirlist via memchr.

This commit is contained in:
Miciah Dashiel Butler Masters 2006-06-09 20:16:35 +00:00 committed by Miciah Dashiel Butler Masters
parent 8c3d7a8e72
commit dafc209c61

View File

@ -1167,21 +1167,18 @@ ftp_process_dirlist(struct cache_entry *cached, off_t *pos,
unsigned char *buf = buffer + ret;
int bufl = buflen - ret;
int bufp;
int newline = 0;
unsigned char *newline;
/* Newline quest. */
for (bufp = 0; bufp < bufl; bufp++) {
if (buf[bufp] == ASCII_LF) {
newline = 1;
break;
}
}
newline = memchr(buf, ASCII_LF, bufl);
if (newline) {
bufp = newline - buf;
ret += bufp + 1;
if (bufp && buf[bufp - 1] == ASCII_CR) bufp--;
} else {
bufp = bufl;
if (!bufp || (!last && bufl < FTP_BUF_SIZE)) {
return ret;
}