From 11b8be3660288f75fee09b00296ce93745f321fb Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 6 Feb 2018 22:05:38 -0500 Subject: Require 4 bit counts on gfxx command line --- bin/gfxx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/gfxx.c b/bin/gfxx.c index c99df532..c2d09576 100644 --- a/bin/gfxx.c +++ b/bin/gfxx.c @@ -79,12 +79,11 @@ extern int init(int argc, char *argv[]) { default: return EX_USAGE; } break; case 'b': { - size_t len = strlen(optarg); - if (len < 3 || len > 4) return EX_USAGE; - bits[0] = (len > 3) ? optarg[0] - '0' : 0; - bits[1] = optarg[len-3] - '0'; - bits[2] = optarg[len-2] - '0'; - bits[3] = optarg[len-1] - '0'; + if (strlen(optarg) < 4) return EX_USAGE; + bits[0] = optarg[0] - '0'; + bits[1] = optarg[1] - '0'; + bits[2] = optarg[2] - '0'; + bits[3] = optarg[3] - '0'; } break; case 'n': offset = strtoul(optarg, NULL, 0); break; case 'f': flip ^= true; break; -- cgit 1.4.1