|
|
improve consistency of line counting (on an invalid file) - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed) |
|
|
 |
git clone git://git.codemadness.org/sfeed_curses (git://git.codemadness.org) |
|
|
 |
Log |
|
|
 |
Files |
|
|
 |
Refs |
|
|
 |
README |
|
|
 |
LICENSE |
|
|
|
--- |
|
|
 |
commit 827f4afdcecbb6cb53ee60d52d068ce5f94bbaac |
|
|
 |
parent 1d4e2e3f6913318cdfce03f08bb517a8c8ebbc56 |
|
|
 |
Author: Hiltjo Posthuma <hiltjo@codemadness.org> (mailto://) |
application/vnd.lotus-organizer |
|
|
Date: Sat, 10 Jul 2021 19:14:48 +0200 |
|
|
|
|
|
|
|
improve consistency of line counting (on an invalid file) |
|
|
|
|
|
|
|
This only happens when there is an invalid sfeed(5) feed file with an empty |
|
|
|
line. The feed_items_get() function would stop further processing, but the |
|
|
|
feed_count() function did not. |
|
|
|
|
|
|
|
Diffstat: |
|
|
|
M sfeed_curses.c | 6 +++--- |
|
|
|
|
|
|
|
1 file changed, 3 insertions(+), 3 deletions(-) |
|
|
|
--- |
|
|
 |
diff --git a/sfeed_curses.c b/sfeed_curses.c |
|
|
|
@@ -1262,7 +1262,7 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret) |
|
|
|
struct item *item, *items = NULL; |
|
|
|
char *line = NULL; |
|
|
|
size_t cap, i, linesize = 0, nitems; |
|
|
|
- ssize_t linelen; |
|
|
|
+ ssize_t linelen, n; |
|
|
|
off_t offset; |
|
|
|
int ret = -1; |
|
|
|
|
|
|
|
@@ -1273,7 +1273,7 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret) |
|
|
|
cap = cap ? cap * 2 : 16; |
|
|
|
items = erealloc(items, cap * sizeof(struct item)); |
|
|
|
} |
|
|
|
- if ((linelen = getline(&line, &linesize, fp)) > 0) { |
|
|
|
+ if ((n = linelen = getline(&line, &linesize, fp)) > 0) { |
|
|
|
item = &items[i]; |
|
|
|
|
|
|
|
item->offset = offset; |
|
|
|
@@ -1296,7 +1296,7 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret) |
|
|
|
} |
|
|
|
if (ferror(fp)) |
|
|
|
goto err; |
|
|
|
- if (linelen <= 0 || feof(fp)) |
|
|
|
+ if (n <= 0 || feof(fp)) |
|
|
|
break; |
|
|
|
} |
|
|
|
ret = 0; |
|