commit 9c7cc7b
default
·
2023-07-04 14:33:54 +0000 UTC
parent 9bf872d
index_list() and index_list_desc() don't return deleted entries.
1 files changed,
+10,
-6
M
data.c
M
data.c
+10,
-6
1@@ -496,9 +496,11 @@ xs_list *index_list(const char *fn, int max)
2 list = xs_list_new();
3
4 while (n < max && fgets(line, sizeof(line), f) != NULL) {
5- line[32] = '\0';
6- list = xs_list_append(list, line);
7- n++;
8+ if (line[0] != '-') {
9+ line[32] = '\0';
10+ list = xs_list_append(list, line);
11+ n++;
12+ }
13 }
14
15 fclose(f);
16@@ -524,9 +526,11 @@ xs_list *index_list_desc(const char *fn, int skip, int show)
17 /* move to the end minus one entry (or more, if skipping entries) */
18 if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) {
19 while (n < show && fgets(line, sizeof(line), f) != NULL) {
20- line[32] = '\0';
21- list = xs_list_append(list, line);
22- n++;
23+ if (line[0] != '-') {
24+ line[32] = '\0';
25+ list = xs_list_append(list, line);
26+ n++;
27+ }
28
29 /* move backwards 2 entries */
30 if (fseek(f, -66, SEEK_CUR) == -1)