about summary refs log tree commit diff
path: root/deansi.c
blob: d1194ebf6b774713ee3639beea604ed893f5dd8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
}