From e441e9c17b69313007051b2c2b68ec01679d8bde Mon Sep 17 00:00:00 2001 From: June 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(-) diff --git a/bin/gfxx.c b/bin/gfxx.c index 0d0b9c79..b1d642bf 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