summary refs log tree commit diff
path: root/.bin
diff options
context:
space:
mode:
authorJune McEnroe <curtis.mcenroe@adgear.com>2016-09-12 14:52:25 -0400
committerJune McEnroe <curtis.mcenroe@adgear.com>2016-09-12 14:52:25 -0400
commit3a6a3b7bcc570899b1814106ca5670b0d49b198a (patch)
treefcee37e7b0bca220019464f732a4289e0cfd92da /.bin
parentAdd .bin/xx.c (diff)
downloadsrc-3a6a3b7bcc570899b1814106ca5670b0d49b198a.tar.gz
src-3a6a3b7bcc570899b1814106ca5670b0d49b198a.zip
Add -c option to xx
Diffstat (limited to '')
-rwxr-xr-x.bin/xx.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/.bin/xx.c b/.bin/xx.c
index d2d86574..153ba74e 100755
--- a/.bin/xx.c
+++ b/.bin/xx.c
@@ -1,17 +1,24 @@
 #if 0
-exec cc -Weverything -o ~/.bin/xx $0
+exec cc -Weverything -Wno-vla -o ~/.bin/xx $0
 #endif
 
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 int main(int argc, char **argv)
 {
+    size_t cols = 16;
     char *path = NULL;
 
-    if (argc > 1)
-        path = argv[1];
+    while (getopt(argc, argv, "c:") > 0)
+        if (optopt == 'c') {
+            cols = (size_t) strtol(optarg, NULL, 10);
+            if (!cols) return EXIT_FAILURE;
+        } else return EXIT_FAILURE;
+    if (argc > optind)
+        path = argv[optind];
 
     FILE *file = path ? fopen(path, "r") : stdin;
     if (!file) {
@@ -19,7 +26,7 @@ int main(int argc, char **argv)
         return EXIT_FAILURE;
     }
 
-    uint8_t buf[16];
+    uint8_t buf[cols];
     for (;;) {
         size_t n = fread(buf, 1, sizeof(buf), file);
         for (size_t i = 0; i < n; ++i)
atgirl/commit/ui.c?h=2.0&id=ea4c70dae5f548ec3f1346f7e54794be0187a95b&follow=1'>Rename line editing functionsJune McEnroe 2018-08-05Initialize all possible color pairsJune McEnroe This is actually possible with use_default_colors! 2018-08-05Refactor color initializationJune McEnroe 2018-08-05Add ^L redrawJune McEnroe 2018-08-05Use 16 colors if availableJune McEnroe Fall back to using bold if there are only 8 colors. This also allowed bright background colors in 16-color terminals. I must port this system to torus. I'll be able to remove the awful termcap patch hack. 2018-08-05Limit parsed colors to number of mIRC colorsJune McEnroe Oh boy that's embarrassing. 2018-08-04Show source link on exitJune McEnroe 2018-08-04Implement line editing, scrollingJune McEnroe Don't really have a way to implement the M-* keys, and currently missing C-w. 2018-08-04Handle /topicJune McEnroe