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.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/deansi.c b/deansi.c
index d1194eb..bc9bae1 100644
--- a/deansi.c
+++ b/deansi.c
@@ -1,22 +1,10 @@
 #include <stdio.h>
-
-
 int main(int argc, char **argv)
 {
-	int ch, next, csi;
-
-	csi = 0;
+	int ch, next, 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;
-	}
+		ch == 0x1b && ((next = getchar()) == '[' ? csi = 1 : ungetc(next, stdin)),
+		!csi && putchar(ch),
+		ch >= 0x40 && ch <= 0x7e && (csi = 0);
 	return ferror(stdin);
 }