aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-31 10:29:20 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-31 10:29:20 +0800
commit77d9b1a3211d23ce3f57928006eaab6e719f64af (patch)
treebbf8213cd9226fa9035cb834d311440fcaa3c497
parentProper tabs on repo index (diff)
downloadforge-77d9b1a3211d23ce3f57928006eaab6e719f64af.tar.gz
forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.tar.zst
forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.zip
Add colb from June McEnroe
-rw-r--r--Makefile6
-rw-r--r--utils/.gitignore1
-rw-r--r--utils/colb.c22
3 files changed, 27 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 0171a2c..3783d4f 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,10 @@ man: $(MAN_PAGES:%=man/%.html) $(MAN_PAGES:%=man/%.txt)
man/%.html: man/%
mandoc -Thtml -O style=./mandoc.css $< > $@
-man/%.txt: man/%
- mandoc $< | col -b > $@
+man/%.txt: man/% utils/colb
+ mandoc $< | ./utils/colb > $@
+
+utils/colb: utils/colb.c
hookc/hookc:
diff --git a/utils/.gitignore b/utils/.gitignore
new file mode 100644
index 0000000..0d965ce
--- /dev/null
+++ b/utils/.gitignore
@@ -0,0 +1 @@
+/colb
diff --git a/utils/colb.c b/utils/colb.c
new file mode 100644
index 0000000..e50ac5d
--- /dev/null
+++ b/utils/colb.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// SPDX-FileCopyrightText: Copyright (c) 2021 June McEnroe <june@causal.agency>
+
+#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+
+int main(void)
+{
+ setlocale(LC_CTYPE, "C.UTF-8");
+ wint_t next, prev = WEOF;
+ while (WEOF != (next = getwchar())) {
+ if (next == L'\b') {
+ prev = WEOF;
+ } else {
+ if (prev != WEOF) putwchar(prev);
+ prev = next;
+ }
+ }
+ if (prev != WEOF)
+ putwchar(prev);
+}