summaryrefslogtreecommitdiff
path: root/usr.bin/jot
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2018-01-12 06:22:32 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2018-01-12 06:22:32 +0000
commiteac606dae07fa300f178b2b75e6c99f5ffb6cba7 (patch)
tree3541db961a56d6d9a85211fba2908095bf317576 /usr.bin/jot
parent0e94a1811d3a0a09a95a4896e07890c31b54c409 (diff)
Align cases in conversion switch vertically. Normalize logic inside cases
and drop an unnecessary test for intdata in '%c'. reads ok to halex, ok millert
Diffstat (limited to 'usr.bin/jot')
-rw-r--r--usr.bin/jot/jot.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c
index 6944439b998..14070bca1d5 100644
--- a/usr.bin/jot/jot.c
+++ b/usr.bin/jot/jot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jot.c,v 1.42 2018/01/11 14:53:42 tb Exp $ */
+/* $OpenBSD: jot.c,v 1.43 2018/01/12 06:22:31 tb Exp $ */
/* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */
/*-
@@ -398,38 +398,41 @@ getformat(void)
}
}
switch (*p) {
- case 'o': case 'u': case 'x': case 'X':
- intdata = nosign = true;
- break;
- case 'd': case 'i':
+ case 'd':
+ case 'i':
intdata = true;
break;
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ intdata = nosign = true;
+ break;
case 'D':
- /* %lD is undefined */
- if (!longdata) {
- longdata = true; /* %D behaves as %ld */
- intdata = true;
- break;
- }
- goto fmt_broken;
- case 'O': case 'U':
- /* %lO and %lU are undefined */
- if (!longdata) {
- longdata = true; /* %O, %U behave as %lo, %lu */
- intdata = nosign = true;
- break;
- }
- goto fmt_broken;
+ if (longdata)
+ goto fmt_broken;
+ longdata = intdata = true; /* same as %ld */
+ break;
+ case 'O':
+ case 'U':
+ if (longdata)
+ goto fmt_broken;
+ longdata = intdata = nosign = true; /* same as %l[ou] */
+ break;
case 'c':
- if (!(intdata | longdata)) {
- chardata = true;
- break;
- }
- goto fmt_broken;
- case 'f': case 'e': case 'g': case 'E': case 'G':
- if (!longdata)
- break;
- /* FALLTHROUGH */
+ if (longdata)
+ goto fmt_broken;
+ chardata = true;
+ break;
+ case 'e':
+ case 'E':
+ case 'f':
+ case 'g':
+ case 'G':
+ if (longdata)
+ goto fmt_broken;
+ /* No cast needed for printing in putdata() */
+ break;
default:
fmt_broken:
errx(1, "illegal or unsupported format '%.*s'",