diff options
author | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-08-02 22:36:51 +0200 |
---|---|---|
committer | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2024-08-02 22:38:00 +0200 |
commit | 843e6fb1a772703593ce4685cc83bdaaaba67138 (patch) | |
tree | d216e38a69bfa8c217cb5d02a2d18d83cf2de82c /src | |
parent | c4ccd4e0798a7ed9af6f86d9819b309575d418a0 (diff) |
tak: lees errno
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) { |