diff options
author | jaseg <code@jaseg.net> | 2016-04-28 22:55:06 +0200 |
---|---|---|
committer | jaseg <code@jaseg.net> | 2016-04-28 22:55:06 +0200 |
commit | 88c27c9df81fc88978991a27a454a4035c457ed0 (patch) | |
tree | 689448c062ebf1db15a6921bd453c4f6a47863d3 /censor.c | |
parent | 9f3492f131cd6faac5c24e9c829f4f70a108ee26 (diff) | |
download | lolcat-88c27c9df81fc88978991a27a454a4035c457ed0.tar.gz lolcat-88c27c9df81fc88978991a27a454a4035c457ed0.tar.bz2 lolcat-88c27c9df81fc88978991a27a454a4035c457ed0.zip |
Improve interop
Diffstat (limited to 'censor.c')
-rw-r--r-- | censor.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -36,6 +36,7 @@ int main(int argc, char **argv){ setlocale(LC_ALL, ""); + int escape_state = 0; for(char **filename=inputs; filename<inputs_end; filename++){ FILE *f = stdin; @@ -49,12 +50,21 @@ int main(int argc, char **argv){ int c; while((c = fgetwc(f)) > 0){ - if(strchr("acegmnopqrsuvwxyz", c)) - printf("▄"); - else if(strchr(".,:; \t\r\n", c)) + if(!escape_state){ + if(c == '\e'){ + printf("%lc", c); + escape_state = 1; + }else if(strchr("acegmnopqrsuvwxyz", c)) + printf("▄"); + else if(strchr(".,:; \t\r\n", c)) + printf("%lc", c); + else + printf("█"); + }else{ printf("%lc", c); - else - printf("█"); + if(!strchr("[0123456789;", c)) + escape_state = 0; + } } fclose(f); |