diff options
| author | Nakidai <nakidai@disroot.org> | 2025-04-20 23:04:54 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-04-20 23:04:54 +0300 |
| commit | 4accbc94ab3b6dca87ce857a5b5b7ed9ed8169bb (patch) | |
| tree | 1b2ce567e2ec6de6e9d192172580f91d179c8a92 | |
| parent | 91103235348e0ebf2a602f6db2dc429fe5289739 (diff) | |
| download | deansi-master.tar.gz deansi-master.zip | |
Now it's smaller than the docs lol
| -rw-r--r-- | deansi.c | 20 |
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); } |