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:
parent
725eb702b7
commit
dcd259a100
1 changed files with 5 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue