sites

mirror of git://git.suckless.org/sites
Log | Files | Refs

commit 763e91701525df3278d9a6bc7e37826f04d47138
parent 5ba883567ba8955c6a66017fa5b21d58415a00f9
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Thu,  3 Jan 2019 13:42:01 +0100

build-page: treat read error as fatal, simplify chdir error handling

Diffstat:
Mbuild-page.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/build-page.c b/build-page.c @@ -136,6 +136,9 @@ oneline(char *buf, size_t bufsiz, char const *path) return -1; } r = fgets(buf, bufsiz, fp); + if (ferror(fp)) + die_perror("fgets: %s", path); + fclose(fp); if (r) @@ -304,10 +307,8 @@ main(int argc, char *argv[]) if ((page = strchr(argv[1], '/'))) *page++ = '\0'; domain = argv[1]; - if (chdir(domain) == -1) { - perror(domain); - return 1; - } + if (chdir(domain) == -1) + die_perror("chdir: %s", domain); print_header(domain, page); print_nav_bar(domain, page);