scribo

Email-based phlog generator
git clone git://git.z3bra.org/scribo.git
Log | Files | Refs

commit edd08054989a560b60a1039cd25e405a59dae81c
parent e4acb5dbbe7330f20b7762305f9b1e291c3efe92
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue,  8 Sep 2020 13:35:28 +0200

Open infile/outfile only when needed

Diffstat:
Mscribo.c | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/scribo.c b/scribo.c @@ -218,14 +218,6 @@ main(int argc, char *argv[]) return -1; } - if (outfile && strcmp(outfile, "-")) - out = fopen(outfile, "w"); - - if (!out) { - perror(outfile); - return -1; - } - if (parseheaders(in, &headers) < 0) { perror("header section"); return -1; @@ -236,10 +228,19 @@ main(int argc, char *argv[]) return -1; } + fclose(in); + + if (outfile && strcmp(outfile, "-")) + out = fopen(outfile, "w"); + + if (!out) { + perror(outfile); + return -1; + } + if (writeindex(out, basedir) < 0) return -1; - fclose(in); fclose(out); return 0;