mirror of
https://github.com/troglobit/libite.git
synced 2026-10-02 05:42:49 +07:00
lftok(): Refactor, collapse and simplify a bit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+10
-13
@@ -92,23 +92,20 @@ char *lftok(lfile_t *lf)
|
||||
}
|
||||
|
||||
token = strtok_r(NULL, lf->sep, &lf->save);
|
||||
if (!token) {
|
||||
while (fgets(lf->buf, sizeof(lf->buf), lf->fp)) {
|
||||
if (lf->buf[0] == '#')
|
||||
continue;
|
||||
if (token)
|
||||
return token;
|
||||
|
||||
token = strtok_r(lf->buf, lf->sep, &lf->save);
|
||||
if (!token)
|
||||
continue;
|
||||
|
||||
while (fgets(lf->buf, sizeof(lf->buf), lf->fp)) {
|
||||
if (lf->buf[0] == '#')
|
||||
continue;
|
||||
|
||||
token = strtok_r(lf->buf, lf->sep, &lf->save);
|
||||
if (token)
|
||||
return token;
|
||||
}
|
||||
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return token;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user