1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

wc: printf(), fprintf(stderr, ...) -> out(), outln(), warnln().

Problem:
- We were using some incorrect format strings in printf-functions:
 * "%7lu" to print `size_t` values instead of "%7zu";
 * "%7i" to print `unsigned int` values instead of "%7u".

Solution:
- Use out(), outln() and warnln() instead of printf-functions. :^)
This commit is contained in:
Emanuele Torre 2021-01-12 00:06:29 +01:00 committed by Andreas Kling
parent 725eb702b7
commit dcd259a100

View file

@ -48,13 +48,13 @@ bool g_output_word = false;
static void wc_out(const Count& count)
{
if (g_output_line)
printf("%7i ", count.lines);
out("{:7} ", count.lines);
if (g_output_word)
printf("%7i ", count.words);
out("{:7} ", count.words);
if (g_output_byte)
printf("%7lu ", count.bytes);
out("{:7} ", count.bytes);
printf("%14s\n", count.name.characters());
outln("{:>14}", count.name);
}
static Count get_count(const String& file_specifier)
@ -67,7 +67,7 @@ static Count get_count(const String& file_specifier)
} else {
count.name = file_specifier;
if ((file_pointer = fopen(file_specifier.characters(), "r")) == nullptr) {
fprintf(stderr, "wc: unable to open %s\n", file_specifier.characters());
warnln("wc: unable to open {}", file_specifier);
count.exists = false;
return count;
}