X-Git-Url: https://git.cworth.org/git?p=mnemon;a=blobdiff_plain;f=mnemon.c;h=ea2e0a1e06c5ecbf1d18da1943cb09ea1ec58871;hp=d28657bfe20d8a4c877bbbb30edf98d2694a74a7;hb=a2a91a3fa4d6cbbfb52b4d6e2233cc39f2488865;hpb=ad1afbd96d6a1de1b49e365a7573af1c1b09f557 diff --git a/mnemon.c b/mnemon.c index d28657b..ea2e0a1 100644 --- a/mnemon.c +++ b/mnemon.c @@ -543,7 +543,7 @@ mnemon_save (mnemon_t *mnemon) err = rename (lock_filename, filename); if (err < 0) { - fprintf (stderr, "Error: Failes to rename %s to %s: %s\n", + fprintf (stderr, "Error: Failed to rename %s to %s: %s\n", lock_filename, filename, strerror (errno)); continue; } @@ -651,12 +651,18 @@ mnemon_do_challenges (mnemon_t *mnemon) if (correct) { printf ("Correct! (Moving from %d to ", item->count); item->count++; + /* We reserve an item count of 0 for an item that has + * never been asked. */ + if (item->count == 0) + item->count = 1; printf ("%d)\n\n", item->count); } else { printf (" %s is the correct answer. (Moving from %d to ", item->response, item->count); item->count--; - if (item->count > 0) + /* Penalize an incorrect response by forcing the count + * negative. */ + if (item->count >= 0) item->count = -1; printf ("%d)\n\n", item->count); }