diff options
author | June McEnroe <june@causal.agency> | 2018-05-25 01:18:53 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-05-25 01:18:53 -0400 |
commit | bdb67f6892e4dee6b93dcf554f60d55058f62238 (patch) | |
tree | 56bf2e5d008f90169ee33f7494d423c0615fca7f /bin | |
parent | Use PF_UNIX (diff) | |
download | src-bdb67f6892e4dee6b93dcf554f60d55058f62238.tar.gz src-bdb67f6892e4dee6b93dcf554f60d55058f62238.zip |
Use break; case style everywhere*
*Except in switches where every branch does a return.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/brot.c | 38 | ||||
-rw-r--r-- | bin/gfxx.c | 113 | ||||
-rw-r--r-- | bin/glitch.c | 18 | ||||
-rw-r--r-- | bin/pngo.c | 8 | ||||
-rw-r--r-- | bin/scheme.c | 14 | ||||
-rw-r--r-- | bin/xx.c | 14 |
6 files changed, 103 insertions, 102 deletions
diff --git a/bin/brot.c b/bin/brot.c index f487c236..cd520cb9 100644 --- a/bin/brot.c +++ b/bin/brot.c @@ -89,20 +89,20 @@ static double scaleStep = 1.0 / 32.0; bool input(char in) { const double PI = acos(-1.0); switch (in) { - case 'q': return false; - break; case '.': depth++; - break; case ',': if (depth > 1) depth--; - break; case 'l': translate += translateStep * transform; - break; case 'h': translate -= translateStep * transform; - break; case 'j': translate += translateStep * I * transform; - break; case 'k': translate -= translateStep * I * transform; - break; case 'u': transform *= cexp(rotateStep * PI * I); - break; case 'i': transform /= cexp(rotateStep * PI * I); - break; case '+': transform *= 1.0 - scaleStep; - break; case '-': transform /= 1.0 - scaleStep; - break; case '0': translate = -0.75; transform = 2.5; - break; case ']': samples++; - break; case '[': if (samples > 1) samples--; + break; case 'q': return false; + break; case '.': depth++; + break; case ',': if (depth > 1) depth--; + break; case 'l': translate += translateStep * transform; + break; case 'h': translate -= translateStep * transform; + break; case 'j': translate += translateStep * I * transform; + break; case 'k': translate -= translateStep * I * transform; + break; case 'u': transform *= cexp(rotateStep * PI * I); + break; case 'i': transform /= cexp(rotateStep * PI * I); + break; case '+': transform *= 1.0 - scaleStep; + break; case '-': transform /= 1.0 - scaleStep; + break; case '0': translate = -0.75; transform = 2.5; + break; case ']': samples++; + break; case '[': if (samples > 1) samples--; } return true; } @@ -136,11 +136,11 @@ int init(int argc, char *argv[]) { int opt; while (0 < (opt = getopt(argc, argv, "f:i:s:t:"))) { switch (opt) { - case 'f': transform = parseComplex(optarg); break; - case 'i': depth = strtoul(optarg, NULL, 0); break; - case 's': samples = strtoul(optarg, NULL, 0); break; - case 't': translate = parseComplex(optarg); break; - default: return EX_USAGE; + break; case 'f': transform = parseComplex(optarg); + break; case 'i': depth = strtoul(optarg, NULL, 0); + break; case 's': samples = strtoul(optarg, NULL, 0); + break; case 't': translate = parseComplex(optarg); + break; default: return EX_USAGE; } } return EX_OK; diff --git a/bin/gfxx.c b/bin/gfxx.c index 2a7eb36e..4f67318c 100644 --- a/bin/gfxx.c +++ b/bin/gfxx.c @@ -74,36 +74,39 @@ int init(int argc, char *argv[]) { int opt; while (0 < (opt = getopt(argc, argv, "c:p:b:e:E:n:fmw:z:o:"))) { switch (opt) { - case 'c': switch (optarg[0]) { - case 'i': space = COLOR_INDEXED; break; - case 'g': space = COLOR_GRAYSCALE; break; - case 'r': space = COLOR_RGB; break; - default: return EX_USAGE; - } break; - case 'p': pal = optarg; break; - case 'e': switch (optarg[0]) { - case 'l': byteOrder = ENDIAN_LITTLE; break; - case 'b': byteOrder = ENDIAN_BIG; break; - default: return EX_USAGE; - } break; - case 'E': switch (optarg[0]) { - case 'l': bitOrder = ENDIAN_LITTLE; break; - case 'b': bitOrder = ENDIAN_BIG; break; - default: return EX_USAGE; - } break; - case 'b': { + break; case 'c': + switch (optarg[0]) { + break; case 'i': space = COLOR_INDEXED; + break; case 'g': space = COLOR_GRAYSCALE; + break; case 'r': space = COLOR_RGB; + break; default: return EX_USAGE; + } + break; case 'p': pal = optarg; + break; case 'e': + switch (optarg[0]) { + break; case 'l': byteOrder = ENDIAN_LITTLE; + break; case 'b': byteOrder = ENDIAN_BIG; + break; default: return EX_USAGE; + } + break; case 'E': + switch (optarg[0]) { + break; case 'l': bitOrder = ENDIAN_LITTLE; + break; case 'b': bitOrder = ENDIAN_BIG; + break; default: return EX_USAGE; + } + break; case 'b': { if (strlen(optarg) < 4) return EX_USAGE; for (int i = 0; i < 4; ++i) { bits[i] = optarg[i] - '0'; } - } break; - case 'n': offset = strtoul(optarg, NULL, 0); break; - case 'f': flip ^= true; break; - case 'm': mirror ^= true; break; - case 'w': width = strtoul(optarg, NULL, 0); break; - case 'z': scale = strtoul(optarg, NULL, 0); break; - case 'o': prefix = optarg; break; - default: return EX_USAGE; + } + break; case 'n': offset = strtoul(optarg, NULL, 0); + break; case 'f': flip ^= true; + break; case 'm': mirror ^= true; + break; case 'w': width = strtoul(optarg, NULL, 0); + break; case 'z': scale = strtoul(optarg, NULL, 0); + break; case 'o': prefix = optarg; + break; default: return EX_USAGE; } } if (argc > optind) path = argv[optind]; @@ -458,35 +461,35 @@ bool input(char in) { size_t pixel = (BITS_TOTAL + 7) / 8; size_t row = width * BITS_TOTAL / 8; switch (in) { - case 'q': return false; - break; case 'x': dump = DUMP_ONE; - break; case 'X': dump ^= DUMP_ALL; - break; case 'o': formatOptions(); printf("%s\n", options); - break; case '[': if (!space--) space = COLOR__COUNT - 1; - break; case ']': if (++space == COLOR__COUNT) space = 0; - break; case 'p': palSample(); - break; case 'P': palDump(); - break; case '{': if (!preset--) preset = PRESETS_LEN - 1; setPreset(); - break; case '}': if (++preset == PRESETS_LEN) preset = 0; setPreset(); - break; case 'e': byteOrder ^= ENDIAN_BIG; - break; case 'E': bitOrder ^= ENDIAN_BIG; - break; case 'h': if (offset) offset--; - break; case 'j': offset += pixel; - break; case 'k': if (offset >= pixel) offset -= pixel; - break; case 'l': offset++; - break; case 'H': if (offset >= row) offset -= row; - break; case 'J': offset += width * row; - break; case 'K': if (offset >= width * row) offset -= width * row; - break; case 'L': offset += row; - break; case '.': width++; - break; case ',': if (width > 1) width--; - break; case '>': width *= 2; - break; case '<': if (width > 1) width /= 2; - break; case 'f': flip ^= true; - break; case 'm': mirror ^= true; - break; case '+': scale++; - break; case '-': if (scale > 1) scale--; - break; default: if (in >= '0' && in <= '9') setBit(in); + break; case 'q': return false; + break; case 'x': dump = DUMP_ONE; + break; case 'X': dump ^= DUMP_ALL; + break; case 'o': formatOptions(); printf("%s\n", options); + break; case '[': if (!space--) space = COLOR__COUNT - 1; + break; case ']': if (++space == COLOR__COUNT) space = 0; + break; case 'p': palSample(); + break; case 'P': palDump(); + break; case '{': if (!preset--) preset = PRESETS_LEN - 1; setPreset(); + break; case '}': if (++preset == PRESETS_LEN) preset = 0; setPreset(); + break; case 'e': byteOrder ^= ENDIAN_BIG; + break; case 'E': bitOrder ^= ENDIAN_BIG; + break; case 'h': if (offset) offset--; + break; case 'j': offset += pixel; + break; case 'k': if (offset >= pixel) offset -= pixel; + break; case 'l': offset++; + break; case 'H': if (offset >= row) offset -= row; + break; case 'J': offset += width * row; + break; case 'K': if (offset >= width * row) offset -= width * row; + break; case 'L': offset += row; + break; case '.': width++; + break; case ',': if (width > 1) width--; + break; case '>': width *= 2; + break; case '<': if (width > 1) width /= 2; + break; case 'f': flip ^= true; + break; case 'm': mirror ^= true; + break; case '+': scale++; + break; case '-': if (scale > 1) scale--; + break; default: if (in >= '0' && in <= '9') setBit(in); } return true; } diff --git a/bin/glitch.c b/bin/glitch.c index 6732522d..bd3d1e48 100644 --- a/bin/glitch.c +++ b/bin/glitch.c @@ -460,18 +460,16 @@ int main(int argc, char *argv[]) { int opt; while (0 < (opt = getopt(argc, argv, "a:cd:fo:pr"))) { switch (opt) { - case 'a': { + break; case 'a': options.applyFilter = parseFilters(options.applyFilters, optarg); - } break; - case 'c': stdio = true; break; - case 'd': { + break; case 'c': stdio = true; + break; case 'd': options.declareFilter = parseFilters(options.declareFilters, optarg); - } break; - case 'f': options.filt = true; break; - case 'o': output = optarg; break; - case 'p': options.brokenPaeth = true; break; - case 'r': options.recon = true; break; - default: return EX_USAGE; + break; case 'f': options.filt = true; + break; case 'o': output = optarg; + break; case 'p': options.brokenPaeth = true; + break; case 'r': options.recon = true; + break; default: return EX_USAGE; } } diff --git a/bin/pngo.c b/bin/pngo.c index e4afa082..49c734da 100644 --- a/bin/pngo.c +++ b/bin/pngo.c @@ -697,10 +697,10 @@ int main(int argc, char *argv[]) { int opt; while (0 < (opt = getopt(argc, argv, "co:v"))) { switch (opt) { - case 'c': stdio = true; break; - case 'o': output = optarg; break; - case 'v': verbose = true; break; - default: return EX_USAGE; + break; case 'c': stdio = true; + break; case 'o': output = optarg; + break; case 'v': verbose = true; + break; default: return EX_USAGE; } } diff --git a/bin/scheme.c b/bin/scheme.c index b43e4fec..e85b7dbb 100644 --- a/bin/scheme.c +++ b/bin/scheme.c @@ -204,13 +204,13 @@ int main(int argc, char *argv[]) { int opt; while (0 < (opt = getopt(argc, argv, "aghltx"))) { switch (opt) { - case 'a': gen = ansi; break; - case 'g': out = png; break; - case 'h': out = hsv; break; - case 'l': out = linux; break; - case 't': gen = terminal; break; - case 'x': out = hex; break; - default: return EX_USAGE; + break; case 'a': gen = ansi; + break; case 'g': out = png; + break; case 'h': out = hsv; + break; case 'l': out = linux; + break; case 't': gen = terminal; + break; case 'x': out = hex; + break; default: return EX_USAGE; } } struct Scheme scheme = gen(); diff --git a/bin/xx.c b/bin/xx.c index 663ee044..c584be61 100644 --- a/bin/xx.c +++ b/bin/xx.c @@ -107,13 +107,13 @@ int main(int argc, char *argv[]) { int opt; while (0 < (opt = getopt(argc, argv, "ac:g:rsz"))) { switch (opt) { - case 'a': options.ascii ^= true; break; - case 'c': options.cols = strtoul(optarg, NULL, 0); break; - case 'g': options.group = strtoul(optarg, NULL, 0); break; - case 'r': reverse = true; break; - case 's': options.offset ^= true; break; - case 'z': options.skip ^= true; break; - default: return EX_USAGE; + break; case 'a': options.ascii ^= true; + break; case 'c': options.cols = strtoul(optarg, NULL, 0); + break; case 'g': options.group = strtoul(optarg, NULL, 0); + break; case 'r': reverse = true; + break; case 's': options.offset ^= true; + break; case 'z': options.skip ^= true; + break; default: return EX_USAGE; } } if (argc > optind) path = argv[optind]; |