1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05: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; unsigned char *buf = buffer + ret;
int bufl = buflen - ret; int bufl = buflen - ret;
int bufp; int bufp;
int newline = 0; unsigned char *newline;
/* Newline quest. */ /* Newline quest. */
for (bufp = 0; bufp < bufl; bufp++) { newline = memchr(buf, ASCII_LF, bufl);
if (buf[bufp] == ASCII_LF) {
newline = 1;
break;
}
}
if (newline) { if (newline) {
bufp = newline - buf;
ret += bufp + 1; ret += bufp + 1;
if (bufp && buf[bufp - 1] == ASCII_CR) bufp--; if (bufp && buf[bufp - 1] == ASCII_CR) bufp--;
} else { } else {
bufp = bufl;
if (!bufp || (!last && bufl < FTP_BUF_SIZE)) { if (!bufp || (!last && bufl < FTP_BUF_SIZE)) {
return ret; return ret;
} }