From dcd259a100252449f1a53f3040996920d52c7875 Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Tue, 12 Jan 2021 00:06:29 +0100 Subject: [PATCH] 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. :^) --- Userland/wc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/wc.cpp b/Userland/wc.cpp index 89a1cfd675..0cdeb0ad46 100644 --- a/Userland/wc.cpp +++ b/Userland/wc.cpp @@ -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; }