summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-12-02 13:24:10 +0900
committerjaseg <git@jaseg.net>2018-12-02 13:37:47 +0900
commite913f914c463ac45f619ce90bdcc8b9555d31e87 (patch)
tree6a7470644ef7d21bed519470eefc923b528f8628
parent29bc06513dbb8beb223f6fe6c13cfe2ad3bed20f (diff)
downloadlolcat-e913f914c463ac45f619ce90bdcc8b9555d31e87.tar.gz
lolcat-e913f914c463ac45f619ce90bdcc8b9555d31e87.tar.bz2
lolcat-e913f914c463ac45f619ce90bdcc8b9555d31e87.zip
Use wprintf and putwchar instead of printf
Thanks @BourgeoisBear
-rw-r--r--lolcat.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lolcat.c b/lolcat.c
index 213ccc6..2ba558e 100644
--- a/lolcat.c
+++ b/lolcat.c
@@ -65,13 +65,13 @@ void find_escape_sequences(wint_t c, int* state)
void usage()
{
- printf("Usage: lolcat [-h horizontal_speed] [-v vertical_speed] [--] [FILES...]\n");
+ wprintf(L"Usage: lolcat [-h horizontal_speed] [-v vertical_speed] [--] [FILES...]\n");
exit(1);
}
void version()
{
- printf("lolcat version 0.1, (c) 2014 jaseg\n");
+ wprintf(L"lolcat version 0.1, (c) 2014 jaseg\n");
exit(0);
}
@@ -154,7 +154,7 @@ int main(int argc, char** argv)
this_file_read_wchar = &fgetwc;
f = fopen(*filename, "r");
if (!f) {
- fprintf(stderr, "Cannot open input file \"%s\": %s\n", *filename, strerror(errno));
+ fwprintf(stderr, L"Cannot open input file \"%s\": %s\n", *filename, strerror(errno));
return 2;
}
}
@@ -170,15 +170,15 @@ int main(int argc, char** argv)
} else {
int ncc = offx * ARRAY_SIZE(codes) + (int)((i += wcwidth(c)) * freq_h + l * freq_v);
if (cc != ncc)
- printf("\033[38;5;%hhum", codes[(cc = ncc) % ARRAY_SIZE(codes)]);
+ wprintf(L"\033[38;5;%hhum", codes[(cc = ncc) % ARRAY_SIZE(codes)]);
}
}
}
- printf("%lc", c);
+ putwchar(c);
if (escape_state == 2)
- printf("\033[38;5;%hhum", codes[cc % ARRAY_SIZE(codes)]);
+ wprintf(L"\033[38;5;%hhum", codes[cc % ARRAY_SIZE(codes)]);
}
printf("\n\033[0m");
cc = -1;
@@ -187,7 +187,7 @@ int main(int argc, char** argv)
fclose(f);
if (ferror(f)) {
- fprintf(stderr, "Error reading input file \"%s\": %s\n", *filename, strerror(errno));
+ fwprintf(stderr, L"Error reading input file \"%s\": %s\n", *filename, strerror(errno));
return 2;
}
}