aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-10-05 00:27:48 +0200
committerThomas Voss <mail@thomasvoss.com> 2022-10-05 00:27:48 +0200
commita22d3b91339a5e063461be948596e9da88ce0d35 (patch)
treea1c616332d32484d53747fcd47d65019199b2fb5
parent3da85228915ccb935e48bad228c4707544040783 (diff)
Sort command-line flags
-rw-r--r--center.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/center.c b/center.c
index 9099584..60e5355 100644
--- a/center.c
+++ b/center.c
@@ -62,19 +62,13 @@ main(int argc, char **argv)
char *endptr;
void (*centerfunc)(FILE *) = center;
- while ((opt = getopt(argc, argv, ":elsw:t:")) != -1) {
+ while ((opt = getopt(argc, argv, ":elt:w:")) != -1) {
switch (opt) {
case 'e':
lenfunc = utf8len;
break;
- case 'w':
- width = strtol(optarg, &endptr, 0);
- if (*optarg == '\0' || *endptr != '\0')
- errx(EXIT_FAILURE, "Invalid integer '%s'", optarg);
- if (width <= 0)
- errx(EXIT_FAILURE, "Width must be >0");
- if (errno == ERANGE || width > INT_MAX)
- warnx("Potential overflow of given width");
+ case 'l':
+ centerfunc = center_by_longest;
break;
case 't':
tabwidth = strtol(optarg, &endptr, 0);
@@ -85,11 +79,17 @@ main(int argc, char **argv)
if (errno == ERANGE || tabwidth > INT_MAX)
warnx("Potential overflow of given tab size");
break;
- case 'l':
- centerfunc = center_by_longest;
+ case 'w':
+ width = strtol(optarg, &endptr, 0);
+ if (*optarg == '\0' || *endptr != '\0')
+ errx(EXIT_FAILURE, "Invalid integer '%s'", optarg);
+ if (width <= 0)
+ errx(EXIT_FAILURE, "Width must be >0");
+ if (errno == ERANGE || width > INT_MAX)
+ warnx("Potential overflow of given width");
break;
default:
- fprintf(stderr, "Usage: %s [-e] [-w width] [-t tab width] [file ...]\n", argv[0]);
+ fprintf(stderr, "Usage: %s [-el] [-t tab width] [-w width] [file ...]\n", argv[0]);
exit(EXIT_FAILURE);
}
}