aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-11-13 09:11:53 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-11-13 09:17:42 +0100
commit8373b17cd79d5076e7ca535fb2b5cf7a1d505eb0 (patch)
tree058e43a51b8727063de834f19809705ce069b8a7
parentc01be381492b5cc3b912ee3419f7fda5fa43b8e3 (diff)
Use constants instead of macrosv1.3.0
-rw-r--r--center.c9
1 files 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 <unistd.h>
#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);
}
}