diff options
author | jaseg <git@jaseg.net> | 2018-07-22 20:47:25 +0200 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2018-07-22 20:47:25 +0200 |
commit | fd9436a7f0962a479cdf2cd0f5d42ad3b4ab0d54 (patch) | |
tree | 8407c08ff4a86999340cbc87d500c4085b7e2198 /censor.c | |
parent | 87248c46ffda6311fa6477ca8de2e37f10a8f0d8 (diff) | |
download | lolcat-fd9436a7f0962a479cdf2cd0f5d42ad3b4ab0d54.tar.gz lolcat-fd9436a7f0962a479cdf2cd0f5d42ad3b4ab0d54.tar.bz2 lolcat-fd9436a7f0962a479cdf2cd0f5d42ad3b4ab0d54.zip |
auto-format c sources
Diffstat (limited to 'censor.c')
-rw-r--r-- | censor.c | 51 |
1 files changed, 26 insertions, 25 deletions
@@ -13,63 +13,64 @@ * 0. You just DO WHAT THE FUCK YOU WANT TO. */ -#include <stdint.h> -#include <stdio.h> -#include <wchar.h> #include <ctype.h> #include <err.h> #include <errno.h> +#include <locale.h> +#include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <locale.h> -#include <unistd.h> #include <sys/time.h> +#include <unistd.h> +#include <wchar.h> -int main(int argc, char **argv){ - char **inputs = argv+1; - char **inputs_end = argv+argc; - if(inputs == inputs_end){ - char *foo[] = {"-"}; +int main(int argc, char** argv) +{ + char** inputs = argv + 1; + char** inputs_end = argv + argc; + if (inputs == inputs_end) { + char* foo[] = { "-" }; inputs = foo; - inputs_end = inputs+1; + inputs_end = inputs + 1; } setlocale(LC_ALL, ""); int escape_state = 0; - for(char **filename=inputs; filename<inputs_end; filename++){ - FILE *f = stdin; + for (char** filename = inputs; filename < inputs_end; filename++) { + FILE* f = stdin; - if(strcmp(*filename, "-")) + if (strcmp(*filename, "-")) f = fopen(*filename, "r"); - - if(!f){ + + if (!f) { fprintf(stderr, "Cannot open input file \"%s\": %s\n", *filename, strerror(errno)); return 2; - } + } int c; - while((c = fgetwc(f)) > 0){ - if(!escape_state){ - if(c == '\e'){ + while ((c = fgetwc(f)) > 0) { + if (!escape_state) { + if (c == '\e') { printf("%lc", c); escape_state = 1; - }else if(strchr("acegmnopqrsuvwxyz", c)) + } else if (strchr("acegmnopqrsuvwxyz", c)) printf("▄"); - else if(strchr(".,:; \t\r\n", c)) + else if (strchr(".,:; \t\r\n", c)) printf("%lc", c); else printf("█"); - }else{ + } else { printf("%lc", c); - if(!strchr("[0123456789;", c)) + if (!strchr("[0123456789;", c)) escape_state = 0; } } fclose(f); - if(c != WEOF && c != 0){ + if (c != WEOF && c != 0) { fprintf(stderr, "Error reading input file \"%s\": %s\n", *filename, strerror(errno)); return 2; } |