diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rn.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1,3 +1,4 @@ +#include <errno.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -51,12 +52,17 @@ static void process(const char *fname, FILE *file, bool perFile, size_t *n) { size_t linen = 0; ssize_t nread = 0; - while ((nread = getline(&line, &linen, file)) != -1) { + while ((errno = 0, nread = getline(&line, &linen, file)) != -1) { printf("%6lu %s", *n, line); *n += 1; } free(line); + + if (errno != 0) { + printf("tak: fout bij lezen uit bestand '%s'\n", fname); + exit(1); + } } int entry_rn(int argc, char **argv) { |