index_list() and index_list_desc() don't return deleted entries.

This commit is contained in:
default 2023-07-04 16:33:54 +02:00
parent 9bf872d603
commit 9c7cc7b710

16
data.c
View file

@ -496,9 +496,11 @@ xs_list *index_list(const char *fn, int max)
list = xs_list_new(); list = xs_list_new();
while (n < max && fgets(line, sizeof(line), f) != NULL) { while (n < max && fgets(line, sizeof(line), f) != NULL) {
line[32] = '\0'; if (line[0] != '-') {
list = xs_list_append(list, line); line[32] = '\0';
n++; list = xs_list_append(list, line);
n++;
}
} }
fclose(f); fclose(f);
@ -524,9 +526,11 @@ xs_list *index_list_desc(const char *fn, int skip, int show)
/* move to the end minus one entry (or more, if skipping entries) */ /* move to the end minus one entry (or more, if skipping entries) */
if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) { if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) {
while (n < show && fgets(line, sizeof(line), f) != NULL) { while (n < show && fgets(line, sizeof(line), f) != NULL) {
line[32] = '\0'; if (line[0] != '-') {
list = xs_list_append(list, line); line[32] = '\0';
n++; list = xs_list_append(list, line);
n++;
}
/* move backwards 2 entries */ /* move backwards 2 entries */
if (fseek(f, -66, SEEK_CUR) == -1) if (fseek(f, -66, SEEK_CUR) == -1)