cards

a command-line tool for reviewing flashcards
git clone https://github.com/tanguyandreani/cards
Log | Files | Refs | README

commit ac1428d674795b20905890104f7f5c5ff85da91c
parent 297405e12d6a2825b3e56322878548885f1df422
Author: Tanguy Andreani <dev@tanguy.space>
Date:   Tue,  9 Apr 2019 15:44:16 +0200

now verify that parse_csv() does not return NULL

Diffstat:
Mcards.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/cards.c b/cards.c @@ -257,15 +257,21 @@ main(int argc, char *argv[]) char csv_line[MAX_CSV_SIZE]; + int l = 0; while (fgets(csv_line, MAX_CSV_SIZE, fp) != NULL) { + l++; + #define o(k,v, p, l) \ ht_insert(cards, k, v, p, l) char **items = parse_csv(csv_line); - if (!items[0] || !items[1] || !items[2]) - continue; + if (items == NULL || !items[0] || !items[1] || !items[2]) { + fprintf(stderr, "Couldn't parse line %d!\n", l); + fclose(fp); + goto end; + } wchar_t q[MAX_QA_SIZE], a[MAX_QA_SIZE]; swprintf(q, MAX_QA_SIZE, L"%hs", items[0]);