summary refs log tree commit diff
path: root/www/text.causal.agency/colb.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-09-26 13:00:12 -0400
committerJune McEnroe <june@causal.agency>2021-09-26 16:53:21 -0400
commit0b6278a185c125ece5ca75ada224e61a7213c6d4 (patch)
treeb96d68833e46c634feef621f69ac5f1844801f9a /www/text.causal.agency/colb.c
parentInstall up to cgi-bin (diff)
downloadsrc-0b6278a185c125ece5ca75ada224e61a7213c6d4.tar.gz
src-0b6278a185c125ece5ca75ada224e61a7213c6d4.zip
Use tiny UTF-8-aware col -b replacement
OpenBSD col(1) doesn't understand UTF-8 and will delete all of it.
Stupid, especially when mandoc(1) tells you to use it to remove man
formatting. I shouldn't have to write something so trivial.
Diffstat (limited to 'www/text.causal.agency/colb.c')
-rw-r--r--www/text.causal.agency/colb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/www/text.causal.agency/colb.c b/www/text.causal.agency/colb.c
new file mode 100644
index 00000000..5faabc3a
--- /dev/null
+++ b/www/text.causal.agency/colb.c
@@ -0,0 +1,16 @@
+#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+int main(void) {
+	setlocale(LC_CTYPE, "en_US.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);
+}