mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:57:47 +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)
|
static void wc_out(const Count& count)
|
||||||
{
|
{
|
||||||
if (g_output_line)
|
if (g_output_line)
|
||||||
printf("%7i ", count.lines);
|
out("{:7} ", count.lines);
|
||||||
if (g_output_word)
|
if (g_output_word)
|
||||||
printf("%7i ", count.words);
|
out("{:7} ", count.words);
|
||||||
if (g_output_byte)
|
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)
|
static Count get_count(const String& file_specifier)
|
||||||
|
@ -67,7 +67,7 @@ static Count get_count(const String& file_specifier)
|
||||||
} else {
|
} else {
|
||||||
count.name = file_specifier;
|
count.name = file_specifier;
|
||||||
if ((file_pointer = fopen(file_specifier.characters(), "r")) == nullptr) {
|
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;
|
count.exists = false;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue