aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/.gitignore1
-rw-r--r--utils/colb.c22
2 files changed, 23 insertions, 0 deletions
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);
+}