diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-31 10:29:20 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-31 10:29:20 +0800 |
commit | 77d9b1a3211d23ce3f57928006eaab6e719f64af (patch) | |
tree | bbf8213cd9226fa9035cb834d311440fcaa3c497 | |
parent | Proper tabs on repo index (diff) | |
download | forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.tar.gz forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.tar.zst forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.zip |
Add colb from June McEnroe
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | utils/.gitignore | 1 | ||||
-rw-r--r-- | utils/colb.c | 22 |
3 files changed, 27 insertions, 2 deletions
@@ -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); +} |