-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathansi2txt.c
31 lines (30 loc) · 820 Bytes
/
ansi2txt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
int main()
{
int ch;
do
{
ch=getchar();
while (ch==13)
if ((ch=getchar())!=10)
putchar(13); /* suppress \r only when followed by \n */
if (ch==27)
if ((ch=getchar())=='[')
while ((ch=getchar())==';'||(ch>='0'&&ch<='9')||ch=='?');
else if (ch==']'&&(ch=getchar())>=0&&ch<='9')
for (;;)
{
if ((ch=getchar())==EOF||ch==7)
break;
else if (ch==27)
{ch=getchar(); break;}
}
else if (ch=='%'||ch=='('||ch==')')
ch=getchar();
else {}
else if (ch!=EOF)
putchar(ch);
}
while (ch!=EOF);
return 0;
}