aboutsummaryrefslogtreecommitdiff
path: root/center.c
diff options
context:
space:
mode:
Diffstat (limited to 'center.c')
-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);
}
}