summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-02-06 22:05:38 -0500
committerJune McEnroe <june@causal.agency>2018-02-06 22:05:38 -0500
commite441e9c17b69313007051b2c2b68ec01679d8bde (patch)
treed6fd07f1c7cf5e88fd0b85bc4640f7aad5662930 /bin
parentAdd gfxx controls for custom bits (diff)
downloadsrc-e441e9c17b69313007051b2c2b68ec01679d8bde.tar.gz
src-e441e9c17b69313007051b2c2b68ec01679d8bde.zip
Require 4 bit counts on gfxx command line
Diffstat (limited to 'bin')
-rw-r--r--bin/gfxx.c11
1 files 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;