From 411379f587d2052d4d1f3ecc7e9d5d927c7deeb6 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 21 May 2023 08:21:40 +0200 Subject: [PATCH] Codechange: replace puts with fmt::print --- src/debug.cpp | 3 +-- src/newgrf_profiling.cpp | 4 ++-- src/settingsgen/settingsgen.cpp | 4 ++-- src/strgen/strgen.cpp | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index 7a411a1077..5038025cba 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -138,8 +138,7 @@ void DebugPrint(const char *level, const std::string &message) fflush(f); #endif } else { - std::string msg = fmt::format("{}dbg: [{}] {}\n", GetLogPrefix(), level, message); - fputs(msg.c_str(), stderr); + fmt::print(stderr, "{}dbg: [{}] {}\n", GetLogPrefix(), level, message); if (_debug_remote_console.load()) { /* Only add to the queue when there is at least one consumer of the data. */ diff --git a/src/newgrf_profiling.cpp b/src/newgrf_profiling.cpp index f3700d453b..6b7d656c54 100644 --- a/src/newgrf_profiling.cpp +++ b/src/newgrf_profiling.cpp @@ -109,9 +109,9 @@ uint32 NewGRFProfiler::Finish() uint32 total_microseconds = 0; - fputs("Tick,Sprite,Feature,Item,CallbackID,Microseconds,Depth,Result\n", f); + fmt::print(f, "Tick,Sprite,Feature,Item,CallbackID,Microseconds,Depth,Result\n"); for (const Call &c : this->calls) { - fputs(fmt::format("{},{},{:#X},{},{:#X},{},{},{}\n", c.tick, c.root_sprite, c.feat, c.item, (uint)c.cb, c.time, c.subs, c.result).c_str(), f); + fmt::print(f, "{},{},{:#X},{},{:#X},{},{},{}\n", c.tick, c.root_sprite, c.feat, c.item, (uint)c.cb, c.time, c.subs, c.result); total_microseconds += c.time; } diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp index 273d414b0c..a074c87051 100644 --- a/src/settingsgen/settingsgen.cpp +++ b/src/settingsgen/settingsgen.cpp @@ -456,11 +456,11 @@ int CDECL main(int argc, char *argv[]) switch (i) { case 'v': - puts("$Revision$"); + fmt::print("$Revision$\n"); return 0; case 'h': - puts("settingsgen - $Revision$\n" + fmt::print("settingsgen - $Revision$\n" "Usage: settingsgen [options] ini-file...\n" "with options:\n" " -v, --version Print version information and exit\n" diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 3f7b181e7a..b1325ee28c 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -423,7 +423,7 @@ int CDECL main(int argc, char *argv[]) switch (i) { case 'v': - puts("$Revision$"); + fmt::print("$Revision$\n"); return 0; case 'C': @@ -467,7 +467,7 @@ int CDECL main(int argc, char *argv[]) break; case 'h': - puts( + fmt::print( "strgen - $Revision$\n" " -v | --version print version information and exit\n" " -t | --todo replace any untranslated strings with ''\n" @@ -480,7 +480,7 @@ int CDECL main(int argc, char *argv[]) " -export-pragmas export all pragmas and exit\n" " Run without parameters and strgen will search for english.txt and parse it,\n" " creating strings.h. Passing an argument, strgen will translate that language\n" - " file using english.txt as a reference and output .lng." + " file using english.txt as a reference and output .lng.\n" ); return 0;