From 73c0ebd0f1ca9d5b2f390de708287ef9c3b122f8 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 15 Oct 2022 12:37:43 +0200 Subject: Define the die() and diex() macros --- center.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/center.c b/center.c index eb769c7..745af61 100644 --- a/center.c +++ b/center.c @@ -33,6 +33,9 @@ #define ESC 033 +#define die(...) err(EXIT_FAILURE, __VA_ARGS__) +#define diex(...) errx(EXIT_FAILURE, __VA_ARGS__) + struct line_item { char *buffer; STAILQ_ENTRY(line_item) list; @@ -102,7 +105,7 @@ main(int argc, char **argv) } if (width == -1 && (width = cols()) == -1) - errx(EXIT_FAILURE, "unable to determine output width"); + diex("unable to determine output width"); argc -= optind; argv += optind; @@ -213,7 +216,7 @@ cols(void) if (!isatty(STDOUT_FILENO)) return -1; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) - err(EXIT_FAILURE, "ioctl"); + die("ioctl"); return w.ws_col; } @@ -308,9 +311,9 @@ polong(long *n, const char *s) char *endptr; *n = strtol(optarg, &endptr, 0); if (*optarg == '\0' || *endptr != '\0') - errx(EXIT_FAILURE, "invalid integer '%s'", optarg); + diex("invalid integer '%s'", optarg); if (*n < 0) - errx(EXIT_FAILURE, "%s must be >= 0", s); + diex("%s must be >= 0", s); if (errno == ERANGE || *n > INT_MAX) \ warnx("potential overflow of given tab size"); } -- cgit v1.2.3