about summary refs log tree commit diff
path: root/deansi.c
diff options
context:
space:
mode:
Diffstat (limited to 'deansi.c')
-rw-r--r--deansi.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/deansi.c b/deansi.c
new file mode 100644
index 0000000..d1194eb
--- /dev/null
+++ b/deansi.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+
+int main(int argc, char **argv)
+{
+	int ch, next, csi;
+
+	csi = 0;
+	while ((ch = getchar()) != EOF)
+	{
+		if (ch == 27 /* ^[ */)
+			if ((next = getchar()) == '[')
+				csi = 1;
+			else if (next != EOF)
+				ungetc(next, stdin);
+		if (!csi)
+			putchar(ch);
+		if (ch >= 0x40 && ch <= 0x7e)
+			csi = 0;
+	}
+	return ferror(stdin);
+}