summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2018-02-06 22:05:38 -0500
committerJune McEnroe <programble@gmail.com>2018-02-06 22:05:38 -0500
commit11b8be3660288f75fee09b00296ce93745f321fb (patch)
treec48a66dbded5dcc4e65db1228c20252a4cc66d34 /bin
parentAdd gfxx controls for custom bits (diff)
downloadsrc-11b8be3660288f75fee09b00296ce93745f321fb.tar.gz
src-11b8be3660288f75fee09b00296ce93745f321fb.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 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;