From 50f9ad14de921295d7a1687799e30562808e940a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Thu, 14 Nov 2013 17:06:20 +0100 Subject: Refactored remote changes --- options.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'options.c') diff --git a/options.c b/options.c index 574f871..e4d597c 100644 --- a/options.c +++ b/options.c @@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options; void print_usage(void) { - printf("usage: sxiv [-bcdFfhioqrstvZ] [-g GEOMETRY] [-G GAMMA] [-n NUM] " + printf("usage: sxiv [-bcdFfhioqrstvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] " "[-N name] [-z ZOOM] FILES...\n"); } @@ -45,6 +45,7 @@ void print_version(void) void parse_options(int argc, char **argv) { int opt, t, gamma; + char *end; _options.from_stdin = false; _options.to_stdout = false; @@ -65,7 +66,7 @@ void parse_options(int argc, char **argv) _options.thumb_mode = false; _options.clean_cache = false; - while ((opt = getopt(argc, argv, "bcdFfg:G:hin:N:oqrstvZz:")) != -1) { + while ((opt = getopt(argc, argv, "bcdFfG:g:hin:N:oqrstvZz:")) != -1) { switch (opt) { case '?': print_usage(); @@ -85,17 +86,18 @@ void parse_options(int argc, char **argv) case 'f': _options.fullscreen = true; break; - case 'g': - _options.geometry = optarg; - break; case 'G': - if (sscanf(optarg, "%d", &gamma) <= 0) { + gamma = strtol(optarg, &end, 0); + if (*end != '\0') { fprintf(stderr, "sxiv: invalid argument for option -G: %s\n", optarg); exit(EXIT_FAILURE); } _options.gamma = gamma; break; + case 'g': + _options.geometry = optarg; + break; case 'h': print_usage(); exit(EXIT_SUCCESS); -- cgit v1.2.3