summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rn.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rn.c b/src/rn.c
index be4fed9..5d05322 100644
--- a/src/rn.c
+++ b/src/rn.c
@@ -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) {