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 /utils/colb.c | |
parent | Proper tabs on repo index (diff) | |
download | forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.tar.gz forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.tar.zst forge-77d9b1a3211d23ce3f57928006eaab6e719f64af.zip |
Add colb from June McEnroe
Diffstat (limited to 'utils/colb.c')
-rw-r--r-- | utils/colb.c | 22 |
1 files changed, 22 insertions, 0 deletions
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); +} |