From 8373b17cd79d5076e7ca535fb2b5cf7a1d505eb0 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 13 Nov 2022 09:11:53 +0100 Subject: Use constants instead of macros --- center.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/center.c b/center.c index cbc4d54..d412473 100644 --- a/center.c +++ b/center.c @@ -30,8 +30,6 @@ #include #define ESC 033 -#define OPTSTR "elrt:w:" -#define PROG_ARGS "[-elr] [-t width] [-w width] [file ...]\n" #define die(...) err(EXIT_FAILURE, __VA_ARGS__) #define diex(...) errx(EXIT_FAILURE, __VA_ARGS__) @@ -75,6 +73,8 @@ int main(int argc, char **argv) { int opt; + const char *optstr = "elrt:w:", + *progargs = "[-elr] [-t width] [-w width] [file ...]"; void (*centerfunc)(FILE *) = center; static struct option longopts[] = { {"ignore-ansi", no_argument, NULL, 'e'}, @@ -84,8 +84,7 @@ main(int argc, char **argv) {"width", required_argument, NULL, 'w'}, {NULL, 0, NULL, 0 } }; - - while ((opt = getopt_long(argc, argv, OPTSTR, longopts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, optstr, longopts, NULL)) != -1) { switch (opt) { case 'e': lenfunc = utf8len; @@ -103,7 +102,7 @@ main(int argc, char **argv) width = polong(optarg, "output width"); break; default: - fprintf(stderr, "Usage: %s " PROG_ARGS, argv[0]); + fprintf(stderr, "Usage: %s %s\n", argv[0], progargs); exit(EXIT_FAILURE); } } -- cgit v1.2.3