From 35b413f525146c1c2cbe509967c2595378fdc299 Mon Sep 17 00:00:00 2001 From: Lieuwe Rooijakkers Date: Sun, 21 Jul 2024 20:25:52 +0200 Subject: tak: verbeter fout afhandeling --- src/tak.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/tak.c b/src/tak.c index e8fb817..1fc8ff5 100644 --- a/src/tak.c +++ b/src/tak.c @@ -4,7 +4,6 @@ #include #include -#include "util/map.h" #include "util/versie.h" #include "io/read_file.h" @@ -70,9 +69,7 @@ int entry_tak(int argc, char **argv) { if (*args == NULL) { struct filebuf *fb = stream_to_filebuf(stdin); - if (fb == NULL) { - return 1; - } + if (fb == NULL) goto err_stdin; process(fb); return 0; @@ -83,19 +80,24 @@ int entry_tak(int argc, char **argv) { if (!strcmp(*args, "-")) { fb = stream_to_filebuf(stdin); - if (fb == NULL) { - return 1; - } + if (fb == NULL) goto err_stdin; } - if (fb == NULL) { - fb = file_to_filebuf(*args); - } + if (fb == NULL) fb = file_to_filebuf(*args); + if (fb == NULL) goto err_file; process(fb); args++; } return 0; + +err_stdin: + fprintf(stderr, "staart: fout bij lezen van standaard invoer"); + return 1; + +err_file: +fprintf(stderr, "staart: fout bij lezen van bestand"); + return 1; } -- cgit v1.2.3-70-g09d2