code-style: don't indent switch cases (#358)

The suckless coding style [^0] and the linux coding style [^1] both
recommends not indenting switch cases. And it helps out people with
lower resolution monitors.

[^0]: https://suckless.org/coding_style/
[^1]: https://www.kernel.org/doc/html/v5.10/process/coding-style.html#indentation

Co-authored-by: explosion-mental <explosion0mental@gmail.com>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/358
Reviewed-by: NRK <nrk@disroot.org>
Co-authored-by: explosion-mental <explosion-mental@noreply.codeberg.org>
Co-committed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
This commit is contained in:
explosion-mental
2022-08-16 10:54:31 +02:00
committed by NRK
parent 6578e6eb65
commit 0f0c49a630
4 changed files with 197 additions and 198 deletions

198
options.c
View File

@ -132,105 +132,105 @@ void parse_options(int argc, char **argv)
assert(op.optarg != NULL);
}
switch (opt) {
case '?':
fprintf(stderr, "%s\n", op.errmsg);
print_usage();
exit(EXIT_FAILURE);
case 'A':
n = strtol(op.optarg, &end, 0);
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -A: %s", op.optarg);
_options.framerate = n;
/* fall through */
case 'a':
_options.animate = true;
break;
case 'b':
_options.hide_bar = true;
break;
case 'c':
_options.clean_cache = true;
break;
case 'e':
n = strtol(op.optarg, &end, 0);
if (*end != '\0')
error(EXIT_FAILURE, 0, "Invalid argument for option -e: %s", op.optarg);
_options.embed = n;
break;
case 'f':
_options.fullscreen = true;
break;
case 'G':
n = strtol(op.optarg, &end, 0);
if (*end != '\0')
error(EXIT_FAILURE, 0, "Invalid argument for option -G: %s", op.optarg);
_options.gamma = n;
break;
case 'g':
_options.geometry = op.optarg;
break;
case 'h':
print_usage();
exit(EXIT_SUCCESS);
case 'i':
_options.from_stdin = true;
break;
case 'n':
n = strtol(op.optarg, &end, 0);
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -n: %s", op.optarg);
_options.startnum = n - 1;
break;
case 'N':
_options.res_name = op.optarg;
break;
case 'o':
_options.to_stdout = true;
break;
case 'p':
_options.private_mode = true;
break;
case 'q':
_options.quiet = true;
break;
case 'r':
_options.recursive = true;
break;
case 'S':
n = strtof(op.optarg, &end) * 10;
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -S: %s", op.optarg);
_options.slideshow = n;
break;
case 's':
s = strchr(scalemodes, op.optarg[0]);
if (s == NULL || *s == '\0' || strlen(op.optarg) != 1)
error(EXIT_FAILURE, 0, "Invalid argument for option -s: %s", op.optarg);
_options.scalemode = s - scalemodes;
break;
case 'T':
title_deprecation_notice(); /* TODO(v31): remove this option */
break;
case 't':
_options.thumb_mode = true;
break;
case 'v':
print_version();
exit(EXIT_SUCCESS);
case 'Z':
_options.scalemode = SCALE_ZOOM;
_options.zoom = 1.0f;
break;
case 'z':
n = strtol(op.optarg, &end, 0);
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -z: %s", op.optarg);
_options.scalemode = SCALE_ZOOM;
_options.zoom = (float) n / 100.0f;
break;
case '0':
_options.using_null = true;
break;
case '?':
fprintf(stderr, "%s\n", op.errmsg);
print_usage();
exit(EXIT_FAILURE);
case 'A':
n = strtol(op.optarg, &end, 0);
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -A: %s", op.optarg);
_options.framerate = n;
/* fall through */
case 'a':
_options.animate = true;
break;
case 'b':
_options.hide_bar = true;
break;
case 'c':
_options.clean_cache = true;
break;
case 'e':
n = strtol(op.optarg, &end, 0);
if (*end != '\0')
error(EXIT_FAILURE, 0, "Invalid argument for option -e: %s", op.optarg);
_options.embed = n;
break;
case 'f':
_options.fullscreen = true;
break;
case 'G':
n = strtol(op.optarg, &end, 0);
if (*end != '\0')
error(EXIT_FAILURE, 0, "Invalid argument for option -G: %s", op.optarg);
_options.gamma = n;
break;
case 'g':
_options.geometry = op.optarg;
break;
case 'h':
print_usage();
exit(EXIT_SUCCESS);
case 'i':
_options.from_stdin = true;
break;
case 'n':
n = strtol(op.optarg, &end, 0);
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -n: %s", op.optarg);
_options.startnum = n - 1;
break;
case 'N':
_options.res_name = op.optarg;
break;
case 'o':
_options.to_stdout = true;
break;
case 'p':
_options.private_mode = true;
break;
case 'q':
_options.quiet = true;
break;
case 'r':
_options.recursive = true;
break;
case 'S':
n = strtof(op.optarg, &end) * 10;
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -S: %s", op.optarg);
_options.slideshow = n;
break;
case 's':
s = strchr(scalemodes, op.optarg[0]);
if (s == NULL || *s == '\0' || strlen(op.optarg) != 1)
error(EXIT_FAILURE, 0, "Invalid argument for option -s: %s", op.optarg);
_options.scalemode = s - scalemodes;
break;
case 'T':
title_deprecation_notice(); /* TODO(v31): remove this option */
break;
case 't':
_options.thumb_mode = true;
break;
case 'v':
print_version();
exit(EXIT_SUCCESS);
case 'Z':
_options.scalemode = SCALE_ZOOM;
_options.zoom = 1.0f;
break;
case 'z':
n = strtol(op.optarg, &end, 0);
if (*end != '\0' || n <= 0)
error(EXIT_FAILURE, 0, "Invalid argument for option -z: %s", op.optarg);
_options.scalemode = SCALE_ZOOM;
_options.zoom = (float) n / 100.0f;
break;
case '0':
_options.using_null = true;
break;
}
}